forked from redhat-developer/rhdh-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (91 loc) · 3.47 KB
/
Copy pathcoverage-baseline.yml
File metadata and controls
106 lines (91 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Codecov baseline coverage for redhat-developer/rhdh-plugins
#
# Feature umbrella: RHDHPLAN-851
# Epic: RHIDP-11862 — Unit Test Coverage for RHDH Plugins Repository
#
# Runs the test suite for every workspace on push to main and uploads
# coverage to Codecov. This establishes the per-workspace baselines that
# Codecov uses to calculate coverage deltas in PRs (via carryforward).
#
# PR-level coverage is handled by the upload step in ci.yml; this
# workflow only covers push events so the two never duplicate work.
name: Coverage Baseline
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
list-workspaces:
name: Discover workspaces
runs-on: ubuntu-latest
outputs:
workspaces: ${{ steps.list.outputs.workspaces }}
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 1
persist-credentials: false
- name: List all workspaces
id: list
run: |
WORKSPACES=$(ls -d workspaces/*/ 2>/dev/null | sed 's|workspaces/||;s|/$||' | grep -v '^\.' | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "workspaces=$WORKSPACES" >> "$GITHUB_OUTPUT"
coverage:
name: Coverage — ${{ matrix.workspace }}
runs-on: ubuntu-latest
needs: list-workspaces
strategy:
matrix:
workspace: ${{ fromJSON(needs.list-workspaces.outputs.workspaces) }}
fail-fast: false
defaults:
run:
working-directory: ./workspaces/${{ matrix.workspace }}
env:
CI: true
NODE_OPTIONS: --max-old-space-size=8192
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 1
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 24
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: yarn install --immutable
- name: Install jest-junit reporter
run: |
npm install jest-junit@17.0.0 --ignore-scripts --prefix ${{ runner.temp }}/jest-junit
mkdir -p ${{ runner.temp }}/test-results/${{ matrix.workspace }}
- name: Run tests with coverage
id: tests
env:
JEST_JUNIT_OUTPUT_DIR: ${{ runner.temp }}/test-results/${{ matrix.workspace }}
JEST_JUNIT_CLASSNAME: '{filepath}'
JEST_JUNIT_UNIQUE_OUTPUT_NAME: 'true'
run: yarn test:all --maxWorkers=3 --reporters=default --reporters=${{ runner.temp }}/jest-junit/node_modules/jest-junit
- name: Upload coverage to Codecov
if: ${{ !cancelled() && steps.tests.outcome != 'skipped' }}
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
with:
flags: ${{ matrix.workspace }}
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
- name: Upload test results to Codecov
if: ${{ !cancelled() && steps.tests.outcome != 'skipped' }}
uses: codecov/test-results-action@0fa95f0e1eeaafde2c782583b36b28ad0d8c77d3 # v1.2.1
with:
flags: ${{ matrix.workspace }}
token: ${{ secrets.CODECOV_TOKEN }}
directory: ${{ runner.temp }}/test-results/${{ matrix.workspace }}
fail_ci_if_error: false