-
Notifications
You must be signed in to change notification settings - Fork 4
118 lines (99 loc) · 3.38 KB
/
run_tests.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Run tests
on:
workflow_dispatch:
pull_request_target:
branches: [ main ]
types: [opened, synchronize, reopened, labeled]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.9, 3.11]
# Only one job at a time to avoid parallel access of test server
max-parallel: 1
if: (contains(github.event.pull_request.labels.*.name, 'safe to test') || (github.event_name == 'workflow_dispatch'))
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Update pip
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
python -m pip install --user --upgrade pip
else
pip install --upgrade pip
fi
shell: bash
- name: Install package
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
pip install --user .[test]
else
pip install .[test]
fi
shell: bash
- name: Test with pytest
env:
REDCAP_API_TOKEN: ${{ secrets.REDCAP_API_TOKEN }}
ELAB_API_TOKEN: ${{ secrets.ELAB_API_TOKEN }}
shell: bash
run: |
# change directory to test installed and not local version
ls -lh
pwd
cd ..
pytest ${{ github.event.repository.name }}
run-coverall:
runs-on: [ubuntu-latest]
needs: build
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Python 3.8
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Update pip
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
python -m pip install --user --upgrade pip
else
pip install --upgrade pip
fi
shell: bash
- name: Install package
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
pip install --user .[test]
else
pip install .[test]
fi
shell: bash
- name: Install Python test dependencies
run: pip install --user coveralls
- name: Create coverage
env:
REDCAP_API_TOKEN: ${{ secrets.REDCAP_API_TOKEN }}
ELAB_API_TOKEN: ${{ secrets.ELAB_API_TOKEN }}
shell: bash
run: |
# change directory to test installed and not local version
cd ..
coverage run -m pytest ${{ github.event.repository.name }}
- name: Submit to coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: coveralls --service=github