11---
22name : " CI"
33concurrency : # Cancel any existing runs of this workflow for this same PR
4- group : " ${{ github.workflow }}-${{ github.ref }}"
4+ group : " ${{ '{{ github.workflow }}' }} -${{ '{{ github.ref }}' }}"
55 cancel-in-progress : true
6- on : # yamllint disable
6+ on : # yamllint disable-line rule:truthy rule:comments
77 push :
88 branches :
99 - " main"
1010 - " develop"
1111 tags :
1212 - " v*"
1313 pull_request : ~
14+
15+ env :
16+ INVOKE_PARSER_IMAGE_NAME : " circuit_maintenance_parser"
17+ INVOKE_PARSER_IMAGE_VER : " latest"
18+
1419jobs :
15- black :
20+ ruff-format :
1621 runs-on : " ubuntu-24.04"
1722 env :
18- INVOKE_LOCAL : " True"
23+ INVOKE_PARSER_LOCAL : " True"
1924 steps :
2025 - name : " Check out repository code"
21- uses : " actions/checkout@v3 "
26+ uses : " actions/checkout@v4 "
2227 - name : " Setup environment"
2328 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 :
5334 runs-on : " ubuntu-24.04"
5435 env :
55- INVOKE_LOCAL : " True"
36+ INVOKE_PARSER_LOCAL : " True"
5637 steps :
5738 - name : " Check out repository code"
58- uses : " actions/checkout@v3 "
39+ uses : " actions/checkout@v4 "
5940 - name : " Setup environment"
6041 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 :
6661 runs-on : " ubuntu-24.04"
6762 env :
68- INVOKE_LOCAL : " True"
63+ INVOKE_PARSER_LOCAL : " True"
6964 steps :
7065 - name : " Check out repository code"
71- uses : " actions/checkout@v3 "
66+ uses : " actions/checkout@v4 "
7267 - name : " Setup environment"
7368 uses : " networktocode/gh-action-setup-poetry-environment@v6"
7469 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 "
7873 needs :
79- - " black"
74+ - " ruff-format"
75+ - " ruff-lint"
76+ - " yamllint"
8077 yamllint :
8178 runs-on : " ubuntu-24.04"
8279 env :
83- INVOKE_LOCAL : " True"
80+ INVOKE_PARSER_LOCAL : " True"
8481 steps :
8582 - name : " Check out repository code"
86- uses : " actions/checkout@v3 "
83+ uses : " actions/checkout@v4 "
8784 - name : " Setup environment"
8885 uses : " networktocode/gh-action-setup-poetry-environment@v6"
86+ with :
87+ poetry-version : " 1.8.5"
8988 - name : " Linting: yamllint"
9089 run : " poetry run invoke yamllint"
9190 needs :
92- - " black"
91+ - " ruff-format"
92+ - " ruff-lint"
9393 pylint :
9494 runs-on : " ubuntu-24.04"
95+ strategy :
96+ fail-fast : true
97+ matrix :
98+ python-version : ["3.9", "3.10", "3.11", "3.12"]
9599 env :
96- INVOKE_LOCAL : " True "
100+ PYTHON_VER : " ${{ matrix.python-version }} "
97101 steps :
98102 - name : " Check out repository code"
99- uses : " actions/checkout@v3 "
103+ uses : " actions/checkout@v4 "
100104 - name : " Setup environment"
101105 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
102113 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"
104126 - name : " Linting: Pylint"
105127 run : " poetry run invoke pylint"
106128 needs :
107- - " bandit"
108- - " pydocstyle"
109- - " flake8"
110- - " yamllint"
111- - " mypy"
112- unittest :
129+ - " poetry"
130+ pytest :
113131 strategy :
114132 fail-fast : true
115133 matrix :
116134 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"
121135 runs-on : " ubuntu-24.04"
122136 env :
123- INVOKE_LOCAL : " True"
124137 PYTHON_VER : " ${{ matrix.python-version }}"
125138 steps :
126139 - name : " Check out repository code"
127- uses : " actions/checkout@v3 "
140+ uses : " actions/checkout@v4 "
128141 - name : " Setup environment"
129142 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
130150 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"
138163 - name : " Run Tests"
139- run : " poetry run invoke pytest --local "
164+ run : " poetry run invoke pytest"
140165 needs :
141- - " pylint "
166+ - " poetry "
142167 publish_gh :
143168 name : " Publish to GitHub"
144169 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')
146172 steps :
147173 - name : " Check out repository code"
148- uses : " actions/checkout@v3 "
174+ uses : " actions/checkout@v4 "
149175 - name : " Set up Python"
150- uses : " actions/setup-python@v4 "
176+ uses : " actions/setup-python@v5 "
151177 with :
152178 python-version : " 3.9"
153179 - name : " Install Python Packages"
@@ -156,27 +182,26 @@ jobs:
156182 run : " echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
157183 - name : " Run Poetry Version"
158184 run : " poetry version $RELEASE_VERSION"
185+ - name : " Build Documentation"
186+ run : " poetry run invoke build-and-check-docs"
159187 - name : " Run Poetry Build"
160188 run : " poetry build"
161189 - 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 }}"
169193 needs :
170- - " unittest "
194+ - " pytest "
171195 publish_pypi :
172196 name : " Push Package to PyPI"
173197 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')
175200 steps :
176201 - name : " Check out repository code"
177- uses : " actions/checkout@v3 "
202+ uses : " actions/checkout@v4 "
178203 - name : " Set up Python"
179- uses : " actions/setup-python@v4 "
204+ uses : " actions/setup-python@v5 "
180205 with :
181206 python-version : " 3.9"
182207 - name : " Install Python Packages"
@@ -188,17 +213,16 @@ jobs:
188213 - name : " Run Poetry Build"
189214 run : " poetry build"
190215 - name : " Push to PyPI"
191- uses : " pypa/gh-action-pypi-publish@release/v1 "
216+ uses : " pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc " # v1.12.4
192217 with :
193218 user : " __token__"
194219 password : " ${{ secrets.PYPI_API_TOKEN }}"
195220 needs :
196- - " unittest "
221+ - " pytest "
197222 slack-notify :
198223 needs :
199224 - " publish_gh"
200225 - " publish_pypi"
201- name : " Send notification to the Slack"
202226 runs-on : " ubuntu-24.04"
203227 env :
204228 SLACK_WEBHOOK_URL : " ${{ secrets.SLACK_WEBHOOK_URL }}"
@@ -211,8 +235,8 @@ jobs:
211235 - name : " Send a notification to Slack"
212236 # ENVs cannot be used directly in job.if. This is a workaround to check
213237 # 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
216240 with :
217241 payload : |
218242 {
0 commit comments