1
1
---
2
2
name : " CI"
3
3
concurrency : # Cancel any existing runs of this workflow for this same PR
4
- group : " ${{ github.workflow }}-${{ github.ref }}"
4
+ group : " ${{ '{{ github.workflow }}' }} -${{ '{{ github.ref }}' }}"
5
5
cancel-in-progress : true
6
- on : # yamllint disable
6
+ on : # yamllint disable-line rule:truthy rule:comments
7
7
push :
8
8
branches :
9
9
- " main"
10
10
- " develop"
11
11
tags :
12
12
- " v*"
13
13
pull_request : ~
14
+
15
+ env :
16
+ INVOKE_PARSER_IMAGE_NAME : " circuit_maintenance_parser"
17
+ INVOKE_PARSER_IMAGE_VER : " latest"
18
+
14
19
jobs :
15
- black :
20
+ ruff-format :
16
21
runs-on : " ubuntu-24.04"
17
22
env :
18
- INVOKE_LOCAL : " True"
23
+ INVOKE_PARSER_LOCAL : " True"
19
24
steps :
20
25
- name : " Check out repository code"
21
- uses : " actions/checkout@v3 "
26
+ uses : " actions/checkout@v4 "
22
27
- name : " Setup environment"
23
28
uses : " networktocode/gh-action-setup-poetry-environment@v6"
24
- - name : " Linting: black"
25
- run : " poetry run invoke black"
26
- bandit :
27
- runs-on : " ubuntu-24.04"
28
- env :
29
- INVOKE_LOCAL : " True"
30
- steps :
31
- - name : " Check out repository code"
32
- uses : " actions/checkout@v3"
33
- - name : " Setup environment"
34
- uses : " networktocode/gh-action-setup-poetry-environment@v6"
35
- - name : " Linting: bandit"
36
- run : " poetry run invoke bandit"
37
- needs :
38
- - " black"
39
- pydocstyle :
40
- runs-on : " ubuntu-24.04"
41
- env :
42
- INVOKE_LOCAL : " True"
43
- steps :
44
- - name : " Check out repository code"
45
- uses : " actions/checkout@v3"
46
- - name : " Setup environment"
47
- uses : " networktocode/gh-action-setup-poetry-environment@v6"
48
- - name : " Linting: pydocstyle"
49
- run : " poetry run invoke pydocstyle"
50
- needs :
51
- - " black"
52
- flake8 :
29
+ with :
30
+ poetry-version : " 1.8.5"
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_PARSER_LOCAL : " True"
56
37
steps :
57
38
- name : " Check out repository code"
58
- uses : " actions/checkout@v3 "
39
+ uses : " actions/checkout@v4 "
59
40
- name : " Setup environment"
60
41
uses : " networktocode/gh-action-setup-poetry-environment@v6"
61
- - name : " Linting: flake8"
62
- run : " poetry run invoke flake8"
63
- needs :
64
- - " black"
65
- mypy :
42
+ with :
43
+ poetry-version : " 1.8.5"
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_PARSER_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_PARSER_LOCAL : " True"
69
64
steps :
70
65
- name : " Check out repository code"
71
- uses : " actions/checkout@v3 "
66
+ uses : " actions/checkout@v4 "
72
67
- name : " Setup environment"
73
68
uses : " networktocode/gh-action-setup-poetry-environment@v6"
74
69
with :
75
- poetry-install-options : " --with dev "
76
- - name : " Linting: flake8 "
77
- run : " poetry run invoke mypy "
70
+ poetry-version : " 1.8.5 "
71
+ - name : " Checking: poetry lock file "
72
+ run : " poetry lock --check "
78
73
needs :
79
- - " black"
74
+ - " ruff-format"
75
+ - " ruff-lint"
76
+ - " yamllint"
80
77
yamllint :
81
78
runs-on : " ubuntu-24.04"
82
79
env :
83
- INVOKE_LOCAL : " True"
80
+ INVOKE_PARSER_LOCAL : " True"
84
81
steps :
85
82
- name : " Check out repository code"
86
- uses : " actions/checkout@v3 "
83
+ uses : " actions/checkout@v4 "
87
84
- name : " Setup environment"
88
85
uses : " networktocode/gh-action-setup-poetry-environment@v6"
86
+ with :
87
+ poetry-version : " 1.8.5"
89
88
- name : " Linting: yamllint"
90
89
run : " poetry run invoke yamllint"
91
90
needs :
92
- - " black"
91
+ - " ruff-format"
92
+ - " ruff-lint"
93
93
pylint :
94
94
runs-on : " ubuntu-24.04"
95
+ strategy :
96
+ fail-fast : true
97
+ matrix :
98
+ python-version : ["3.9", "3.10", "3.11", "3.12"]
95
99
env :
96
- INVOKE_LOCAL : " True "
100
+ PYTHON_VER : " ${{ matrix.python-version }} "
97
101
steps :
98
102
- name : " Check out repository code"
99
- uses : " actions/checkout@v3 "
103
+ uses : " actions/checkout@v4 "
100
104
- name : " Setup environment"
101
105
uses : " networktocode/gh-action-setup-poetry-environment@v6"
106
+ - name : " Get image version"
107
+ run : " echo INVOKE_PARSER_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
102
113
with :
103
- poetry-install-options : " --with dev"
114
+ builder : " ${{ steps.buildx.outputs.name }}"
115
+ context : " ./"
116
+ push : false
117
+ load : true
118
+ tags : " ${{ env.INVOKE_PARSER_IMAGE_NAME }}:${{ env.INVOKE_PARSER_IMAGE_VER }}"
119
+ file : " ./Dockerfile"
120
+ cache-from : " type=gha,scope=${{ env.INVOKE_PARSER_IMAGE_NAME }}-${{ env.INVOKE_PARSER_IMAGE_VER }}-py${{ matrix.python-version }}"
121
+ cache-to : " type=gha,scope=${{ env.INVOKE_PARSER_IMAGE_NAME }}-${{ env.INVOKE_PARSER_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"
104
126
- name : " Linting: Pylint"
105
127
run : " poetry run invoke pylint"
106
128
needs :
107
- - " bandit"
108
- - " pydocstyle"
109
- - " flake8"
110
- - " yamllint"
111
- - " mypy"
112
- unittest :
129
+ - " poetry"
130
+ pytest :
113
131
strategy :
114
132
fail-fast : true
115
133
matrix :
116
134
python-version : ["3.9", "3.10", "3.11", "3.12"]
117
- pydantic : ["2.x"]
118
- include :
119
- - python-version : " 3.11"
120
- pydantic : " 1.x"
121
135
runs-on : " ubuntu-24.04"
122
136
env :
123
- INVOKE_LOCAL : " True"
124
137
PYTHON_VER : " ${{ matrix.python-version }}"
125
138
steps :
126
139
- name : " Check out repository code"
127
- uses : " actions/checkout@v3 "
140
+ uses : " actions/checkout@v4 "
128
141
- name : " Setup environment"
129
142
uses : " networktocode/gh-action-setup-poetry-environment@v6"
143
+ - name : " Get image version"
144
+ run : " echo INVOKE_PARSER_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
130
150
with :
131
- python-version : " ${{ matrix.python-version }}"
132
- poetry-install-options : " --all-extras"
133
- - name : " Run poetry Install"
134
- run : " poetry install"
135
- - name : " Run poetry Install"
136
- run : " pip install pydantic==1.10.13"
137
- if : matrix.pydantic == '1.x'
151
+ builder : " ${{ steps.buildx.outputs.name }}"
152
+ context : " ./"
153
+ push : false
154
+ load : true
155
+ tags : " ${{ env.INVOKE_PARSER_IMAGE_NAME }}:${{ env.INVOKE_PARSER_IMAGE_VER }}"
156
+ file : " ./Dockerfile"
157
+ cache-from : " type=gha,scope=${{ env.INVOKE_PARSER_IMAGE_NAME }}-${{ env.INVOKE_PARSER_IMAGE_VER }}-py${{ matrix.python-version }}"
158
+ cache-to : " type=gha,scope=${{ env.INVOKE_PARSER_IMAGE_NAME }}-${{ env.INVOKE_PARSER_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
- run : " poetry run invoke pytest --local "
164
+ run : " poetry run invoke pytest"
140
165
needs :
141
- - " pylint "
166
+ - " poetry "
142
167
publish_gh :
143
168
name : " Publish to GitHub"
144
169
runs-on : " ubuntu-24.04"
145
- if : " startsWith(github.ref, 'refs/tags/v')"
170
+ # yamllint disable-line rule:quoted-strings
171
+ if : startsWith(github.ref, 'refs/tags/v')
146
172
steps :
147
173
- name : " Check out repository code"
148
- uses : " actions/checkout@v3 "
174
+ uses : " actions/checkout@v4 "
149
175
- name : " Set up Python"
150
- uses : " actions/setup-python@v4 "
176
+ uses : " actions/setup-python@v5 "
151
177
with :
152
178
python-version : " 3.9"
153
179
- name : " Install Python Packages"
@@ -156,27 +182,26 @@ jobs:
156
182
run : " echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
157
183
- name : " Run Poetry Version"
158
184
run : " poetry version $RELEASE_VERSION"
185
+ - name : " Build Documentation"
186
+ run : " poetry run invoke build-and-check-docs"
159
187
- name : " Run Poetry Build"
160
188
run : " poetry build"
161
189
- 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
190
+ run : " gh release upload ${{ github.ref_name }} dist/*.{tar.gz,whl}"
191
+ env :
192
+ GH_TOKEN : " ${{ secrets.NTC_GITHUB_TOKEN }}"
169
193
needs :
170
- - " unittest "
194
+ - " pytest "
171
195
publish_pypi :
172
196
name : " Push Package to PyPI"
173
197
runs-on : " ubuntu-24.04"
174
- if : " startsWith(github.ref, 'refs/tags/v')"
198
+ # yamllint disable-line rule:quoted-strings
199
+ if : startsWith(github.ref, 'refs/tags/v')
175
200
steps :
176
201
- name : " Check out repository code"
177
- uses : " actions/checkout@v3 "
202
+ uses : " actions/checkout@v4 "
178
203
- name : " Set up Python"
179
- uses : " actions/setup-python@v4 "
204
+ uses : " actions/setup-python@v5 "
180
205
with :
181
206
python-version : " 3.9"
182
207
- name : " Install Python Packages"
@@ -188,17 +213,16 @@ jobs:
188
213
- name : " Run Poetry Build"
189
214
run : " poetry build"
190
215
- name : " Push to PyPI"
191
- uses : " pypa/gh-action-pypi-publish@release/v1 "
216
+ uses : " pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc " # v1.12.4
192
217
with :
193
218
user : " __token__"
194
219
password : " ${{ secrets.PYPI_API_TOKEN }}"
195
220
needs :
196
- - " unittest "
221
+ - " pytest "
197
222
slack-notify :
198
223
needs :
199
224
- " publish_gh"
200
225
- " publish_pypi"
201
- name : " Send notification to the Slack"
202
226
runs-on : " ubuntu-24.04"
203
227
env :
204
228
SLACK_WEBHOOK_URL : " ${{ secrets.SLACK_WEBHOOK_URL }}"
@@ -211,8 +235,8 @@ jobs:
211
235
- name : " Send a notification to Slack"
212
236
# ENVs cannot be used directly in job.if. This is a workaround to check
213
237
# if SLACK_WEBHOOK_URL is present.
214
- if : " ${{ env.SLACK_WEBHOOK_URL != '' }} "
215
- uses : " slackapi/slack-github-action@v1.23.0 "
238
+ if : " env.SLACK_WEBHOOK_URL != ''"
239
+ uses : " slackapi/slack-github-action@fcfb566f8b0aab22203f066d80ca1d7e4b5d05b3 " # v1.27.1
216
240
with :
217
241
payload : |
218
242
{
0 commit comments