-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathpydna_test_and_coverage_workflow.yml
More file actions
120 lines (106 loc) · 3.84 KB
/
pydna_test_and_coverage_workflow.yml
File metadata and controls
120 lines (106 loc) · 3.84 KB
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
name: Tests & Coverage
on:
push:
branches:
- "**"
- "!testpypi" # excludes testpypi branch
pull_request: {}
jobs:
build:
name: Test (${{ matrix.python-version }}, ${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: ["macos-latest", "windows-latest"]
python-version: ["3.13", "3.12", "3.11", "3.10"]
include:
- os: ubuntu-latest
python-version: "3.10"
- os: ubuntu-latest
python-version: "3.11"
- os: ubuntu-latest
python-version: "3.12"
codecov: true
- os: ubuntu-latest
python-version: "3.12"
hooks: true
# Don't run hooks check on master, otherwise no-commit-to-branch hook will fail
if: github.ref != 'refs/heads/master'
- os: ubuntu-latest
python-version: "3.13"
# This mimics what would happen installing using pip install pydna (removes the
# poetry.lock file before installing)
- os: ubuntu-latest
python-version: "3.12"
fresh-install: true
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
env:
MPLBACKEND: Agg
steps:
- name: 🛑 Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.11.0
- name: ⬇️ Checkout PR HEAD (full history)
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: ⬇️ Checkout (push/tag) full history
if: github.event_name != 'pull_request'
uses: actions/checkout@v4
with:
fetch-depth: 0
- 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.4.1
- name: 🔩 list Poetry settings
run: poetry config --list
- name: remove poetry.lock for fresh install
run: rm poetry.lock
if: matrix.fresh-install == 'true'
- name: 🔩 Install with Poetry
run: poetry install --all-extras
- name: 🔎 poetry run python run_test.py
# Don't run tests if we're just checking hooks
if: (!matrix.hooks)
run: poetry run python run_test.py
# Enforce pre-commit hooks ===========================
- name: Get changed files
if: (matrix.hooks)
id: changed-files
uses: tj-actions/changed-files@v45
with:
since_last_remote_commit: true
- uses: actions/cache@v4
if: (matrix.hooks)
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.hooks) && (steps.cache-precommit.outputs.cache-hit != 'true')
run: poetry run pre-commit install --install-hooks
- name: Run style checking via pre-commit
if: (matrix.hooks && 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@v5
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true