Skip to content

Commit

Permalink
ci: upload code coverage reports to codecov only if tests pass (#204)
Browse files Browse the repository at this point in the history
* ci: make the upload to codecov run only if tests pass
* refactor: standardize the name of similar steps
* ci: put icons on job names instead of workflow names to improve readability
  • Loading branch information
bgatellier authored Jan 14, 2024
1 parent 14cfe3f commit 040716c
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 86 deletions.
50 changes: 0 additions & 50 deletions .github/workflows/coverage.yaml

This file was deleted.

49 changes: 22 additions & 27 deletions .github/workflows/pr.yaml → .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,63 +1,58 @@
name: 🧹 Pull request
name: Lint & changelog

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
syntax_changelog:
name: Syntax & changelog
lint:
name: 🧹 Lint code
runs-on: ubuntu-latest
timeout-minutes: 5
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Checkout code
uses: actions/checkout@v4

- uses: actions/setup-node@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Install
- name: Install dependencies
run: node common/scripts/install-run-rush.js install

- name: 🏗 Build
- name: Build projects
run: node common/scripts/install-run-rush.js rebuild

- name: 📝 Verify missing changelogs
run: node common/scripts/install-run-rush.js change --target-branch origin/$GITHUB_BASE_REF --verify -v

- name: 💅 Lint
- name: Lint code
# --verbose allows to display warnings from ESLint
run: node common/scripts/install-run-rush.js lint --verbose

test:
name: Test
changelog:
name: 📝 Checks for changelogs
runs-on: ubuntu-latest
timeout-minutes: 5
defaults:
run:
shell: bash
strategy:
matrix:
node_version: [18, 19, 20, 21]

steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2

- uses: actions/setup-node@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
node-version-file: .nvmrc

- name: Install
- name: Install dependencies
run: node common/scripts/install-run-rush.js install

- name: 🏗 Build
run: node common/scripts/install-run-rush.js rebuild

- name: 🐛 Test
run: node common/scripts/install-run-rush.js test
- name: Checks for changelogs
run: node common/scripts/install-run-rush.js change --target-branch origin/$GITHUB_BASE_REF --verify -v
22 changes: 13 additions & 9 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# then merged it in the main branch once the publication has been done.
#

name: 🚀 Publish packages
name: Publish packages

on:
workflow_dispatch:
Expand Down Expand Up @@ -43,7 +43,7 @@ env:
jobs:
simulate:
if: inputs.PUBLICATION_MODE == 'simulate'
name: Simulate a publication to npmjs.org with the version policy ${{ inputs.VERSION_POLICY }}
name: 🚀 Simulate a publication to npmjs.org with the version policy ${{ inputs.VERSION_POLICY }}
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -52,12 +52,14 @@ jobs:
contents: write

steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
ref: ${{ env.SOURCE_BRANCH }}

- uses: actions/setup-node@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

Expand All @@ -75,7 +77,7 @@ jobs:

publish:
if: inputs.PUBLICATION_MODE == 'publish'
name: Publish to npmjs.org with the version policy ${{ inputs.VERSION_POLICY }}
name: 🚀 Publish to npmjs.org with the version policy ${{ inputs.VERSION_POLICY }}
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -85,12 +87,14 @@ jobs:
pull-requests: write

steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
ref: ${{ env.SOURCE_BRANCH }}

- uses: actions/setup-node@v3
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

Expand All @@ -100,10 +104,10 @@ jobs:
name: Heart
email: [email protected]

- name: Install
- name: Install dependencies
run: node common/scripts/install-run-rush.js install

- name: 🏗 Build
- name: Build projects
run: node common/scripts/install-run-rush.js rebuild

- name: Create origin/${{ env.TARGET_BRANCH }} branch
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Tests

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
test:
name: 🐛 Run tests
runs-on: ubuntu-latest
timeout-minutes: 5
defaults:
run:
shell: bash
strategy:
matrix:
node_version: [18, 19, 20, 21]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}

- name: Install dependencies
run: node common/scripts/install-run-rush.js install

- name: Build projects
run: node common/scripts/install-run-rush.js rebuild

- name: Run tests
if: ${{ matrix.node_version != '18' }}
run: node common/scripts/install-run-rush.js test

- name: Run tests and generate coverage reports
if: ${{ matrix.node_version == '18' }}
run: node common/scripts/install-run-rush.js test --coverage

- name: Archive code coverage reports
if: ${{ matrix.node_version == '18' }}
uses: actions/upload-artifact@v4
with:
name: code-coverage-reports
path: modules/**/clover.xml
retention-days: 1

coverage:
needs: test
name: ⬆️ Upload code coverage reports to Codecov
runs-on: ubuntu-latest
timeout-minutes: 5
defaults:
run:
shell: bash

steps:
- name: Download reports from previous job
uses: actions/download-artifact@v4
with:
name: code-coverage-reports

- name: Upload reports to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true

0 comments on commit 040716c

Please sign in to comment.