-
Notifications
You must be signed in to change notification settings - Fork 45
99 lines (87 loc) · 3.04 KB
/
pydna_test_and_coverage_workflow.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
name: Tests & Coverage
on:
push:
branches:
- "**"
- "!master" # excludes master branch
- "!testpypi" # excludes testpypi branch
tags-ignore:
- "*.*"
pull_request: {}
jobs:
build:
name: Test (${{ matrix.python-version }}, ${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: ["macos-latest", "windows-latest"]
python-version: ["3.12", "3.11", "3.10", "3.9", "3.8"]
include:
- os: ubuntu-latest
python-version: "3.8"
codecov: true
- os: ubuntu-latest
python-version: "3.9"
- os: ubuntu-latest
python-version: "3.10"
- os: ubuntu-latest
python-version: "3.11"
- os: ubuntu-latest
python-version: "3.12"
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/[email protected]
- name: ⬇️ Checkout
uses: actions/checkout@v3
- 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: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs.prefer-active-python: true
- name: 🔩 list Poetry settings
run: poetry config --list
- name: 🔩 Install with Poetry
run: poetry install --all-extras --with test
- name: 🔎 poetry run python run_test.py
run: poetry run python run_test.py
# Enforce pre-commit hooks ===========================
- name: Get changed files
if: (matrix.codecov)
id: changed-files
uses: tj-actions/changed-files@v45
with:
since_last_remote_commit: true
- uses: actions/cache@v4
if: (matrix.codecov)
id: cache-precommit
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-precommit-hooks-v2-${{ hashFiles('**/.pre-commit-config.yaml') }}
- name: Installing pre-commit hooks (cached)
if: (matrix.codecov) && (steps.cache-precommit.outputs.cache-hit != 'true')
run: poetry run pre-commit install --install-hooks
- name: Run style checking via pre-commit
if: (matrix.codecov && steps.changed-files.outputs.all_changed_files)
run: |
echo "Changed files:"
echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n'
poetry run pre-commit run --files ${{ steps.changed-files.outputs.all_changed_files }}
# ======================================================
- name: 🔼 Upload coverage to Codecov
if: (matrix.codecov)
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true