forked from Cal-CS-61A-Staff/seating
-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (49 loc) · 1.83 KB
/
test.yml
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
46
47
48
49
50
51
52
name: Test
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
unit-test-with-pytest:
strategy:
matrix:
test-type: ["unit", "e2e"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Bootstrap
uses: ./.github/actions/bootstrap
# values set in GitHub repo vars/secrets are available as env vars in os
# but flask app expects them from os (flask uses os.getenv to fetech them)
# so we need to export them to os
- name: Exports all GitHub Environment Secrets
uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
- name: Exports all GitHub Environment Variables
uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(vars) }}
- name: Prepare reports directory
run: |
mkdir -p reports
touch reports/pytest-${{ matrix.test-type }}.txt
touch reports/pytest-coverage-${{ matrix.test-type }}.txt
- name: Run tests with pytest and generate reports
run: |
# make sure pipe propogates exit code to fail CI on test failure
set -o pipefail
pytest --junitxml=reports/pytest-${{ matrix.test-type }}.xml --cov-report=term-missing:skip-covered --cov=server tests/${{ matrix.test-type }}/ | tee reports/pytest-coverage-${{ matrix.test-type }}.txt
set +o pipefail
- name: Pytest coverage comment
uses: MishaKav/pytest-coverage-comment@main
with:
title: Coverage for ${{ matrix.test-type }} tests
create-new-comment: true
pytest-coverage-path: reports/pytest-coverage-${{ matrix.test-type }}.txt
junitxml-path: reports/pytest-${{ matrix.test-type }}.xml