Skip to content

Commit

Permalink
ci: make the upload to codecov run only if tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
bgatellier committed Jan 14, 2024
1 parent 14cfe3f commit 617db3f
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 77 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 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
67 changes: 67 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 617db3f

Please sign in to comment.