Skip to content

Commit

Permalink
ci: Combine coverage from all shards (#22849)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov authored Jun 17, 2023
1 parent c826ae8 commit 086b9a7
Show file tree
Hide file tree
Showing 4 changed files with 466 additions and 175 deletions.
63 changes: 46 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ env:
tools/
package.json
yarn.lock
codecov.yml
jobs:
setup:
Expand All @@ -49,7 +50,6 @@ jobs:
os-matrix-is-full: ${{ steps.os-matrix-is-full.outputs.os-matrix-is-full }}
os-matrix-prefetch: ${{ steps.os-matrix-prefetch.outputs.matrix }}
test-shard-matrix: ${{ steps.schedule-test-shards.outputs.test-shard-matrix }}
test-coverage-files: ${{ steps.schedule-test-shards.outputs.test-coverage-files }}
test-matrix-empty: ${{ steps.schedule-test-shards.outputs.test-matrix-empty }}

steps:
Expand Down Expand Up @@ -312,45 +312,65 @@ jobs:
- name: Move coverage files
if: (success() || failure()) && github.event.pull_request.draft != true && matrix.coverage
run: |
mkdir ./coverage-reports
mkdir -p ./coverage/lcov
mkdir -p ./coverage/json
for shard in ${{ matrix.shards }};
do
mv ./coverage/shard/$shard/lcov.info ./coverage-reports/$shard.txt
mv ./coverage/shard/$shard/lcov.info ./coverage/lcov/$shard.lcov
mv ./coverage/shard/$shard/coverage-final.json ./coverage/json/$shard.json
done
- name: Save coverage artifacts
if: (success() || failure()) && github.event.pull_request.draft != true && matrix.coverage
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: coverage-reports
path: ./coverage-reports/*.txt
name: coverage
path: |
./coverage/lcov
./coverage/json
codecov:
needs: [setup, test]
coverage:
needs: [test]
runs-on: ubuntu-latest
timeout-minutes: 3
if: (success() || failure()) && github.event.pull_request.draft != true
steps:
- name: Checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
sparse-checkout: codecov.yml
fetch-depth: 2 # We think codecov used to resolve coverage changes using previous commit, but maybe not
sparse-checkout: ${{ env.SPARSE_CHECKOUT }}

- name: Download coverage reports
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: coverage-reports
path: ./coverage-reports
name: coverage
path: coverage

- name: Codecov
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
with:
files: '${{ needs.setup.outputs.test-coverage-files }}'
directory: coverage/lcov

- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
node-version: ${{ env.NODE_VERSION }}
os: ${{ runner.os }}

- name: Merge coverage reports
run: yarn -s nyc merge ./coverage/json ./coverage/nyc/coverage.json

# This allows not to specify particular jobs in matrix as required
- name: Check coverage threshold
run: |
yarn -s nyc check-coverage -t ./coverage/nyc \
--branches 98 \
--functions 100 \
--lines 100 \
--statements 100
# Catch-all required check for test matrix and coverage
test-success:
needs: [setup, test]
needs: [setup, test, coverage]
runs-on: ubuntu-latest
timeout-minutes: 1
if: always()
Expand All @@ -364,6 +384,15 @@ jobs:
)
run: exit 1
- if: |
needs.coverage.result == 'failure' ||
needs.coverage.result == 'cancelled' ||
(needs.coverage.result == 'skipped' &&
!(github.event.pull_request.draft &&
needs.setup.outputs.test-matrix-empty == 'true')
)
run: exit 1
build:
needs: setup
runs-on: ubuntu-latest
Expand Down Expand Up @@ -392,7 +421,7 @@ jobs:
path: renovate-v0.0.0-semantic-release.tgz

build-docs:
needs: [setup, lint-docs]
needs: [lint-docs]
runs-on: ubuntu-latest
timeout-minutes: 5
if: github.event.pull_request.draft != true
Expand All @@ -416,7 +445,7 @@ jobs:
path: tmp/docs/

test-e2e:
needs: [setup, build]
needs: [build]
runs-on: 'ubuntu-latest'
timeout-minutes: 7

Expand Down Expand Up @@ -452,7 +481,7 @@ jobs:
- test-e2e
- test-success
- build-docs
- codecov
- coverage

if: github.repository == 'renovatebot/renovate' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
Expand Down
Loading

0 comments on commit 086b9a7

Please sign in to comment.