-
Notifications
You must be signed in to change notification settings - Fork 11
142 lines (120 loc) · 4.42 KB
/
code.yml
File metadata and controls
142 lines (120 loc) · 4.42 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
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Code CI
on:
push:
pull_request:
jobs:
test:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"] # can add windows-latest, macos-latest
python: ["3.9", "3.10", "3.11", "3.12"]
install: ["-e .[dev]"]
# Make one version be non-editable to test both paths of version code
include:
- os: "ubuntu-latest"
python: "3.8"
install: ".[dev]"
runs-on: ${{ matrix.os }}
container:
image: ghcr.io/epics-containers/epics-base-developer:7.0.9ec3
volumes:
- /opt/hostedtoolcache:/opt/hostedtoolcache
env:
# https://github.com/pytest-dev/pytest/issues/2042
PY_IGNORE_IMPORTMISMATCH: "1"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Need this to get version number from last tag
fetch-depth: 0
- name: Install python packages
uses: ./.github/actions/install_requirements
with:
python_version: ${{ matrix.python }}
requirements_file: requirements-test-${{ matrix.os }}-${{ matrix.python }}.txt
install_options: ${{ matrix.install }}
- name: List dependency tree
run: pipdeptree
- name: Run tests
run: tox -e pytest
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
name: ${{ matrix.python }}/${{ matrix.os }}
files: cov.xml
dist:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Need this to get version number from last tag
fetch-depth: 0
- name: Build sdist
run: |
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) && \
pipx run build --sdist
- name: Build wheels
uses: pypa/[email protected]
with:
output-dir: dist
env:
# Force using an older manylinux image to support more OSs
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
# Simple test that the wheel is loaded and available
CIBW_TEST_COMMAND: python -c "import cothread; print(cothread.__version__)"
# Skip all PyPy wheels (GIL deadlock detected in ThreadState_New)
# Skip all i686 wheels (cannot build numpy)
# This leaves manylinux and musllinux wheels
CIBW_SKIP: pp* *i686*
- name: Upload sdist and wheels as artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}-${{ matrix.python }}
path: dist
- name: Check for packaging errors
run: pipx run twine check --strict dist/*
release:
# upload to PyPI and make a release on every tag
needs: [dist, test]
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
runs-on: ubuntu-latest
env:
HAS_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN != '' }}
steps:
- name: Download dist
uses: actions/download-artifact@v4
with:
pattern: dist*
path: dist
merge-multiple: true
- name: Download lockfiles
uses: actions/download-artifact@v4
with:
pattern: lockfiles*
path: lockfiles
merge-multiple: true
- name: Fixup blank lockfiles
# Github release artifacts can't be blank
run: for f in lockfiles/*; do [ -s $f ] || echo '# No requirements' >> $f; done
- name: Github Release
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
files: |
dist/*
lockfiles/*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to PyPI
if: ${{ env.HAS_PYPI_TOKEN }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}