From 617db3f6559549f5831b9860d38c7bcf9d9a90d6 Mon Sep 17 00:00:00 2001 From: Bastien Gatellier Date: Sun, 14 Jan 2024 16:58:49 +0100 Subject: [PATCH 1/6] ci: make the upload to codecov run only if tests pass --- .github/workflows/coverage.yaml | 50 ------------------ .github/workflows/{pr.yaml => lint.yaml} | 49 ++++++++--------- .github/workflows/test.yaml | 67 ++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 77 deletions(-) delete mode 100644 .github/workflows/coverage.yaml rename .github/workflows/{pr.yaml => lint.yaml} (55%) create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml deleted file mode 100644 index ee2b9ec9..00000000 --- a/.github/workflows/coverage.yaml +++ /dev/null @@ -1,50 +0,0 @@ -# Generate code coverage reports and uploads them to Codecov -name: ๐Ÿ› Code coverage - -on: - push: - branches: ["main"] - pull_request: - types: [opened, synchronize, reopened] - -jobs: - generate: - name: Generate coverage reports - runs-on: ubuntu-latest - timeout-minutes: 5 - defaults: - run: - shell: bash - outputs: - reports_path: ${{ steps.list_reports_path.outputs.reports_path }} - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-node@v3 - with: - node-version-file: .nvmrc - - - name: Install - 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 --coverage - - - name: List module names for which a coverage report has been generated - id: list_reports_path - # directories_names is an array of strings formatted like that: ./modules/common/coverage. - # syntax checked with https://www.shellcheck.net/ - # https://yaml-multiline.info/ - run: | - reports_path=$(find ./modules -name clover.xml | tr '\n' ',') - echo "reports_path=$reports_path" >> "$GITHUB_OUTPUT" - - - name: โค’ Upload coverage reports - uses: codecov/codecov-action@v3 - with: - fail_ci_if_error: true - files: ${{ steps.list_reports_path.outputs.reports_path }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/lint.yaml similarity index 55% rename from .github/workflows/pr.yaml rename to .github/workflows/lint.yaml index 144b1d12..88208485 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/lint.yaml @@ -1,12 +1,12 @@ -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: @@ -14,50 +14,45 @@ jobs: 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 application 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 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000..92390578 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,67 @@ +name: ๐Ÿ› Test + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + test: + name: Test + 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 + run: node common/scripts/install-run-rush.js install + + - name: Build + run: node common/scripts/install-run-rush.js rebuild + + - name: Test + if: ${{ matrix.node != 18 }} + run: node common/scripts/install-run-rush.js test + + - name: Test and generate coverage reports + if: ${{ matrix.node == 18 }} + run: node common/scripts/install-run-rush.js test --coverage + + - name: Archive code coverage reports + if: ${{ matrix.node == 18 }} + uses: actions/upload-artifact@v4 + with: + name: code-coverage-reports + path: modules/**/clover.xml + retention-days: 1 + + coverage: + name: Upload code coverage reports to Codecov + runs-on: ubuntu-latest + needs: test + 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 From 23d6fc8a74532d4c2b1b1a6d26d1dc38d6b2c2c3 Mon Sep 17 00:00:00 2001 From: Bastien Gatellier Date: Sun, 14 Jan 2024 17:09:13 +0100 Subject: [PATCH 2/6] ci: fix type --- .github/workflows/test.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 92390578..e3db2c6a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -25,22 +25,22 @@ jobs: with: node-version: ${{ matrix.node_version }} - - 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: Test - if: ${{ matrix.node != 18 }} + if: ${{ matrix.node != "18" }} run: node common/scripts/install-run-rush.js test - name: Test and generate coverage reports - if: ${{ matrix.node == 18 }} + if: ${{ matrix.node == "18" }} run: node common/scripts/install-run-rush.js test --coverage - name: Archive code coverage reports - if: ${{ matrix.node == 18 }} + if: ${{ matrix.node == "18" }} uses: actions/upload-artifact@v4 with: name: code-coverage-reports From 3d45d74e406aa76defcd2610c8fb8e9558e8e3eb Mon Sep 17 00:00:00 2001 From: Bastien Gatellier Date: Sun, 14 Jan 2024 17:09:42 +0100 Subject: [PATCH 3/6] refactor: standardize the name of similar steps --- .github/workflows/lint.yaml | 2 +- .github/workflows/publish.yaml | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 88208485..112dc623 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -25,7 +25,7 @@ jobs: - name: Install dependencies run: node common/scripts/install-run-rush.js install - - name: Build application + - name: Build projects run: node common/scripts/install-run-rush.js rebuild - name: Lint code diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index e2220d8c..1cd45d73 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -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 @@ -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 @@ -100,10 +104,10 @@ jobs: name: Heart email: heart@fabernovel.com - - 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 From 27c1c8aeba0dcf631f3bc6b417e1ed51c88b9a61 Mon Sep 17 00:00:00 2001 From: Bastien Gatellier Date: Sun, 14 Jan 2024 17:13:57 +0100 Subject: [PATCH 4/6] ci: fix quotes --- .github/workflows/test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e3db2c6a..50b7a063 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -32,15 +32,15 @@ jobs: run: node common/scripts/install-run-rush.js rebuild - name: Test - if: ${{ matrix.node != "18" }} + if: ${{ matrix.node != '18' }} run: node common/scripts/install-run-rush.js test - name: Test and generate coverage reports - if: ${{ matrix.node == "18" }} + if: ${{ matrix.node == '18' }} run: node common/scripts/install-run-rush.js test --coverage - name: Archive code coverage reports - if: ${{ matrix.node == "18" }} + if: ${{ matrix.node == '18' }} uses: actions/upload-artifact@v4 with: name: code-coverage-reports From 0189a5229b5f91c6fd91dbb86fccdc1781b020c2 Mon Sep 17 00:00:00 2001 From: Bastien Gatellier Date: Sun, 14 Jan 2024 17:17:36 +0100 Subject: [PATCH 5/6] ci: fix matrix variable name --- .github/workflows/test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 50b7a063..dc3f9b62 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -32,15 +32,15 @@ jobs: run: node common/scripts/install-run-rush.js rebuild - name: Test - if: ${{ matrix.node != '18' }} + if: ${{ matrix.node_version != '18' }} run: node common/scripts/install-run-rush.js test - name: Test and generate coverage reports - if: ${{ matrix.node == '18' }} + if: ${{ matrix.node_version == '18' }} run: node common/scripts/install-run-rush.js test --coverage - name: Archive code coverage reports - if: ${{ matrix.node == '18' }} + if: ${{ matrix.node_version == '18' }} uses: actions/upload-artifact@v4 with: name: code-coverage-reports From aaaf8585cf0a51146ed5653cb1fc485571c8e031 Mon Sep 17 00:00:00 2001 From: Bastien Gatellier Date: Sun, 14 Jan 2024 17:42:21 +0100 Subject: [PATCH 6/6] ci: put icons on job names instead of workflow names to improve readability --- .github/workflows/lint.yaml | 6 +++--- .github/workflows/publish.yaml | 6 +++--- .github/workflows/test.yaml | 13 +++++++------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 112dc623..c22c1a26 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,4 +1,4 @@ -name: ๐Ÿงน Lint & changelog +name: Lint & changelog on: pull_request: @@ -6,7 +6,7 @@ on: jobs: lint: - name: Lint code + name: ๐Ÿงน Lint code runs-on: ubuntu-latest timeout-minutes: 5 defaults: @@ -33,7 +33,7 @@ jobs: run: node common/scripts/install-run-rush.js lint --verbose changelog: - name: Checks for changelogs + name: ๐Ÿ“ Checks for changelogs runs-on: ubuntu-latest timeout-minutes: 5 defaults: diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 1cd45d73..7f8ee4f7 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -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: @@ -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: @@ -77,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: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index dc3f9b62..fe719fa7 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,4 +1,4 @@ -name: ๐Ÿ› Test +name: Tests on: pull_request: @@ -6,7 +6,7 @@ on: jobs: test: - name: Test + name: ๐Ÿ› Run tests runs-on: ubuntu-latest timeout-minutes: 5 defaults: @@ -31,11 +31,11 @@ jobs: - name: Build projects run: node common/scripts/install-run-rush.js rebuild - - name: Test + - name: Run tests if: ${{ matrix.node_version != '18' }} run: node common/scripts/install-run-rush.js test - - name: Test and generate coverage reports + - name: Run tests and generate coverage reports if: ${{ matrix.node_version == '18' }} run: node common/scripts/install-run-rush.js test --coverage @@ -48,9 +48,10 @@ jobs: retention-days: 1 coverage: - name: Upload code coverage reports to Codecov - runs-on: ubuntu-latest needs: test + name: โฌ†๏ธ Upload code coverage reports to Codecov + runs-on: ubuntu-latest + timeout-minutes: 5 defaults: run: shell: bash