Skip to content

Commit

Permalink
feat: add working directory input on composite actions, add a name of…
Browse files Browse the repository at this point in the history
… package on mutation test comment
  • Loading branch information
GoldenJaden committed Nov 24, 2023
1 parent 160535e commit bd63fd5
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ runs:
env:
STRYKER_DASHBOARD_API_KEY: ${{ inputs.stryker_dashboard_api_key }}
shell: bash
run: yarn workspaces foreach -Rpt --from '@editorjs/${{ inputs.package-name }}' run build
run: yarn workspaces foreach -Rpt --from '${{ inputs.package-name }}' run build
2 changes: 1 addition & 1 deletion .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ runs:

- name: Run ESLint check
shell: bash
run: yarn workspace @editorjs/${{ inputs.package-name }} lint:ci
run: yarn workspace ${{ inputs.package-name }} lint:ci
2 changes: 1 addition & 1 deletion .github/actions/mutation-tests-all-files/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ runs:
- name: Run mutation tests
shell: bash
id: run-mutation-tests
run: yarn workspace @editorjs/${{ inputs.package-name }} test:mutations --dashboard.version main
run: yarn workspace ${{ inputs.package-name }} test:mutations --dashboard.version main
17 changes: 10 additions & 7 deletions .github/actions/mutation-tests-changed-files/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Run mutation tests for changed files only
name: Mutation tests for changed files
inputs:
working-directory:
description: 'Path to the ./packages/name_of_your_package_folder'
required: true
package-name:
description: 'Name of the package'
description: 'A full name of the package'
required: true
stryker_dashboard_api_key:
description: 'Stryker dashboard api key'
Expand All @@ -26,13 +29,13 @@ runs:
- '!src/**/*.spec.ts'
- '!src/**/__mocks__/**'
separator: "','"
path: packages/${{ inputs.package-name }}
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 @editorjs/${{ inputs.package-name }} test:mutations --mutate ${{format('''{0}''', steps.changed-files.outputs.src_all_changed_files)}}
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
Expand All @@ -46,7 +49,7 @@ runs:
if: steps.changed-files.outputs.src_any_changed == 'true' && steps.run-mutation-tests.outcome == 'success' && ${{ steps.findPr.outputs.number != '' }}
with:
message: |
## ✅ Mutation testing passed
✅ Mutation testing passed for `${{ inputs.working-directory }}`
Report: https://dashboard.stryker-mutator.io/reports/github.com/editor-js/document-model/PR-${{ github.event.number }}
Expand All @@ -66,7 +69,7 @@ runs:
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
❌ 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 }}
Expand All @@ -86,7 +89,7 @@ runs:
if: steps.changed-files.outputs.src_any_changed == 'false' && ${{ steps.findPr.outputs.number != '' }}
with:
message: |
## ⏭️ No files to mutate
⏭️ No files to mutate for `${{ inputs.working-directory }}`
comment_tag: mutation-tests
pr_number: ${{ steps.findPr.outputs.number != '' && steps.findPr.outputs.number || '1'}}
Expand Down
11 changes: 7 additions & 4 deletions .github/actions/unit-tests/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Run unit test
name: Unit tests
inputs:
working-directory:
description: 'Path to the ./packages/name_of_your_package_folder'
required: true
package-name:
description: 'Name of the package'
description: 'A full name of the package'
required: true

runs:
Expand All @@ -19,7 +22,7 @@ runs:
- name: Run unit tests
uses: ArtiomTr/jest-coverage-report-action@v2
with:
working-directory: ./packages/${{ inputs.package-name }}
test-script: yarn workspace @editorjs/${{ inputs.package-name }} test
working-directory: ${{ inputs.working-directory }}
test-script: yarn workspace ${{ inputs.package-name }} test
package-manager: yarn
prnumber: ${{ steps.findPr.outputs.number }}
13 changes: 8 additions & 5 deletions .github/workflows/dom-adapters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Run ESLint check
uses: ./.github/actions/lint
with:
package-name: dom-adapters
package-name: '@editorjs/dom-adapters'

tests:
runs-on: ubuntu-latest
Expand All @@ -19,7 +19,8 @@ jobs:
- name: Run unit tests
uses: ./.github/actions/unit-tests
with:
package-name: dom-adapters
working-directory: './packages/dom-adapters'
package-name: '@editorjs/dom-adapters'

mutation-tests:
runs-on: ubuntu-latest
Expand All @@ -30,14 +31,16 @@ jobs:
if: ${{ github.event_name == 'push' }}
uses: ./.github/actions/mutation-tests-changed-files
with:
package-name: dom-adapters
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: dom-adapters
package-name: '@editorjs/dom-adapters'
working-directory: './packages/dom-adapters'
stryker_dashboard_api_key: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}

build:
Expand All @@ -47,4 +50,4 @@ jobs:
- name: Build the package
uses: ./.github/actions/build
with:
package-name: dom-adapters
package-name: '@editorjs/dom-adapters'
13 changes: 8 additions & 5 deletions .github/workflows/model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Run ESLint check
uses: ./.github/actions/lint
with:
package-name: model
package-name: '@editorjs/model'

tests:
runs-on: ubuntu-latest
Expand All @@ -21,7 +21,8 @@ jobs:
- name: Run unit tests
uses: ./.github/actions/unit-tests
with:
package-name: model
package-name: '@editorjs/model'
working-directory: './packages/model'

mutation-tests:
runs-on: ubuntu-latest
Expand All @@ -32,14 +33,16 @@ jobs:
if: ${{ github.event_name == 'push' }}
uses: ./.github/actions/mutation-tests-changed-files
with:
package-name: model
package-name: '@editorjs/model'
working-directory: './packages/model'
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: model
package-name: '@editorjs/model'
working-directory: './packages/model'
stryker_dashboard_api_key: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}

build:
Expand All @@ -49,4 +52,4 @@ jobs:
- name: Build the package
uses: ./.github/actions/build
with:
package-name: model
package-name: '@editorjs/model'
4 changes: 2 additions & 2 deletions .github/workflows/playground.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Run ESLint check
uses: ./.github/actions/lint
with:
package-name: document-playground
package-name: '@editorjs/document-playground'

build:
runs-on: ubuntu-latest
Expand All @@ -20,4 +20,4 @@ jobs:
- name: Build the package
uses: ./.github/actions/build
with:
package-name: document-playground
package-name: '@editorjs/document-playground'

0 comments on commit bd63fd5

Please sign in to comment.