-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (36 loc) · 1.17 KB
/
code-coverage.yml
File metadata and controls
45 lines (36 loc) · 1.17 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
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build Docker image
run: docker build -t my-project:latest .
- name: Run tests in Docker
run: docker run --rm my-project:latest
- name: Capture code coverage
run: |
docker run --rm my-project:latest lcov --directory /app/build --capture --output-file /app/build/coverage.info
docker run --rm my-project:latest lcov --remove /app/build/coverage.info '/usr/include/*' --output-file /app/build/coverage.info
docker cp $(docker create my-project:latest):/app/build/coverage.info .
- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.info
flags: unittests
- name: Report on Codecov upload
run: echo "Code coverage has been uploaded to Codecov"
- name: Fail if tests fail or coverage check fails
if: ${{ failure() }}
run: |
echo "Tests or coverage check failed"
exit 1