-
Notifications
You must be signed in to change notification settings - Fork 15
161 lines (149 loc) · 4.79 KB
/
build.yml
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Build
on:
push:
branches: [main]
tags:
- v*
# Required shell entrypoint to have properly activated conda environments
defaults:
run:
shell: bash -l {0}
jobs:
check:
name: Run checks for GutenTAG on ubuntu with python 3.7
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Miniconda
uses: conda-incubator/[email protected]
with:
use-mamba: true
auto-update-conda: true
python-version: "3.7"
- name: Install dependencies
run: |
pip install -r requirements.dev
- name: Typcheck with mypy
run: |
python setup.py typecheck
- name: Lint with flake8
run: |
flake8 . --count --show-source --statistics
test:
name: Test GutenTAG on ${{ matrix.os }} with python ${{ matrix.python_version }}
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 3
matrix:
os: [ubuntu-latest] # [ubuntu-latest, windows-latest, macOS-latest]
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Setup Miniconda
uses: conda-incubator/[email protected]
with:
use-mamba: true
auto-update-conda: true
python-version: ${{ matrix.python_version }}
- name: Install dependencies
run: |
pip install -r requirements.dev
- name: Test with pytest
run: |
python setup.py test
- name: Extract test coverage
if: ${{ matrix.python_version == '3.11' && matrix.os == 'ubuntu-latest' }}
run: |
SUMMARY=$(sed -n "s/^<coverage.*line-rate=\"\([0-9.]*\)\".*>$/\1/p" coverage.xml)
echo "COVERAGE=$(echo ${SUMMARY})" >> $GITHUB_ENV
echo "Extracted coverage data: ${COVERAGE}"
REF=${{ github.ref }}
IFS='/' read -ra PATHS <<< "$REF"
BRANCH_NAME="${PATHS[1]}_${PATHS[2]}"
echo "BRANCH=$(echo ${BRANCH_NAME})" >> $GITHUB_ENV
echo "Extracted branch name: $BRANCH_NAME"
- name: Create coverage badge
if: ${{ matrix.python_version == '3.11' && matrix.os == 'ubuntu-latest' }}
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 6762bee806477c52e079f21d2f252688
filename: gutentag__${{ env.BRANCH }}.json
label: Test Coverage
message: ${{ env.COVERAGE }}
color: green
namedLogo: pytest
- name: Upload Coverage to Codecov
if: ${{ matrix.python_version == '3.11' && matrix.os == 'ubuntu-latest' }}
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: coverage.xml
flags: unittests
build-source-distribution:
name: Build source distribution
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs:
- test
- check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Miniconda
uses: conda-incubator/[email protected]
with:
use-mamba: true
auto-update-conda: true
python-version: 3.7
- name: Build source distribution
run: |
python setup.py sdist
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: packages-source
path: dist
build-manylinux-wheels:
name: Build manylinux wheels
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs:
- test
- check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build manylinux Python wheels
uses: RalfG/[email protected]_x86_64
with:
# our wheel is purely python, so this creates a *-none-any.wheel and other versions are not required for now
python-versions: 'cp37-cp37m'
- name: List packages
run: |
ls -alh dist
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: packages-manylinux
path: dist/*.whl
publish:
name: Publish distributions
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [build-source-distribution, build-manylinux-wheels]
runs-on: ubuntu-latest
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- name: Download packages
uses: actions/download-artifact@v4
with:
path: dist
- name: Restore original folder structure of dist
run: |
find dist -type f -exec mv {} dist/ \;
find dist/* -type d -exec rmdir {} \; || true
- name: Publish package to PyPi
uses: pypa/[email protected]