generated from BrianPugh/python-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
122 lines (103 loc) · 3.84 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
# 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]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
POETRY_HOME: "~/poetry"
steps:
- name: Set OS Environment Variables (Windows)
if: runner.os == 'Windows'
run: |
echo 'ACTIVATE_PYTHON_VENV=.venv/scripts/activate' >> $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 repository
uses: actions/checkout@v4
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache Poetry Install
uses: actions/cache@v4
id: cached-poetry
with:
path: ${{ env.POETRY_HOME }}
key: poetry-cache-${{ runner.os }}-${{ env.PYTHON }}-${{ hashFiles('.github/workflows/tests.yaml') }}
- name: Install poetry
uses: snok/install-poetry@v1
if: steps.cached-poetry.outputs.cache-hit != 'true'
- name: Add Poetry to PATH # Needs to be separate from install-poetry because cache.
run: |
echo "$POETRY_HOME/bin" >> $GITHUB_PATH
- name: Configure Poetry # Needs to be separate from install-poetry because cache.
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry config installer.parallel ${{ runner.os != 'Windows' }} # Currently there seems to be some race-condition in windows
- name: Cache venv
uses: actions/cache@v4
id: cached-venv
with:
path: .venv/
key: venv-cache-${{ runner.os }}-${{ env.PYTHON }}-${{ hashFiles('.github/workflows/tests.yaml') }}
- name: Install MicroPython
uses: BrianPugh/install-micropython@v2
with:
reference: v1.22.0
- name: Install library
run: poetry install --no-interaction
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Pre-commit run
run: |
source ${{ env.ACTIVATE_PYTHON_VENV }}
pre-commit run --show-diff-on-failure --color=always --all-files
- name: Run tests
run: |
source ${{ env.ACTIVATE_PYTHON_VENV }}
python -m pytest --cov=tamp --cov-report term --cov-report xml --junitxml=testresults.xml
belay run micropython -X heapsize=200M -m unittest tests/*.py
coverage report
- name: Upload coverage to Codecov
if: steps.check_test_files.outputs.files_exists == 'true'
uses: codecov/codecov-action@v4
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