-
Notifications
You must be signed in to change notification settings - Fork 15
205 lines (185 loc) · 8.96 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: Build and Test
on:
push:
branches:
- master
pull_request:
branches:
- master
types:
- opened
- synchronize
- reopened
- closed
jobs:
matrix-builder:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
inverted_matrix: ${{ steps.set-matrix.outputs.inverted_matrix }}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
architecture: x64
- id: set-matrix
env:
PY_VERSIONS: "[\"3.7\", \"3.8\", \"3.9\", \"3.10\", \"3.11\", \"3.12\", \"pypy-3.9\", \"pypy-3.10\"]"
OS_NAMES: "[\"ubuntu-20.04\"]" #, windows-latest, macOS-latest]
CELERY_VERSIONS: "[\">=4.0.0,<5.0.0\", \">=5.0.0,<6.0.0\"]"
run: |
python -m pip install --upgrade pip
MATRIX=$(python .github/workflows/resolve_versions.py matrix -c "$PY_VERSIONS" -o "$OS_NAMES" -n "celery" -s "$CELERY_VERSIONS")
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
INV_MATRIX=$(python .github/workflows/resolve_versions.py matrix -c "$PY_VERSIONS" -o "$OS_NAMES" -n "celery" -s "$CELERY_VERSIONS" --invert)
echo "inverted_matrix=$INV_MATRIX" >> $GITHUB_OUTPUT
unsupported:
name: Skipping on Python ${{ matrix.python-version }} and ${{ matrix.os }} with celery${{ matrix.celery }}
needs: matrix-builder
strategy:
matrix: ${{ fromJSON(needs.matrix-builder.outputs.inverted_matrix) }}
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Prepare badges
id: badges
run: |
CELERY_MAJOR=$(echo "${{ matrix.celery }}" | sed -r 's/^([^.]+).*$/\1/; s/^[^0-9]*([0-9]+).*$/\1/')
echo "celery=${CELERY_MAJOR}" >> $GITHUB_OUTPUT
echo "source_name=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
echo "source_branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
echo "source_tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
[[ "${{ matrix.python-version }}" == pypy* ]] \
&& echo "python=$(echo "${{ matrix.python-version }}" | cut -d '-' -f1-2)" >> $GITHUB_OUTPUT \
|| echo "python=${{ matrix.python-version }}" >> $GITHUB_OUTPUT
[[ "${{ matrix.os }}" == ubuntu* ]] && echo "platform=linux" >> $GITHUB_OUTPUT || echo "Not on linux"
[[ "${{ matrix.os }}" == windows* ]] && echo "platform=windows" >> $GITHUB_OUTPUT || echo "Not on window"
[[ "${{ matrix.os }}" == macOS* ]] && echo "platform=apple" >> $GITHUB_OUTPUT || echo "Not on macOS"
- name: Badge Creation (master) (unsupported)
uses: RubbaBoy/[email protected]
if: github.event.pull_request.merged == true && steps.badges.outcome == 'success'
with:
NAME: m_${{ steps.badges.outputs.platform }}_${{ steps.badges.outputs.python }}_celery${{ steps.badges.outputs.celery }}
ICON: 'https://simpleicons.vercel.app/${{ steps.badges.outputs.platform }}/ffffff'
LABEL: "celery-pubsub (in master)"
STATUS: "Unsupported"
COLOR: yellow
GITHUB_TOKEN: ${{ secrets.BADGES_TOKEN }}
- name: Badge Creation (tag) (unsupported)
uses: RubbaBoy/[email protected]
if: github.event_name == 'push' && github.ref_type == 'tag' && steps.badges.outcome == 'success'
with:
NAME: ${{ steps.badges.outputs.source_tag }}_${{ steps.badges.outputs.platform }}_${{ steps.badges.outputs.python }}_celery${{ steps.badges.outputs.celery }}
ICON: 'https://simpleicons.vercel.app/${{ steps.badges.outputs.platform }}/ffffff'
LABEL: "celery-pubsub ${{ steps.badges.outputs.source_tag }}"
STATUS: "Unsupported"
COLOR: yellow
GITHUB_TOKEN: ${{ secrets.BADGES_TOKEN }}
build:
name: Test on Python ${{ matrix.python-version }} and ${{ matrix.os }} with celery${{ matrix.celery }}
needs: matrix-builder
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{ fromJSON(needs.matrix-builder.outputs.matrix) }}
fail-fast: false
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Show system
run: |
python --version
uname -a
lsb_release -a
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements_test.txt
pip install "celery${{ matrix.celery }}"
pip install pytest-github-actions-annotate-failures
- name: Check with black
run: black --check .
- name: Check with mypy
if: ${{ !startsWith(matrix.python-version, 'pypy') }}
run: mypy
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude .github
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude .github
- name: Test with pytest
run: |
coverage run -m pytest -v -s tests
coverage report
- name: Code Climate Coverage Action
uses: paambaati/[email protected]
env:
# According to CodeClimate documentation, this is not considered a sensitive value.
# https://docs.codeclimate.com/docs/finding-your-test-coverage-token#regenerating-a-repos-test-reporter-id
CC_TEST_REPORTER_ID: 4967416d540739937e0eebfb13a3cf2f8dfbddd762f2b1ec800e83d18fb5efbb
with:
coverageCommand: coverage xml
debug: true
- name: Prepare badges
id: badges
run: |
CELERY_MAJOR=$(echo "${{ matrix.celery }}" | sed -r 's/^([^.]+).*$/\1/; s/^[^0-9]*([0-9]+).*$/\1/')
echo "celery=${CELERY_MAJOR}" >> $GITHUB_OUTPUT
echo "source_name=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
echo "source_branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
echo "source_tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
[[ "${{ matrix.python-version }}" == pypy* ]] \
&& echo "python=$(echo "${{ matrix.python-version }}" | cut -d '-' -f1-2)" >> $GITHUB_OUTPUT \
|| echo "python=${{ matrix.python-version }}" >> $GITHUB_OUTPUT
[[ "${{ matrix.os }}" == ubuntu* ]] && echo "platform=linux" >> $GITHUB_OUTPUT || echo "Not on linux"
[[ "${{ matrix.os }}" == windows* ]] && echo "platform=windows" >> $GITHUB_OUTPUT || echo "Not on window"
[[ "${{ matrix.os }}" == macOS* ]] && echo "platform=apple" >> $GITHUB_OUTPUT || echo "Not on macOS"
- name: Badge Creation (master) (success)
uses: RubbaBoy/[email protected]
if: github.event.pull_request.merged == true && steps.badges.outcome == 'success'
with:
NAME: m_${{ steps.badges.outputs.platform }}_${{ steps.badges.outputs.python }}_celery${{ steps.badges.outputs.celery }}
ICON: 'https://simpleicons.vercel.app/${{ steps.badges.outputs.platform }}/ffffff'
LABEL: "celery-pubsub (in master)"
STATUS: "Supported"
COLOR: green
GITHUB_TOKEN: ${{ secrets.BADGES_TOKEN }}
- name: Badge Creation (master) (failure)
uses: RubbaBoy/[email protected]
if: github.event.pull_request.merged == true && steps.badges.outcome != 'success'
with:
NAME: m_${{ steps.badges.outputs.platform }}_${{ steps.badges.outputs.python }}_celery${{ steps.badges.outputs.celery }}
ICON: 'https://simpleicons.vercel.app/${{ steps.badges.outputs.platform }}/ffffff'
LABEL: "celery-pubsub (in master)"
STATUS: "Failed"
COLOR: red
GITHUB_TOKEN: ${{ secrets.BADGES_TOKEN }}
- name: Badge Creation (tag) (success)
uses: RubbaBoy/[email protected]
if: github.event_name == 'push' && github.ref_type == 'tag' && steps.badges.outcome == 'success'
with:
NAME: ${{ steps.badges.outputs.source_tag }}_${{ steps.badges.outputs.platform }}_${{ steps.badges.outputs.python }}_celery${{ steps.badges.outputs.celery }}
ICON: 'https://simpleicons.vercel.app/${{ steps.badges.outputs.platform }}/ffffff'
LABEL: "celery-pubsub ${{ steps.badges.outputs.source_tag }}"
STATUS: "Supported"
COLOR: green
GITHUB_TOKEN: ${{ secrets.BADGES_TOKEN }}
- name: Badge Creation (tag) (failure)
uses: RubbaBoy/[email protected]
if: github.event_name == 'push' && github.ref_type == 'tag' && steps.badges.outcome != 'success'
with:
NAME: ${{ steps.badges.outputs.source_tag }}_${{ steps.badges.outputs.platform }}_${{ steps.badges.outputs.python }}_celery${{ steps.badges.outputs.celery }}
ICON: 'https://simpleicons.vercel.app/${{ steps.badges.outputs.platform }}/ffffff'
LABEL: "celery-pubsub ${{ steps.badges.outputs.source_tag }}"
STATUS: "Failed"
COLOR: red
GITHUB_TOKEN: ${{ secrets.BADGES_TOKEN }}