Skip to content

Commit fa1d9f4

Browse files
chore(ci): Fix codecov coverage collection within CI jobs (#9559)
* chore(ci): Fix codecov coverage collection within CI jobs * fix codecov to git paths * fix codecov flags * another try * another try * remove debug * another try * Potential fix for code scanning alert no. 416: Workflow does not contain permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * fix * fix * another fix --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 31019d8 commit fa1d9f4

File tree

3 files changed

+69
-16
lines changed

3 files changed

+69
-16
lines changed

.github/actions/codecov-fix.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../" && pwd)"
6+
7+
for path in "$repo_root"/packages/*/coverage/lcov.info; do
8+
[ -f "$path" ] || continue
9+
10+
pkg_dir="$(dirname "$path")" # packages/foo/coverage
11+
pkg_root="$(dirname "$pkg_dir")" # packages/foo
12+
tmp_path="$pkg_dir/lcov.fixed.info"
13+
14+
sed "s|SF:src/|SF:packages/$(basename "$pkg_root")/src/|g" "$path" > "$tmp_path"
15+
done

.github/workflows/push.yml

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,21 @@ jobs:
120120
run: yarn build
121121
- name: Lerna test
122122
run: yarn lerna run --concurrency 1 --stream --no-prefix unit
123-
- name: Upload coverage reports to Codecov
124-
uses: codecov/codecov-action@v5
123+
- name: Fix lcov paths
125124
if: (matrix.node-version == '22.x' && matrix.transpile-worker-threads == true)
125+
run: |
126+
./.github/actions/codecov-fix.sh
127+
- name: Combine all fixed LCOV files
128+
if: (matrix.node-version == '22.x' && matrix.transpile-worker-threads == true)
129+
run: |
130+
echo "" > ./combined-unit.lcov
131+
find ./packages -type f -name lcov.fixed.info -exec cat {} + >> ./combined-unit.lcov || true
132+
- name: Upload coverage artifact
133+
if: (matrix.node-version == '22.x' && matrix.transpile-worker-threads == true)
134+
uses: actions/upload-artifact@v4
126135
with:
127-
token: ${{ secrets.CODECOV_TOKEN }}
128-
files: ./packages/*/coverage/*
129-
verbose: true
130-
flags: cube-backend
131-
fail_ci_if_error: false
136+
name: coverage-unit
137+
path: ./combined-unit.lcov
132138

133139
lint:
134140
runs-on: ubuntu-24.04
@@ -496,15 +502,18 @@ jobs:
496502
# Snowflake
497503
DRIVERS_TESTS_SNOWFLAKE_CUBEJS_DB_USER: ${{ secrets.DRIVERS_TESTS_CUBEJS_DB_SNOWFLAKE_USER }}
498504
DRIVERS_TESTS_SNOWFLAKE_CUBEJS_DB_PASS: ${{ secrets.DRIVERS_TESTS_CUBEJS_DB_SNOWFLAKE_PASS }}
499-
- name: Upload coverage reports to Codecov
500-
uses: codecov/codecov-action@v5
501-
if: (matrix.node-version == '22.x')
502-
with:
503-
token: ${{ secrets.CODECOV_TOKEN }}
504-
files: ./packages/*/coverage/*
505-
verbose: true
506-
flags: cube-backend
507-
fail_ci_if_error: false
505+
- name: Fix lcov paths
506+
run: |
507+
./.github/actions/codecov-fix.sh
508+
- name: Combine all fixed LCOV files
509+
run: |
510+
echo "" > ./combined-integration-${{ matrix.db }}.lcov
511+
find ./packages -type f -name lcov.fixed.info -exec cat {} + >> ./combined-integration-${{ matrix.db }}.lcov || true
512+
- name: Upload coverage artifact
513+
uses: actions/upload-artifact@v4
514+
with:
515+
name: coverage-integration-${{ matrix.db }}
516+
path: ./combined-integration-${{ matrix.db }}.lcov
508517

509518
integration-smoke:
510519
needs: [latest-tag-sha, build-cubestore, build-native-linux]
@@ -787,3 +796,29 @@ jobs:
787796
with:
788797
name: cypress-screenshots-docker-dev-${{ matrix.name }}
789798
path: packages/cubejs-testing/cypress/screenshots
799+
800+
upload-coverage:
801+
name: Upload merged coverage to Codecov
802+
needs: [unit, integration]
803+
runs-on: ubuntu-latest
804+
permissions:
805+
contents: read
806+
actions: read
807+
steps:
808+
- name: Install Codecov CLI
809+
run: |
810+
curl -Os https://uploader.codecov.io/latest/linux/codecov
811+
chmod +x codecov
812+
- name: Download all coverage artifacts
813+
uses: actions/download-artifact@v4
814+
with:
815+
path: all-coverage
816+
- name: Merge all coverage files
817+
run: |
818+
find all-coverage -name '*.lcov' -exec cat {} + > merged-coverage.info
819+
- name: Upload merged coverage to Codecov
820+
run: |
821+
./codecov --token "${{ secrets.CODECOV_TOKEN }}" \
822+
--file ./merged-coverage.info \
823+
--flags cube-backend \
824+
--name "cube backend coverage"

codecov.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ coverage:
1010
patch:
1111
default:
1212
informational: true
13+
14+
github_checks:
15+
annotations: false

0 commit comments

Comments
 (0)