-
Notifications
You must be signed in to change notification settings - Fork 99
129 lines (106 loc) · 3.26 KB
/
Copy pathpython-testing.yml
File metadata and controls
129 lines (106 loc) · 3.26 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
121
122
123
124
125
126
127
128
129
---
name: Python
# HINT: Sync this paths with the egrep in step check_files
on:
push:
branches: [ "master", "main" ]
paths:
- 'pyproject.toml'
- 'setup.cfg'
- '**.py'
- '.github/workflows/*.yml'
pull_request:
branches: [ "master", "main" ]
paths:
- 'pyproject.toml'
- 'setup.cfg'
- '**.py'
- '.github/workflows/*.yml'
permissions:
contents: read
concurrency:
# only cancel in-progress runs of the same workflow
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-files:
runs-on: ubuntu-latest
outputs:
can_run: ${{ steps.check_files.outputs.can_run }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: GitHub variables
id: gh-vars
run: |
for var in GITHUB_WORKFLOW GITHUB_ACTION GITHUB_ACTIONS GITHUB_REPOSITORY GITHUB_EVEN_NAME GITHUB_EVENT_PATH GITHUB_WORKSPACE GITHUB_SHA GITHUB_REF GITHUB_HEAD_REF GITHUB_BASE_REF; do
echo "$var = ${!var}"
done
- name: Check for file changes
id: check_files
run: |
# ${{ github.event.after }} ${{ github.event.before }}
can_run=$(git diff --name-only HEAD~1 HEAD | \
egrep -q '.github/workflows/|pyproject.toml|setup.cfg|\.py$' && echo 1 || echo 0)
echo "can_run=$can_run"
echo "can_run=$can_run" >> $GITHUB_OUTPUT
skip_test:
runs-on: ubuntu-latest
needs: check-files
timeout-minutes: 2
if: ${{ needs.check-files.outputs.can_run == '0' }}
steps:
- name: Skip test
run: |
echo "Nothing to do as no TOML, Python, or YAML file has been changed.
"
echo "Skipping."
check:
runs-on: ubuntu-latest
needs: check-files
timeout-minutes: 15
# needs.check-files.outputs.can_run
if: ${{ needs.check-files.outputs.can_run == '1' }}
steps:
- uses: actions/checkout@v7
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
enable-cache: true
- name: Set up Python 3.10
# check tox.ini for the lowest version
run: uv python install 3.10
- name: Install the project
run: |
uv sync --all-extras --group gh-action
- name: Checks
continue-on-error: true
run: uv run tox run -e checks
tests:
needs: check
runs-on: ${{ matrix.os }}
# continue-on-error: true
strategy:
max-parallel: 5
fail-fast: true
matrix:
python-version: ["3.10",
"3.11",
"3.12",
"3.13",
"3.14",
]
os: ["ubuntu-latest", "macos-latest"]
steps:
- uses: actions/checkout@v7
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install the project
run: |
uv sync --all-extras --dev
uv pip install tox tox-gh-actions
- name: Checks
run: uv run tox run -e ${{ matrix.python-version }}