-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (144 loc) · 4.75 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
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Tests
on:
push:
tags: '*'
branches: [ master, main ]
pull_request:
branches: [ master, main ]
jobs:
verify_style:
runs-on: 'ubuntu-latest'
steps:
-
uses: actions/checkout@v4
-
name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: '3.x'
architecture: 'x64'
-
name: Install dependencies
run: |
python -m pip install --upgrade pip invoke typing-extensions
invoke setup --devel --tests
python/bin/python -m pip install black==19.3b0 click==8.0.1
-
name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
python/bin/python -m flake8 instruct/ --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
python/bin/python -m flake8 instruct/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
-
name: Check style with black
run: |
python/bin/python -m black --check
test_matrix:
needs: [verify_style]
strategy:
fail-fast: false
matrix:
arch:
- 'x64'
python_version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- 'pypy3.7'
- 'pypy3.8'
- 'pypy3.9'
- 'pypy3.10'
os:
- 'ubuntu-latest'
runs-on: ${{ matrix.os }}
steps:
-
uses: actions/checkout@v4
-
name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
architecture: ${{ matrix.arch }}
-
name: Install dependencies
run: |
python -m pip install --upgrade pip invoke typing-extensions
invoke setup --tests
-
name: Test with pytest
run: |
python/bin/python -m pytest
pypi-publish:
needs: [test_matrix, verify_style]
runs-on: 'ubuntu-latest'
environment:
name: pypi
url: https://pypi.org/p/instruct
permissions:
id-token: write
steps:
-
uses: actions/checkout@v4
-
name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
architecture: 'x64'
-
name: Set some variables...
id: version
run: |
echo "GIT_VERSION=$(echo '${{ github.ref_name }}' | sed 's/^.//')" >> "$GITHUB_OUTPUT"
echo "CURRENT_VERSION=$(grep -vE '^#' CURRENT_VERSION.txt | head -1)" >> "$GITHUB_OUTPUT"
-
name: Assert tag version matches the source version
run: |
if [ 'x${{ steps.version.outputs.GIT_VERSION }}' != 'x${{ steps.version.outputs.CURRENT_VERSION }}' ]; then
if [ 'x${{ github.ref_type }}' = 'xtag']; then
echo '::error file=CURRENT_VERSION.txt,line=2,title=Version mismatch::Expected ${{ steps.version.outputs.GIT_VERSION }} but got ${{ steps.version.outputs.CURRENT_VERSION }} instead.
Suggest you fix that and delete the tag.'
exit 254
else
echo '::warn file=CURRENT_VERSION.txt,line=2,title=Version mismatch::Expected ${{ steps.version.outputs.GIT_VERSION }} but got ${{ steps.version.outputs.CURRENT_VERSION }} instead.
If you make a tag from this, it *will* error out.'
fi
fi
-
name: Install dependencies
run: |
python -m pip install --upgrade pip invoke typing-extensions
invoke setup --devel --no-project
-
name: Create artifacts
run: |
python/bin/python -m build
-
name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: ${{ github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') }}
with:
skip-existing: false
# -
# name: Create Release
# if: false
# id: create_release
# uses: actions/create-release@latest
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: ${{ github.ref }}
# release_name: Release ${{ steps.version.outputs.CURRENT_VERSION }}
# body: |
# Changes in this Release
# - First Change
# - Second Change
# draft: false
# prerelease: false