-
Notifications
You must be signed in to change notification settings - Fork 69
75 lines (63 loc) · 2.38 KB
/
push_pr.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Run code tests on push and pull requests
on:
pull_request:
push:
branches:
- master
workflow_dispatch:
permissions:
contents: read
pull-requests: write
jobs:
tests:
name: Code tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
include-sigpy: [true, false]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install PyPulseq and dependencies
run: |
pip install --upgrade --upgrade-strategy eager .[test]
if [ ${{ matrix.include-sigpy }} == "true" ]; then
pip install sigpy
fi
- name: Install PyTest GitHub Annotation Plugin
run: pip install pytest-github-actions-annotate-failures
- name: Run PyTest and Generate Coverage Report
run: |
if [ ${{ matrix.include-sigpy }} == "true" ]; then
(set -o pipefail && pytest --junitxml=pytest.xml \
--cov-report=term-missing:skip-covered --cov=pypulseq | tee pytest-coverage.txt)
else
(set -o pipefail && pytest -m "not sigpy" --junitxml=pytest.xml \
--cov-report=term-missing:skip-covered --cov=pypulseq | tee pytest-coverage.txt)
fi
shell: bash
- name: Post PyTest Coverage Comment
id: coverageComment
uses: MishaKav/[email protected]
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
- name: Set Pipeline Status Based on Test Results
if: steps.coverageComment.outputs.errors != 0 || steps.coverageComment.outputs.failures != 0
uses: actions/github-script@v7
with:
script: |
core.setFailed("PyTest workflow failed with ${{ steps.coverageComment.outputs.errors }} errors and ${{ steps.coverageComment.outputs.failures }} failures.")
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
# Cancel in-progress runs when a new workflow with the same group name is triggered
cancel-in-progress: true