-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
ci(): Refactor GHA for reuse and caching #9029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
638e914
lets start from basic
asturur b468ec9
oops
asturur a27445e
test this
asturur 41714b4
yet antoher misaligned line
asturur 1955d02
yet antoher misaligned line
asturur 1b10d97
just progressing
asturur ef003bb
just progressing
asturur 2d18f1c
remove warnings
asturur 44a804f
try jest
asturur a53e72e
this will probably fail
asturur 012d63c
test this
asturur 566efec
test this other
asturur d6e6c7c
test this other
asturur 23f3449
lets keep old coverage
asturur cff5073
tidy up
asturur 1600e66
add cached install action
asturur 855a131
try composite action with cache
asturur 41440f3
try composite action with cache
asturur c660433
try composite action with cache
asturur 2c2d364
try composite action with cache
asturur fae9a11
apply a bit around
asturur d59a342
no fund no audit
asturur 923ebbc
test this
asturur a00a638
test this
asturur 3579990
no warnings
asturur bc23249
start coverage earlier
asturur 8c359d0
start coverage earlier
asturur 7b70a09
wrong check
asturur 40765a8
add build cache
asturur 6dd8158
internet runs on javascript and javascript does not work
asturur 1bbbe91
internet runs on javascript and javascript does not work
asturur 07c137b
build
asturur 5a333b0
back the action
asturur 482b628
back the action
asturur ff1c4a3
Added changelog
asturur 6a892f0
no cache
asturur 405cc4f
chaching is good
asturur 660937c
Merge branch 'master' into coverage-action
asturur 30a8e10
Merge branch 'master' into coverage-action
asturur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| name: 'Build fabric' | ||
| description: 'Build fabric and cache result per commit' | ||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Get cache build | ||
| id: build-cache | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: ./dist | ||
| key: npm-${{ github.event.pull_request.head.sha }} | ||
| - name: Build fabric.js dist folder | ||
| if: steps.build-cache.outputs.cache-hit != 'true' | ||
| run: npm run build -- -f | ||
| shell: bash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: 'Install fabric' | ||
| description: 'Install dependencies from cache between different node versions' | ||
| inputs: | ||
| node-version: | ||
| required: true | ||
| description: 'the node version' | ||
| install-system-deps: | ||
| description: 'install node-canvas deps with apt-get' | ||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Install system deps for node canvas | ||
| if: inputs.install-system-deps == 'true' | ||
| run: sudo apt-get install libgif-dev libpng-dev libpango1.0-dev libjpeg8-dev librsvg2-dev libcairo2-dev | ||
| shell: bash | ||
| - name: Use Node.js v${{ inputs.node-version }} | ||
| uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: ${{ inputs.node-version }} | ||
| - name: Get npm cache directory | ||
| id: npm-cache-dir | ||
| run: | | ||
| echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT | ||
| shell: bash | ||
| - name: Cache dependencies | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: ${{ steps.npm-cache-dir.outputs.dir }} | ||
| key: npm-${{ inputs.node-version }}-${{ hashFiles('package-lock.json') }} | ||
| restore-keys: npm-${{ inputs.node-version }} | ||
| - run: npm ci --audit false --fund false | ||
| shell: bash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,12 +9,11 @@ jobs: | |
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - name: Uglified build | ||
| uses: actions/setup-node@v1 | ||
| uses: actions/checkout@v3 | ||
| - uses: ./.github/actions/cached-install | ||
| with: | ||
| node-version: 18.x | ||
| - run: npm ci | ||
| - run: npm run build | ||
| stats: | ||
| name: Build stats | ||
|
|
@@ -72,38 +71,18 @@ jobs: | |
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Linting | ||
| uses: actions/setup-node@v1 | ||
| uses: actions/checkout@v3 | ||
| - uses: ./.github/actions/cached-install | ||
| with: | ||
| node-version: 18.x | ||
| - run: npm ci | ||
| - run: npm run lint | ||
| prettier: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Prettier check | ||
| uses: actions/setup-node@v1 | ||
| uses: actions/checkout@v3 | ||
| - uses: ./.github/actions/cached-install | ||
| with: | ||
| node-version: 18.x | ||
| - run: npm ci | ||
| - run: npm run prettier:check | ||
| coverage: | ||
| if: ${{ always() }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Code Coverage Report Updater | ||
| uses: actions/setup-node@v1 | ||
| with: | ||
| node-version: 18.x | ||
| - run: npm ci | ||
| - run: npm run build -- -f | ||
| - run: npm run test:coverage && npm run test:visual:coverage | ||
| - run: npm run coverage:report | ||
| - uses: ShaMan123/[email protected] | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| delete-old-comments: true | ||
| update-comment: true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,49 @@ on: | |
| paths-ignore: [CHANGELOG.md] | ||
|
|
||
| jobs: | ||
| prime-build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - name: Install dependencies | ||
| uses: ./.github/actions/cached-install | ||
| with: | ||
| node-version: 18.x | ||
| install-system-deps: true | ||
| - name: Build fabric.js | ||
| uses: ./.github/actions/build-fabric-cached | ||
| node-coverage: | ||
| needs: [prime-build] | ||
| runs-on: ubuntu-latest | ||
| name: Node 18.x ${{ matrix.suite }} tests | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| # For more information see: | ||
| # https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
| # supported Node.js release schedule: https://nodejs.org/en/about/releases/ | ||
| suite: [unit, visual] | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: ./.github/actions/cached-install | ||
| with: | ||
| node-version: 18.x | ||
| install-system-deps: true | ||
| - name: Build fabric.js | ||
| uses: ./.github/actions/build-fabric-cached | ||
| - name: Run ${{ matrix.suite }} tests with coverage | ||
| if: matrix.suite == 'unit' | ||
| run: npm run test:coverage | ||
| - name: Run ${{ matrix.suite }} tests with coverage | ||
| if: matrix.suite == 'visual' | ||
| run: npm run test:visual:coverage | ||
| - name: Upload test coverage | ||
| uses: actions/upload-artifact@v3 | ||
| with: | ||
| name: coverage-${{ matrix.suite }} | ||
| path: .nyc_output/*.json | ||
| browser: | ||
| needs: [prime-build] | ||
| name: ${{ matrix.target }} ${{ matrix.suite }} tests | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
|
|
@@ -18,18 +60,19 @@ jobs: | |
| suite: [unit, visual] | ||
| fail-fast: false | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Unit tests on Chrome | ||
| uses: actions/setup-node@v1 | ||
| - name: Unit tests on browser ${{ matrix.target }} | ||
| uses: actions/checkout@v3 | ||
| - uses: ./.github/actions/cached-install | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| - run: npm ci | ||
| - run: npm run build -- -f | ||
| - name: Build fabric.js | ||
| uses: ./.github/actions/build-fabric-cached | ||
| - name: Run ${{ matrix.target }} ${{ matrix.suite }} headless test | ||
| uses: GabrielBB/xvfb-action@v1 | ||
| uses: coactions/setup-xvfb@v1 | ||
| with: | ||
| run: npm run test -- -c ${{ matrix.target }} -s ${{ matrix.suite }} | ||
| node: | ||
| needs: [prime-build] | ||
| runs-on: ubuntu-latest | ||
| name: Node ${{ matrix.node-version }} ${{ matrix.suite }} tests | ||
| strategy: | ||
|
|
@@ -38,32 +81,56 @@ jobs: | |
| # For more information see: | ||
| # https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
| # supported Node.js release schedule: https://nodejs.org/en/about/releases/ | ||
| node-version: [14.x, 16.x, 18.x] | ||
| node-version: [14.x, 16.x, 20.x] | ||
| suite: [unit, visual] | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Install node-canvas | ||
| run: sudo apt-get install libgif-dev libpng-dev libpango1.0-dev libjpeg8-dev librsvg2-dev libcairo2-dev | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v1 | ||
| - uses: actions/checkout@v3 | ||
| - uses: ./.github/actions/cached-install | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| - run: npm ci | ||
| - name: Build | ||
| run: npm run build -- -f | ||
| install-system-deps: true | ||
| - name: Build fabric.js | ||
| uses: ./.github/actions/build-fabric-cached | ||
| - name: Run ${{ matrix.suite }} tests | ||
| run: npm run test -- -c node -s ${{ matrix.suite }} | ||
| jest: | ||
| name: Jest tests | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Install node-canvas | ||
| run: sudo apt-get install libgif-dev libpng-dev libpango1.0-dev libjpeg8-dev librsvg2-dev libcairo2-dev | ||
| - name: Use Node.js v18 | ||
| uses: actions/setup-node@v1 | ||
| - uses: actions/checkout@v3 | ||
| - uses: ./.github/actions/cached-install | ||
| with: | ||
| node-version: 18 | ||
| - run: npm ci | ||
| node-version: 18.x | ||
| install-system-deps: true | ||
| - name: Run Jest unit test | ||
| run: npm run test:jest | ||
| run: npm run test:jest:coverage | ||
| - name: Upload test coverage | ||
| uses: actions/upload-artifact@v3 | ||
| with: | ||
| name: coverage-jest | ||
| path: .nyc_output/*.json | ||
| coverage: | ||
| needs: [node-coverage] | ||
| name: Coverage reporting | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: ./.github/actions/cached-install | ||
| with: | ||
| node-version: 18.x | ||
| install-system-deps: false | ||
| - uses: actions/download-artifact@v3 | ||
| with: | ||
| name: coverage-unit | ||
| path: .nyc_output | ||
| - uses: actions/download-artifact@v3 | ||
| with: | ||
| name: coverage-visual | ||
| path: .nyc_output | ||
| - run: ls -l .nyc_output | ||
| - run: npm run coverage:report | ||
| - uses: ShaMan123/[email protected] | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| delete-old-comments: true | ||
| update-comment: true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed any more
I will find the comment in one of my ci prs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#8402 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even better imho. I forgot about the visual artifact prs, we should merge that too.