generated from BrianPugh/python-template
-
-
Notifications
You must be signed in to change notification settings - Fork 13
180 lines (151 loc) · 6.09 KB
/
tests.yaml
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# Regular tests
#
# Use this to ensure your tests are passing on every push and PR (skipped on
# pushes which only affect documentation).
#
# You should make sure you run jobs on at least the *oldest* and the *newest*
# versions of python that your codebase is intended to support.
name: tests
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
jobs:
test:
timeout-minutes: 45
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
BELAY_DEBUG_PROCESS_BUFFER: false
steps:
- name: Set OS Environment Variables (Windows)
if: runner.os == 'Windows'
run: |
echo 'ACTIVATE_PYTHON_VENV=.venv/scripts/activate' >> $GITHUB_ENV
echo 'BELAY_SHORT_INTEGRATION_TEST=true' >> $GITHUB_ENV
- name: Set OS Environment Variables (not Windows)
if: runner.os != 'Windows'
run: |
echo 'ACTIVATE_PYTHON_VENV=.venv/bin/activate' >> $GITHUB_ENV
- name: Check out Belay repository
uses: actions/checkout@v3
- name: Check out RP2040js repository
uses: actions/checkout@v3
with:
repository: wokwi/rp2040js
path: rp2040js
- name: Cache $HOME/.local # Significantly speeds up Poetry Install
uses: actions/cache@v3
with:
path: ~/.local
key: dotlocal-${{ runner.os }}-${{ hashFiles('.github/workflows/tests.yml') }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Cache Pi Pico MicroPython 1.17 firmware
id: cached-pi-pico-micropython-1-17-firmware
uses: actions/cache@v3
with:
path: rp2040js/micropython-v1.17.uf2
key: pi-pico-rp2040js/micropython-v1.17.uf2
- name: Download Pi Pico MicroPython 1.17 firmware
if: steps.cached-pi-pico-micropython-1-17-firmware.outputs.cache-hit != 'true'
run: |
curl https://micropython.org/resources/firmware/RPI_PICO-20210902-v1.17.uf2 -o rp2040js/micropython-v1.17.uf2
- name: Cache Pi Pico CircuitPython 7.3.3 firmware
id: cached-pi-pico-circuitpython-7-3-3-firmware
uses: actions/cache@v3
with:
path: rp2040js/circuitpython-v7.3.3.uf2
key: pi-pico-rp2040js/circuitpython-v7.3.3.uf2
- name: Download Pi Pico CircuitPython 7.3.3 firmware
if: steps.cached-pi-pico-circuitpython-7-3-3-firmware.outputs.cache-hit != 'true'
run: |
curl https://downloads.circuitpython.org/bin/raspberry_pi_pico/en_US/adafruit-circuitpython-raspberry_pi_pico-en_US-7.3.3.uf2 -o rp2040js/circuitpython-v7.3.3.uf2
- name: Cache Pi Pico CircuitPython 8.0.0 firmware
id: cached-pi-pico-circuitpython-8-0-0-firmware
uses: actions/cache@v3
with:
path: rp2040js/circuitpython-v8.0.0.uf2
key: pi-pico-rp2040js/circuitpython-v8.0.0.uf2
- name: Download Pi Pico CircuitPython 8.0.0 firmware
if: steps.cached-pi-pico-circuitpython-8-0-0-firmware.outputs.cache-hit != 'true'
run: |
curl https://downloads.circuitpython.org/bin/raspberry_pi_pico/en_US/adafruit-circuitpython-raspberry_pi_pico-en_US-8.0.0.uf2 -o rp2040js/circuitpython-v8.0.0.uf2
- name: Cache Node Modules
id: cached-npm
uses: actions/cache@v3
with:
path: rp2040js/node_modules
key: modules-${{ hashFiles('rp2040js/package-lock.json') }}
- name: Install rp2040js
if: steps.cached-npm.outputs.cache-hit != 'true'
run: |
cd rp2040js
npm install
- name: Load pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: pip-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}
restore-keys: ${{ runner.os }}-pip
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install Belay dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Install Belay
run: poetry install --no-interaction
- name: Collect Workflow Telemetry
uses: runforesight/workflow-telemetry-action@v1
with:
theme: light
comment_on_pr: false
- name: Run tests (unit only)
if: runner.os == 'Windows'
run: |
source ${{ env.ACTIVATE_PYTHON_VENV }}
python -m pytest --cov=belay --cov-report=term --cov-report=xml --cov-config=.coveragerc --junitxml=testresults.xml --network tests -s
coverage report
- name: Run tests (unit + integration)
if: runner.os != 'Windows'
run: |
source ${{ env.ACTIVATE_PYTHON_VENV }}
python -m pytest --cov=belay --cov-report=term --cov-report=xml --cov-config=.coveragerc --junitxml=testresults.xml --network tests tests/integration -s
coverage report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
env_vars: OS,PYTHON
name: Python ${{ matrix.python-version }} on ${{ runner.os }}
#----------------------------------------------
# make sure docs build
#----------------------------------------------
- name: Build HTML docs
run: |
source ${{ env.ACTIVATE_PYTHON_VENV }}
sphinx-build -b html docs/source/ docs/build/html