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 :
20
+ ruff-format :
27
21
runs-on : " ubuntu-24.04"
28
22
env :
29
- INVOKE_LOCAL : " True"
23
+ INVOKE_JDIFF_LOCAL : " True"
30
24
steps :
31
25
- name : " Check out repository code"
32
26
uses : " actions/checkout@v4"
33
27
- name : " Setup environment"
34
28
uses : " networktocode/gh-action-setup-poetry-environment@v6"
35
29
with :
36
30
poetry-version : " 1.8.5"
37
- - name : " Linting: mypy "
38
- run : " poetry run invoke mypy "
39
- bandit :
31
+ - name : " Linting: ruff format "
32
+ run : " poetry run invoke ruff --action format "
33
+ ruff-lint :
40
34
runs-on : " ubuntu-24.04"
41
35
env :
42
- INVOKE_LOCAL : " True"
36
+ INVOKE_JDIFF_LOCAL : " True"
43
37
steps :
44
38
- name : " Check out repository code"
45
39
uses : " actions/checkout@v4"
46
40
- name : " Setup environment"
47
41
uses : " networktocode/gh-action-setup-poetry-environment@v6"
48
42
with :
49
43
poetry-version : " 1.8.5"
50
- - name : " Linting: bandit"
51
- run : " poetry run invoke bandit"
52
- pydocstyle :
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 :
53
61
runs-on : " ubuntu-24.04"
54
62
env :
55
- INVOKE_LOCAL : " True"
63
+ INVOKE_JDIFF_LOCAL : " True"
56
64
steps :
57
65
- name : " Check out repository code"
58
66
uses : " actions/checkout@v4"
59
67
- name : " Setup environment"
60
68
uses : " networktocode/gh-action-setup-poetry-environment@v6"
61
69
with :
62
70
poetry-version : " 1.8.5"
63
- - name : " Linting: pydocstyle"
64
- run : " poetry run invoke pydocstyle"
65
- flake8 :
66
- runs-on : " ubuntu-24.04"
67
- env :
68
- INVOKE_LOCAL : " True"
69
- steps :
70
- - name : " Check out repository code"
71
- uses : " actions/checkout@v4"
72
- - name : " Setup environment"
73
- uses : " networktocode/gh-action-setup-poetry-environment@v6"
74
- with :
75
- 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,61 +87,106 @@ 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"
140
- publish_gh :
141
165
needs :
142
- - " pytest"
166
+ - " poetry"
167
+ changelog :
168
+ if : >
169
+ contains(fromJson('["develop"]'), github.base_ref) &&
170
+ (github.head_ref != 'main') && (!startsWith(github.head_ref, 'release'))
171
+ runs-on : " ubuntu-22.04"
172
+ steps :
173
+ - name : " Check out repository code"
174
+ uses : " actions/checkout@v4"
175
+ with :
176
+ fetch-depth : " 0"
177
+ - name : " Setup environment"
178
+ uses : " networktocode/gh-action-setup-poetry-environment@v6"
179
+ with :
180
+ poetry-version : " 1.8.5"
181
+ - name : " Check for changelog entry"
182
+ run : |
183
+ git fetch --no-tags origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
184
+ poetry run towncrier check --compare-with origin/${{ github.base_ref }}
185
+ publish_gh :
143
186
name : " Publish to GitHub"
144
187
runs-on : " ubuntu-24.04"
145
- if : " startsWith(github.ref, 'refs/tags/v')"
188
+ # yamllint disable-line rule:quoted-strings
189
+ if : startsWith(github.ref, 'refs/tags/v')
146
190
steps :
147
191
- name : " Check out repository code"
148
192
uses : " actions/checkout@v4"
@@ -156,22 +200,21 @@ jobs:
156
200
run : " echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
157
201
- name : " Run Poetry Version"
158
202
run : " poetry version $RELEASE_VERSION"
203
+ - name : " Build Documentation"
204
+ run : " poetry run invoke build-and-check-docs"
159
205
- name : " Run Poetry Build"
160
206
run : " poetry build"
161
207
- name : " Upload binaries to release"
162
- uses : " svenstaro/upload-release-action@v2"
163
- with :
164
- repo_token : " ${{ secrets.NTC_GITHUB_TOKEN }}"
165
- file : " dist/*"
166
- tag : " ${{ github.ref }}"
167
- overwrite : true
168
- file_glob : true
169
- publish_pypi :
208
+ run : " gh release upload ${{ github.ref_name }} dist/*.{tar.gz,whl}"
209
+ env :
210
+ GH_TOKEN : " ${{ secrets.NTC_GITHUB_TOKEN }}"
170
211
needs :
171
212
- " pytest"
213
+ publish_pypi :
172
214
name : " Push Package to PyPI"
173
215
runs-on : " ubuntu-24.04"
174
- if : " startsWith(github.ref, 'refs/tags/v')"
216
+ # yamllint disable-line rule:quoted-strings
217
+ if : startsWith(github.ref, 'refs/tags/v')
175
218
steps :
176
219
- name : " Check out repository code"
177
220
uses : " actions/checkout@v4"
@@ -188,15 +231,16 @@ jobs:
188
231
- name : " Run Poetry Build"
189
232
run : " poetry build"
190
233
- name : " Push to PyPI"
191
- uses : " pypa/gh-action-pypi-publish@release/v1 "
234
+ uses : " pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc " # v1.12.4
192
235
with :
193
236
user : " __token__"
194
237
password : " ${{ secrets.PYPI_API_TOKEN }}"
238
+ needs :
239
+ - " pytest"
195
240
slack-notify :
196
241
needs :
197
242
- " publish_gh"
198
243
- " publish_pypi"
199
- name : " Send notification to the Slack"
200
244
runs-on : " ubuntu-24.04"
201
245
env :
202
246
SLACK_WEBHOOK_URL : " ${{ secrets.SLACK_WEBHOOK_URL }}"
@@ -209,8 +253,8 @@ jobs:
209
253
- name : " Send a notification to Slack"
210
254
# ENVs cannot be used directly in job.if. This is a workaround to check
211
255
# if SLACK_WEBHOOK_URL is present.
212
- if : " ${{ env.SLACK_WEBHOOK_URL != '' }} "
213
- uses : " slackapi/slack-github-action@v1.17.0 "
256
+ if : " env.SLACK_WEBHOOK_URL != ''"
257
+ uses : " slackapi/slack-github-action@fcfb566f8b0aab22203f066d80ca1d7e4b5d05b3 " # v1.27.1
214
258
with :
215
259
payload : |
216
260
{
0 commit comments