Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into feature/block-tool-adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyamore88 committed Dec 23, 2023
2 parents 97f721f + 5390859 commit 6f7f4db
Show file tree
Hide file tree
Showing 16 changed files with 305 additions and 152 deletions.
21 changes: 21 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Build"
inputs:
package-name:
description: 'Name of the package'
required: true
runs:
using: "composite"
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc

- name: Setup environment
uses: ./.github/actions/setup

- name: Build the package with dependencies
env:
STRYKER_DASHBOARD_API_KEY: ${{ inputs.stryker_dashboard_api_key }}
shell: bash
run: yarn workspaces foreach -Rpt --from '${{ inputs.package-name }}' run build
19 changes: 19 additions & 0 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Lint"
inputs:
package-name:
description: 'Name of the package'
required: true
runs:
using: "composite"
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc

- name: Setup environment
uses: ./.github/actions/setup

- name: Run ESLint check
shell: bash
run: yarn workspace ${{ inputs.package-name }} lint:ci
22 changes: 22 additions & 0 deletions .github/actions/mutation-tests-all-files/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Mutation tests for all files
inputs:
package-name:
description: 'Name of the package'
required: true
stryker_dashboard_api_key:
description: 'Stryker dashboard api key'
required: true
runs:
using: "composite"
steps:
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc

- name: Setup environment
uses: ./.github/actions/setup

- name: Run mutation tests
shell: bash
id: run-mutation-tests
run: yarn workspace ${{ inputs.package-name }} test:mutations --dashboard.version main
99 changes: 99 additions & 0 deletions .github/actions/mutation-tests-changed-files/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Mutation tests for changed files
inputs:
working-directory:
description: 'Path to the ./packages/name_of_your_package_folder'
required: true
package-name:
description: 'A full name of the package'
required: true
stryker_dashboard_api_key:
description: 'Stryker dashboard api key'
required: true
runs:
using: "composite"
steps:
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc

- name: Setup environment
uses: ./.github/actions/setup

- name: Get changed files
uses: tj-actions/[email protected]
id: changed-files
with:
files_yaml: |
src:
- 'src/**/*.ts'
- '!src/**/*.spec.ts'
- '!src/**/__mocks__/**'
separator: "','"
path: ${{ inputs.working-directory }}

- name: Run mutation tests
if: steps.changed-files.outputs.src_any_changed == 'true'
shell: bash
id: run-mutation-tests
run: yarn workspace ${{ inputs.package-name }} test:mutations --mutate ${{format('''{0}''', steps.changed-files.outputs.src_all_changed_files)}}
continue-on-error: true

- name: Find current PR's number
uses: jwalton/gh-find-current-pr@v1
id: findPr

- name: Comment on successful mutation testing
uses: thollander/actions-comment-pull-request@v2
env:
STRYKER_DASHBOARD_API_KEY: ${{ inputs.stryker_dashboard_api_key }}
if: steps.changed-files.outputs.src_any_changed == 'true' && steps.run-mutation-tests.outcome == 'success' && ${{ steps.findPr.outputs.number != '' }}
with:
message: |
✅ Mutation testing passed for `${{ inputs.working-directory }}`
Report: https://dashboard.stryker-mutator.io/reports/github.com/editor-js/document-model/PR-${{ github.event.number }}
<details>
<summary>Mutated files</summary>
<pre>
${{ join(fromJson(format('[{0}]', format('''{0}''', steps.changed-files.outputs.src_all_changed_files))), '<br />') }}
</pre>
</details>
comment_tag: mutation-tests for `${{ inputs.working-directory }}`
pr_number: ${{ steps.findPr.outputs.number != '' && steps.findPr.outputs.number || '1'}}

- name: Comment on failed mutation testing
uses: thollander/actions-comment-pull-request@v2
env:
STRYKER_DASHBOARD_API_KEY: ${{ inputs.stryker_dashboard_api_key }}
if: steps.changed-files.outputs.src_any_changed == 'true' && steps.run-mutation-tests.outcome == 'failure' && ${{ steps.findPr.outputs.number != '' }}
with:
message: |
❌ Mutation testing hasn't passed score threshold for `${{ inputs.working-directory }}`
Report: https://dashboard.stryker-mutator.io/reports/github.com/editor-js/document-model/PR-${{ github.event.number }}
<details>
<summary>Mutated files</summary>
<pre>
${{ join(fromJson(format('[{0}]', format('''{0}''', steps.changed-files.outputs.src_all_changed_files))), '<br />') }}
</pre>
</details>
comment_tag: mutation-tests for `${{ inputs.working-directory }}`
pr_number: ${{ steps.findPr.outputs.number != '' && steps.findPr.outputs.number || '1'}}

- name: Comment on empty changes
uses: thollander/actions-comment-pull-request@v2
env:
STRYKER_DASHBOARD_API_KEY: ${{ inputs.stryker_dashboard_api_key }}
if: steps.changed-files.outputs.src_any_changed == 'false' && ${{ steps.findPr.outputs.number != '' }}
with:
message: |
⏭️ No files to mutate for `${{ inputs.working-directory }}`
comment_tag: mutation-tests for `${{ inputs.working-directory }}`
pr_number: ${{ steps.findPr.outputs.number != '' && steps.findPr.outputs.number || '1'}}

- if: steps.changed-files.outputs.src_any_changed == 'true' && steps.run-mutation-tests.outcome == 'failure'
shell: bash
run: exit 1
29 changes: 29 additions & 0 deletions .github/actions/unit-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Unit tests
inputs:
working-directory:
description: 'Path to the ./packages/name_of_your_package_folder'
required: true
package-name:
description: 'A full name of the package'
required: true

runs:
using: "composite"
steps:
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- uses: ./.github/actions/setup

# Find current PR's number
- uses: jwalton/gh-find-current-pr@v1
id: findPr

- name: Run unit tests
uses: ArtiomTr/jest-coverage-report-action@v2
with:
custom-title: Coverage report for `${{ inputs.working-directory }}`
working-directory: ${{ inputs.working-directory }}
test-script: yarn workspace ${{ inputs.package-name }} test
package-manager: yarn
prnumber: ${{ steps.findPr.outputs.number }}
53 changes: 53 additions & 0 deletions .github/workflows/dom-adapters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Dom-adapters check
on:
push:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run ESLint check
uses: ./.github/actions/lint
with:
package-name: '@editorjs/dom-adapters'

tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run unit tests
uses: ./.github/actions/unit-tests
with:
working-directory: './packages/dom-adapters'
package-name: '@editorjs/dom-adapters'

mutation-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Run mutation tests for changed files
if: ${{ github.event_name == 'push' }}
uses: ./.github/actions/mutation-tests-changed-files
with:
package-name: '@editorjs/dom-adapters'
working-directory: './packages/dom-adapters'
stryker_dashboard_api_key: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}

- name: Run mutation tests for all files
if: ${{ github.event_name == 'merge_group' }}
uses: ./.github/actions/mutation-tests-all-files
with:
package-name: '@editorjs/dom-adapters'
working-directory: './packages/dom-adapters'
stryker_dashboard_api_key: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build the package
uses: ./.github/actions/build
with:
package-name: '@editorjs/dom-adapters'
58 changes: 0 additions & 58 deletions .github/workflows/model-merge.yml

This file was deleted.

Loading

0 comments on commit 6f7f4db

Please sign in to comment.