1
1
---
2
2
name : " CI"
3
- on : # yamllint disable-line rule:truthy rule:comments
3
+ concurrency : # Cancel any existing runs of this workflow for this same PR
4
+ group : " ${{ github.workflow }}-${{ github.ref }}"
5
+ cancel-in-progress : true
6
+ on : # yamllint disable-line rule:truthy rule:comments
4
7
push :
5
8
branches :
6
9
- " main"
@@ -9,76 +12,72 @@ on: # yamllint disable-line rule:truthy rule:comments
9
12
- " v*"
10
13
pull_request : ~
11
14
15
+ env :
16
+ INVOKE_JDIFF_IMAGE_NAME : " jdiff"
17
+ INVOKE_JDIFF_IMAGE_VER : " latest"
18
+
12
19
jobs :
13
- black :
14
- runs-on : " ubuntu-24.04"
15
- env :
16
- INVOKE_LOCAL : " True"
17
- steps :
18
- - name : " Check out repository code"
19
- uses : " actions/checkout@v4"
20
- - name : " Setup environment"
21
- uses : " networktocode/gh-action-setup-poetry-environment@v6"
22
- with :
23
- poetry-version : " 1.8.5"
24
- - name : " Linting: black"
25
- run : " poetry run invoke black"
26
- mypy :
27
- runs-on : " ubuntu-24.04"
28
- env :
29
- INVOKE_LOCAL : " True"
30
- steps :
31
- - name : " Check out repository code"
32
- uses : " actions/checkout@v4"
33
- - name : " Setup environment"
34
- uses : " networktocode/gh-action-setup-poetry-environment@v6"
35
- with :
36
- poetry-version : " 1.8.5"
37
- - name : " Linting: mypy"
38
- run : " poetry run invoke mypy"
39
- bandit :
20
+ ruff-format :
40
21
runs-on : " ubuntu-24.04"
41
22
env :
42
- INVOKE_LOCAL : " True"
23
+ INVOKE_JDIFF_LOCAL : " True"
43
24
steps :
44
25
- name : " Check out repository code"
45
26
uses : " actions/checkout@v4"
46
27
- name : " Setup environment"
47
28
uses : " networktocode/gh-action-setup-poetry-environment@v6"
48
29
with :
49
30
poetry-version : " 1.8.5"
50
- - name : " Linting: bandit "
51
- run : " poetry run invoke bandit "
52
- pydocstyle :
31
+ - name : " Linting: ruff format "
32
+ run : " poetry run invoke ruff --action format "
33
+ ruff-lint :
53
34
runs-on : " ubuntu-24.04"
54
35
env :
55
- INVOKE_LOCAL : " True"
36
+ INVOKE_JDIFF_LOCAL : " True"
56
37
steps :
57
38
- name : " Check out repository code"
58
39
uses : " actions/checkout@v4"
59
40
- name : " Setup environment"
60
41
uses : " networktocode/gh-action-setup-poetry-environment@v6"
61
42
with :
62
43
poetry-version : " 1.8.5"
63
- - name : " Linting: pydocstyle"
64
- run : " poetry run invoke pydocstyle"
65
- flake8 :
44
+ - name : " Linting: ruff"
45
+ run : " poetry run invoke ruff --action lint"
46
+ # Temporarily disabled due to issues with the docs build and needing best practices for NTC python builds.
47
+ # check-docs-build:
48
+ # runs-on: "ubuntu-24.04"
49
+ # env:
50
+ # INVOKE_JDIFF_LOCAL: "True"
51
+ # steps:
52
+ # - name: "Check out repository code"
53
+ # uses: "actions/checkout@v4"
54
+ # - name: "Setup environment"
55
+ # uses: "networktocode/gh-action-setup-poetry-environment@v6"
56
+ # with:
57
+ # poetry-version: "1.8.5"
58
+ # - name: "Check Docs Build"
59
+ # run: "poetry run invoke build-and-check-docs"
60
+ poetry :
66
61
runs-on : " ubuntu-24.04"
67
62
env :
68
- INVOKE_LOCAL : " True"
63
+ INVOKE_JDIFF_LOCAL : " True"
69
64
steps :
70
65
- name : " Check out repository code"
71
66
uses : " actions/checkout@v4"
72
67
- name : " Setup environment"
73
68
uses : " networktocode/gh-action-setup-poetry-environment@v6"
74
69
with :
75
70
poetry-version : " 1.8.5"
76
- - name : " Linting: flake8"
77
- run : " poetry run invoke flake8"
71
+ - name : " Checking: poetry lock file"
72
+ run : " poetry lock --check"
73
+ needs :
74
+ - " ruff-format"
75
+ - " ruff-lint"
76
+ - " yamllint"
78
77
yamllint :
79
78
runs-on : " ubuntu-24.04"
80
79
env :
81
- INVOKE_LOCAL : " True"
80
+ INVOKE_JDIFF_LOCAL : " True"
82
81
steps :
83
82
- name : " Check out repository code"
84
83
uses : " actions/checkout@v4"
@@ -88,55 +87,83 @@ jobs:
88
87
poetry-version : " 1.8.5"
89
88
- name : " Linting: yamllint"
90
89
run : " poetry run invoke yamllint"
91
- pylint :
92
90
needs :
93
- - " bandit"
94
- - " pydocstyle"
95
- - " flake8"
96
- - " yamllint"
97
- - " black"
98
- - " mypy"
91
+ - " ruff-format"
92
+ - " ruff-lint"
93
+ pylint :
99
94
runs-on : " ubuntu-24.04"
100
95
strategy :
101
96
fail-fast : true
102
97
matrix :
103
- python-version : ["3.8 "]
98
+ python-version : ["3.9", "3.10", "3.11", "3.12", "3.13 "]
104
99
env :
105
100
PYTHON_VER : " ${{ matrix.python-version }}"
106
- INVOKE_LOCAL : " True"
107
101
steps :
108
102
- name : " Check out repository code"
109
103
uses : " actions/checkout@v4"
110
104
- name : " Setup environment"
111
105
uses : " networktocode/gh-action-setup-poetry-environment@v6"
106
+ - name : " Get image version"
107
+ run : " echo INVOKE_JDIFF_IMAGE_VER=`poetry version -s`-py${{ matrix.python-version }} >> $GITHUB_ENV"
108
+ - name : " Set up Docker Buildx"
109
+ id : " buildx"
110
+ uses : " docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2" # v3.10.0
111
+ - name : " Build"
112
+ uses : " docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25" # v5.4.0
112
113
with :
113
- poetry-version : " 1.8.5"
114
- # Default install options is "--only dev", but we need to install all dependencies
115
- poetry-install-options : " "
114
+ builder : " ${{ steps.buildx.outputs.name }}"
115
+ context : " ./"
116
+ push : false
117
+ load : true
118
+ tags : " ${{ env.INVOKE_JDIFF_IMAGE_NAME }}:${{ env.INVOKE_JDIFF_IMAGE_VER }}"
119
+ file : " ./Dockerfile"
120
+ cache-from : " type=gha,scope=${{ env.INVOKE_JDIFF_IMAGE_NAME }}-${{ env.INVOKE_JDIFF_IMAGE_VER }}-py${{ matrix.python-version }}"
121
+ cache-to : " type=gha,scope=${{ env.INVOKE_JDIFF_IMAGE_NAME }}-${{ env.INVOKE_JDIFF_IMAGE_VER }}-py${{ matrix.python-version }}"
122
+ build-args : |
123
+ PYTHON_VER=${{ env.PYTHON_VER }}
124
+ - name : " Debug: Show docker images"
125
+ run : " docker image ls"
116
126
- name : " Linting: Pylint"
117
127
run : " poetry run invoke pylint"
118
- pytest :
119
128
needs :
120
- - " pylint"
129
+ - " poetry"
130
+ pytest :
121
131
strategy :
122
132
fail-fast : true
123
133
matrix :
124
- python-version : ["3.8 ", "3.9 ", "3.10 ", "3.11 "]
134
+ python-version : ["3.9 ", "3.10 ", "3.11 ", "3.12", "3.13 "]
125
135
runs-on : " ubuntu-24.04"
126
136
env :
127
137
PYTHON_VER : " ${{ matrix.python-version }}"
128
- INVOKE_LOCAL : " True"
129
138
steps :
130
139
- name : " Check out repository code"
131
140
uses : " actions/checkout@v4"
132
141
- name : " Setup environment"
133
142
uses : " networktocode/gh-action-setup-poetry-environment@v6"
143
+ - name : " Get image version"
144
+ run : " echo INVOKE_JDIFF_IMAGE_VER=`poetry version -s`-py${{ matrix.python-version }} >> $GITHUB_ENV"
145
+ - name : " Set up Docker Buildx"
146
+ id : " buildx"
147
+ uses : " docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2" # v3.10.0
148
+ - name : " Build"
149
+ uses : " docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25" # v5.4.0
134
150
with :
135
- poetry-version : " 1.8.5"
136
- # Default install options is "--only dev", but we need to install all dependencies
137
- poetry-install-options : " "
151
+ builder : " ${{ steps.buildx.outputs.name }}"
152
+ context : " ./"
153
+ push : false
154
+ load : true
155
+ tags : " ${{ env.INVOKE_JDIFF_IMAGE_NAME }}:${{ env.INVOKE_JDIFF_IMAGE_VER }}"
156
+ file : " ./Dockerfile"
157
+ cache-from : " type=gha,scope=${{ env.INVOKE_JDIFF_IMAGE_NAME }}-${{ env.INVOKE_JDIFF_IMAGE_VER }}-py${{ matrix.python-version }}"
158
+ cache-to : " type=gha,scope=${{ env.INVOKE_JDIFF_IMAGE_NAME }}-${{ env.INVOKE_JDIFF_IMAGE_VER }}-py${{ matrix.python-version }}"
159
+ build-args : |
160
+ PYTHON_VER=${{ env.PYTHON_VER }}
161
+ - name : " Debug: Show docker images"
162
+ run : " docker image ls"
138
163
- name : " Run Tests"
139
164
run : " poetry run invoke pytest"
165
+ needs :
166
+ - " poetry"
140
167
changelog :
141
168
if : >
142
169
contains(fromJson('["develop"]'), github.base_ref) &&
@@ -156,11 +183,10 @@ jobs:
156
183
git fetch --no-tags origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
157
184
poetry run towncrier check --compare-with origin/${{ github.base_ref }}
158
185
publish_gh :
159
- needs :
160
- - " pytest"
161
186
name : " Publish to GitHub"
162
187
runs-on : " ubuntu-24.04"
163
- if : " startsWith(github.ref, 'refs/tags/v')"
188
+ # yamllint disable-line rule:quoted-strings
189
+ if : startsWith(github.ref, 'refs/tags/v')
164
190
steps :
165
191
- name : " Check out repository code"
166
192
uses : " actions/checkout@v4"
@@ -174,22 +200,21 @@ jobs:
174
200
run : " echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
175
201
- name : " Run Poetry Version"
176
202
run : " poetry version $RELEASE_VERSION"
203
+ - name : " Build Documentation"
204
+ run : " poetry run invoke build-and-check-docs"
177
205
- name : " Run Poetry Build"
178
206
run : " poetry build"
179
207
- name : " Upload binaries to release"
180
- uses : " svenstaro/upload-release-action@v2"
181
- with :
182
- repo_token : " ${{ secrets.NTC_GITHUB_TOKEN }}"
183
- file : " dist/*"
184
- tag : " ${{ github.ref }}"
185
- overwrite : true
186
- file_glob : true
187
- publish_pypi :
208
+ run : " gh release upload ${{ github.ref_name }} dist/*.{tar.gz,whl}"
209
+ env :
210
+ GH_TOKEN : " ${{ secrets.NTC_GITHUB_TOKEN }}"
188
211
needs :
189
212
- " pytest"
213
+ publish_pypi :
190
214
name : " Push Package to PyPI"
191
215
runs-on : " ubuntu-24.04"
192
- if : " startsWith(github.ref, 'refs/tags/v')"
216
+ # yamllint disable-line rule:quoted-strings
217
+ if : startsWith(github.ref, 'refs/tags/v')
193
218
steps :
194
219
- name : " Check out repository code"
195
220
uses : " actions/checkout@v4"
@@ -206,15 +231,16 @@ jobs:
206
231
- name : " Run Poetry Build"
207
232
run : " poetry build"
208
233
- name : " Push to PyPI"
209
- uses : " pypa/gh-action-pypi-publish@release/v1 "
234
+ uses : " pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc " # v1.12.4
210
235
with :
211
236
user : " __token__"
212
237
password : " ${{ secrets.PYPI_API_TOKEN }}"
238
+ needs :
239
+ - " pytest"
213
240
slack-notify :
214
241
needs :
215
242
- " publish_gh"
216
243
- " publish_pypi"
217
- name : " Send notification to the Slack"
218
244
runs-on : " ubuntu-24.04"
219
245
env :
220
246
SLACK_WEBHOOK_URL : " ${{ secrets.SLACK_WEBHOOK_URL }}"
@@ -227,8 +253,8 @@ jobs:
227
253
- name : " Send a notification to Slack"
228
254
# ENVs cannot be used directly in job.if. This is a workaround to check
229
255
# if SLACK_WEBHOOK_URL is present.
230
- if : " ${{ env.SLACK_WEBHOOK_URL != '' }} "
231
- uses : " slackapi/slack-github-action@v1.17.0 "
256
+ if : " env.SLACK_WEBHOOK_URL != ''"
257
+ uses : " slackapi/slack-github-action@fcfb566f8b0aab22203f066d80ca1d7e4b5d05b3 " # v1.27.1
232
258
with :
233
259
payload : |
234
260
{
0 commit comments