-
Notifications
You must be signed in to change notification settings - Fork 167
114 lines (94 loc) · 3.09 KB
/
Copy pathtest.yaml
File metadata and controls
114 lines (94 loc) · 3.09 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
name: test
on:
# Run on each commit.
push:
# Run on pull requests.
pull_request:
branches:
- main
# Run daily at UTC midnight.
schedule:
- cron: "0 0 * * *"
# Can be launched manually in github actions tab.
workflow_dispatch: # Allows manual trigger
inputs:
commit_sha:
description: "[Optional] commit SHA to test"
required: false
default: ""
verbose:
description: "Verbose [false|true]"
required: false
default: "false"
jobs:
test:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
matrix:
os: [ubuntu-22.04, macos-latest, windows-latest]
python-version: ['3.11', "3.12", "3.13", "3.14"]
steps:
- name: Show architecture
run: uname -a
- name: Determine commit to use
run: |
# Strip leading and trailing spaces
sha="$(echo "${{ github.event.inputs.commit_sha }}" | xargs)"
# User specified commit SHA.
if [ -n "$sha" ]; then
echo "COMMIT_SHA=$sha" >> $GITHUB_ENV
echo "COMMIT_NOTE=Using manual commit" >> $GITHUB_ENV
# Default behavior, use latest commit.
else
echo "COMMIT_SHA=${{ github.sha }}" >> $GITHUB_ENV
echo "COMMIT_NOTE=Using latest commit" >> $GITHUB_ENV
fi
- name: Show selected commit
run: |
echo "$COMMIT_NOTE"
echo "Selected: $COMMIT_SHA"
echo "Latest: ${{github.sha}}"
- name: Checkout apio
uses: actions/checkout@v6
with:
ref: ${{env.COMMIT_SHA}}
- name: Install python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Show python version
run: python --version
- name: Install dev tools
run: |
pip install invoke
invoke install-deps
# TODO: Move the logic here to an Invoke task and use it instead.
- name: Run Tests
run: |
# Convert py version such as '3.13' to 'py313' as required by tox.ini.
pyver="py${{matrix.python-version}}"
echo "pyver: [$pyver]"
pyver=${pyver//./}
echo "pyver: [$pyver]"
# Determine if we run in verbose mode. This can be enabled
# in the github dashboard when running the workflow manuall.y.
echo "Original verbose: [${{ github.event.inputs.verbose }}]"
verbose="${{ github.event.inputs.verbose || 'false' }}"
echo "Effective verbose: [${verbose}]"
if [[ "$verbose" != "true" && "$verbose" != "false" ]]; then
echo "Error: 'verbose' must be 'true' or 'false'."
exit 1
fi
# Determine the posargs to pass to pytest.
if [ "${verbose}" = "true" ]; then
echo "Verbose mode ON"
posargs="-s"
else
echo "Verbose mode OFF"
posargs=""
fi
# Run the tests
python -m tox --skip-missing-interpreters false -e lint,$pyver -- ${posargs}