Repository navigation
126 lines (108 loc) · 3.03 KB
/
Copy pathtest.yml
File metadata and controls
126 lines (108 loc) · 3.03 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
name: Test
on:
pull_request:
push:
branches: [master]
tags: ["v*"]
workflow_dispatch:
inputs:
publish_to:
description: Where to publish
type: choice
required: true
default: none
options:
- none
- testpypi
- pypi
permissions:
contents: read
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}
cancel-in-progress: ${{ github.event_name != 'workflow_dispatch' }}
jobs:
build:
name: Build distributions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/setup-python@v7.1.0
with:
python-version: "3.15"
cache: pip
- name: Build sdist and wheel
run: |
python -m pip install nox
nox -s build
- uses: actions/upload-artifact@v7.0.2
with:
name: build-dist
path: ${{ github.workspace }}/dist/
if-no-files-found: error
test:
needs: [build]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"]
steps:
- uses: actions/checkout@v7.0.1
- name: Use Python ${{ matrix.python-version }}
uses: actions/setup-python@v7.1.0
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: pip
- name: Download distributions
uses: actions/download-artifact@v8.0.2
with:
name: build-dist
path: ${{ github.workspace }}/dist
- name: Test
run: |
python -m pip install nox
nox -s test -- dist/*.whl
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v7.1.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
tests-passed:
needs: test
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Check test results
env:
RESULT: ${{ needs.test.result }}
run: |
if [ "$RESULT" != "success" ]; then
echo "Checks did not succeed: test=$RESULT"
exit 1
fi
echo "All tests passed."
publish:
needs: [tests-passed]
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && inputs.publish_to != 'none'
env:
REPOSITORY_URL: ${{ inputs.publish_to == 'testpypi' && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }}
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v8.0.2
with:
pattern: build-*
merge-multiple: true
path: ${{ github.workspace }}/dist
- name: Publish
uses: pypa/gh-action-pypi-publish@v1.14.3
with:
repository-url: ${{ env.REPOSITORY_URL }}
packages-dir: dist
skip-existing: false
print-hash: true