@@ -37,24 +37,37 @@ jobs:
3737 - name : Install dependencies
3838 run : yarn --frozen-lockfile --network-concurrency 1
3939
40+ - name : Restore base coverage cache
41+ id : cache-base
42+ uses : actions/cache@v4
43+ with :
44+ path : .coverage-base/lcov.info
45+ key : coverage-base-${{ github.event.pull_request.base.sha }}
46+
4047 - name : Checkout base branch
41- if : github.event_name == 'pull_request '
48+ if : steps.cache-base.outputs.cache-hit != 'true '
4249 uses : actions/checkout@v4
4350 with :
4451 ref : ${{ github.event.pull_request.base.sha }}
4552 path : base
4653
4754 - name : Install base dependencies
48- if : github.event_name == 'pull_request '
55+ if : steps.cache-base.outputs.cache-hit != 'true '
4956 working-directory : base
5057 run : yarn --frozen-lockfile --network-concurrency 1
5158
5259 - name : Run base coverage
53- if : github.event_name == 'pull_request '
60+ if : steps.cache-base.outputs.cache-hit != 'true '
5461 shell : bash
5562 working-directory : base
5663 run : yarn coverage
5764
65+ - name : Save base coverage to cache path
66+ if : steps.cache-base.outputs.cache-hit != 'true'
67+ run : |
68+ mkdir -p .coverage-base
69+ cp base/lcov.info .coverage-base/lcov.info
70+
5871 - name : Run coverage
5972 shell : bash
6073 run : yarn coverage
@@ -69,13 +82,11 @@ jobs:
6982 coverage-files : lcov.info
7083 github-token : ${{ github.token }}
7184 update-comment : true
72- if : github.event_name == 'pull_request'
7385
7486 - name : Compare previous coverage (against base branch)
75- if : github.event_name == 'pull_request'
7687 run : |
77- if [ -f base/lcov.info ]; then
78- old=$(lcov --summary base/lcov.info 2>/dev/null | awk '/lines\.+:/ {print $2}' | tr -d '%')
88+ if [ -f .coverage- base/lcov.info ]; then
89+ old=$(lcov --summary .coverage- base/lcov.info 2>/dev/null | awk '/lines\.+:/ {print $2}' | tr -d '%')
7990 else
8091 old=0
8192 fi
0 commit comments