Skip to content
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

ci: upload code coverage reports to codecov only if tests pass #204

Merged
merged 6 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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