Skip to content

Commit f4ad326

Browse files
kukkok3stevenj
andauthored
feat: adds code coverage with coveralls (#520)
* test * test * wip * fix: artifact name * adds: coveralls * fix bash * debug * fix file path * adds coverall action * adds debug * change ci * adds allow empty flag * fix: update ci version * feats: adds coverage for backend pytest tests * test * fix spelling * rename coverage file * fix: enable earthfile * test * test run * fix path * chore: test run * chore: test run * fix: action param * test * test * test * adds debug * adds base path * fix base path * test * test * test * test * test * test * feat: adds sed * chore: clean up * test * fix melos * feat: adds parallel coverage * feat: adds flutter coverage * fix: coverage ext path * fix coverage ext * fix: coverage path * fix coverage path * feat: adds sed for flutter coverage * test * fix coverage path --------- Co-authored-by: Steven Johnson <[email protected]>
1 parent 2b8e7d7 commit f4ad326

File tree

11 files changed

+481
-397
lines changed

11 files changed

+481
-397
lines changed

.config/dictionaries/project.dic

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ afinet
66
androidx
77
anypolicy
88
appspot
9-
Arissara
109
Arbritrary
1110
ARGB
11+
Arissara
1212
asmjs
1313
asyncio
1414
asyncpg
@@ -25,11 +25,12 @@ bluefireteam
2525
BROTLI
2626
canvaskit
2727
cardano
28+
carryforward
2829
Catalyst
2930
CBOR
3031
cborg
31-
CEST
3232
cdylib
33+
CEST
3334
cfbundle
3435
Chotivichit
3536
chromedriver
@@ -40,6 +41,7 @@ COCOAPODS
4041
codegen
4142
codepoints
4243
coti
44+
coverallsapp
4345
cryptoxide
4446
Cunego
4547
Cupertino
@@ -239,4 +241,4 @@ xcodeproj
239241
xctest
240242
xctestrun
241243
xcworkspace
242-
yoroi
244+
yoroi

.github/workflows/generate-allure-report.yml

+77-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ env:
2020
EARTHLY_TARGET: docker
2121
ECR_REGISTRY: 332405224602.dkr.ecr.eu-central-1.amazonaws.com
2222
ALLURE_REPORT_PATH: allure-report
23+
COVERAGE_REPORT_PATH: coverage-report
2324
REPORT_EXT: .junit-report.xml
25+
COVERAGE_EXT: .info
2426

2527
jobs:
2628
generate-test-reports:
@@ -71,8 +73,8 @@ jobs:
7173
target_flags:
7274
runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
7375
artifact: "false"
74-
75-
- name: Get backend python test report
76+
77+
- name: Get python api test report
7678
uses: input-output-hk/catalyst-ci/actions/run@master
7779
if: always()
7880
continue-on-error: true
@@ -88,10 +90,20 @@ jobs:
8890
uses: actions/upload-artifact@v4
8991
if: always()
9092
with:
93+
name: test-reports
9194
path: '**/*${{ env.REPORT_EXT }}'
9295
if-no-files-found: error
9396
retention-days: 1
9497

98+
- name: Collect and upload test coverage
99+
uses: actions/upload-artifact@v4
100+
if: always()
101+
with:
102+
name: coverage-reports
103+
path: '**/*${{ env.COVERAGE_EXT }}'
104+
if-no-files-found: error
105+
retention-days: 1
106+
95107
generate-allure-report:
96108
name: Generate allure report
97109
runs-on: ubuntu-latest
@@ -100,6 +112,8 @@ jobs:
100112
- uses: actions/checkout@v4
101113

102114
- uses: actions/download-artifact@v4
115+
with:
116+
name: test-reports
103117

104118
- name: Setup Allure report
105119
run: |
@@ -136,4 +150,64 @@ jobs:
136150
message: |
137151
${{ steps.allure.outputs.test_result_icon }} [Test Report](${{ steps.allure.outputs.report_url }}) | ${\color{lightgreen}Pass: ${{ steps.allure.outputs.test_result_passed }}/${{ steps.allure.outputs.test_result_total }}}$ | ${\color{red}Fail: ${{ steps.allure.outputs.test_result_failed }}/${{ steps.allure.outputs.test_result_total }}}$ |
138152
comment_tag: allure_report
139-
mode: upsert
153+
mode: upsert
154+
155+
generate-coverage-report:
156+
name: Generate coverage report
157+
runs-on: ubuntu-latest
158+
needs: [generate-test-reports]
159+
steps:
160+
- uses: actions/checkout@v4
161+
162+
- uses: actions/download-artifact@v4
163+
with:
164+
name: coverage-reports
165+
166+
- name: Collect coverage report
167+
run: |
168+
mkdir -p ${{ env.COVERAGE_REPORT_PATH }}
169+
shopt -s globstar
170+
cp **/*${{ env.COVERAGE_EXT }} ${{ env.COVERAGE_REPORT_PATH }}
171+
ls ${{ env.COVERAGE_REPORT_PATH }}
172+
173+
- name: Normalize coverage report paths
174+
run: |
175+
sed -i -e 's/SF:\/root/SF:catalyst-gateway/g' ${{ env.COVERAGE_REPORT_PATH }}/cat-gateway.coverage.info
176+
sed -i -e 's/SF:lib/SF:catalyst_voices\/lib/g' ${{ env.COVERAGE_REPORT_PATH }}/lcov.info
177+
cat ${{ env.COVERAGE_REPORT_PATH }}/cat-gateway.coverage.info
178+
179+
- name: Coveralls
180+
env:
181+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
182+
uses: coverallsapp/github-action@v2
183+
with:
184+
path-to-lcov: "${{ env.COVERAGE_REPORT_PATH }}/cat-gateway.coverage.info"
185+
allow-empty: true
186+
debug: true
187+
flag-name: rust-unit-test
188+
base-path: "/home/runner/work/catalyst-voices/catalyst-voices/"
189+
parallel: true
190+
191+
- name: Coveralls
192+
env:
193+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
194+
uses: coverallsapp/github-action@v2
195+
with:
196+
path-to-lcov: "${{ env.COVERAGE_REPORT_PATH }}/lcov.info"
197+
allow-empty: true
198+
debug: true
199+
flag-name: flutter-test
200+
base-path: "/home/runner/work/catalyst-voices/catalyst-voices/"
201+
parallel: true
202+
203+
upload-coverage-report:
204+
name: Upload coverage report
205+
needs: [generate-coverage-report]
206+
if: ${{ always() }}
207+
runs-on: ubuntu-latest
208+
steps:
209+
- name: Coveralls Finished
210+
uses: coverallsapp/github-action@v2
211+
with:
212+
parallel-finished: true
213+
carryforward: "rust-unit-test,flutter-test"

catalyst-gateway/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ target/
1111
*.pdb
1212

1313
# Build artifacts
14-
cat-gateway.coverage-report.info
14+
cat-gateway.coverage.info
1515
cat-gateway.junit-report.xml
1616
cat-gateway-api.*

catalyst-gateway/Earthfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ build:
4040
--args2="--cov_report=$HOME/coverage-report.info" \
4141
--output="release/cat-gateway" \
4242
--junit="cat-gateway.junit-report.xml" \
43-
--coverage="cat-gateway.coverage-report.info" \
43+
--coverage="cat-gateway.coverage.info" \
4444
--docs="true"
4545

4646
# Generate the OpenAPI doc from the cat-gateway executable itself.

catalyst-gateway/tests/api_tests/Earthfile

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@ builder:
1313
# Disabled in CI, to enable rename it to `test`.
1414
api-test:
1515
FROM +builder
16+
RUN apk update && apk add iptables-legacy # workaround for https://github.com/earthly/earthly/issues/3784
1617

1718
COPY ./docker-compose.yml .
1819

1920
WITH DOCKER \
2021
--compose docker-compose.yml \
2122
--load event-db:latest=(../../event-db+build) \
22-
--load cat-gateway:latest=(../../+package-cat-gateway-with-preprod) \
23+
--load cat-gateway:latest=(../../+package-cat-gateway-with-preprod-snapshot) \
2324
--service cat-gateway \
2425
--allow-privileged
25-
RUN poetry run pytest -s --junitxml=junit-report.xml
26+
RUN poetry run pytest -s --junitxml=junit-report.xml --cov=api_tests --cov-report lcov
2627
END
2728
WAIT
28-
SAVE ARTIFACT junit-report.xml AS LOCAL backendpython.junit-report.xml
29+
SAVE ARTIFACT junit-report.xml AS LOCAL api-tests.junit-report.xml
30+
SAVE ARTIFACT coverage.lcov AS LOCAL api-tests.coverage.info
31+
2932
END

0 commit comments

Comments
 (0)