Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldenJaden committed Nov 23, 2023
1 parent d36b918 commit a669aae
Show file tree
Hide file tree
Showing 9 changed files with 282 additions and 30 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 '@editorjs/${{ 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 @editorjs/${{ 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: Run 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 @editorjs/${{ inputs.package-name }} test:mutations --dashboard.version main
96 changes: 96 additions & 0 deletions .github/actions/mutation-tests-changed-files/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Run mutation tests for changed files only
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: Get changed files
uses: tj-actions/[email protected]
id: changed-files
with:
files_yaml: |
src:
- 'src/**/*.ts'
- '!src/**/*.spec.ts'
- '!src/**/__mocks__/**'
separator: "','"
path: packages/${{ inputs.package-name }}

- 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)}}
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
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
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
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
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
comment_tag: mutation-tests
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
25 changes: 25 additions & 0 deletions .github/actions/unit-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Run unit test
inputs:
package-name:
description: '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:
working-directory: ./packages/${{ inputs.package-name }}
test-script: yarn workspace @editorjs/${{ inputs.package-name }} test
package-manager: yarn
prnumber: ${{ steps.findPr.outputs.number }}
50 changes: 50 additions & 0 deletions .github/workflows/dom-adapters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Dom-adapters package workflow runner
on:
push:

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

tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run unit tests
uses: ./.github/actions/unit-tests
with:
package-name: 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: 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
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: dom-adapters
52 changes: 23 additions & 29 deletions .github/workflows/model-merge.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,52 @@
name: Merge queue workflow runner for model package
on:
push:
merge_group:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- uses: ./.github/actions/setup
- name: Run ESLint check
run: yarn workspace @editorjs/model lint:ci

uses: ./.github/actions/lint
with:
package-name: model

tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- uses: ./.github/actions/setup

- name: Run unit tests
uses: ArtiomTr/jest-coverage-report-action@v2
uses: ./.github/actions/unit-tests
with:
working-directory: ./packages/model
test-script: yarn workspace @editorjs/model test
package-manager: yarn
package-name: model

mutation-tests:
runs-on: ubuntu-latest
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc

- uses: ./.github/actions/setup

- name: Run mutation tests
id: run-mutation-tests
run: yarn workspace @editorjs/model test:mutations --dashboard.version main
- name: Run mutation tests for changed files
if: ${{ github.event_name == 'push' }}
uses: ./.github/actions/mutation-tests-changed-files
with:
package-name: 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
stryker_dashboard_api_key: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- uses: ./.github/actions/setup
- name: Build the package
run: yarn workspace @editorjs/model build
uses: ./.github/actions/build
with:
package-name: model
3 changes: 2 additions & 1 deletion .github/workflows/model.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Model package workflow runner
on:
pull_request:
merge_group:

jobs:
lint:
Expand Down Expand Up @@ -102,6 +102,7 @@ jobs:
## ⏭️ No files to mutate
comment_tag: mutation-tests
#pr_number: ${{ github.event.number }}

- if: steps.changed-files.outputs.src_any_changed == 'true' && steps.run-mutation-tests.outcome == 'failure'
run: exit 1
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/playground.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Playground package workflow runner
on:
push:
merge_group:

jobs:
# lint:ci не настроен для playground
# lint:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Run ESLint check
# uses: ./.github/actions/lint
# with:
# package-name: document-playground

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build the package
uses: ./.github/actions/build
with:
package-name: document-playground

1 comment on commit a669aae

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report for ./packages/model

St.
Category Percentage Covered / Total
🟢 Statements 100% 589/589
🟢 Branches 99.27% 136/137
🟢 Functions 99.33% 149/150
🟢 Lines 100% 564/564

Test suite run success

347 tests passing in 20 suites.

Report generated by 🧪jest coverage report action from a669aae

Please sign in to comment.