11---
22name : " 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
47 push :
58 branches :
69 - " main"
@@ -9,76 +12,72 @@ on: # yamllint disable-line rule:truthy rule:comments
912 - " v*"
1013 pull_request : ~
1114
15+ env :
16+ INVOKE_JDIFF_IMAGE_NAME : " jdiff"
17+ INVOKE_JDIFF_IMAGE_VER : " latest"
18+
1219jobs :
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 :
4021 runs-on : " ubuntu-24.04"
4122 env :
42- INVOKE_LOCAL : " True"
23+ INVOKE_JDIFF_LOCAL : " True"
4324 steps :
4425 - name : " Check out repository code"
4526 uses : " actions/checkout@v4"
4627 - name : " Setup environment"
4728 uses : " networktocode/gh-action-setup-poetry-environment@v6"
4829 with :
4930 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 :
5334 runs-on : " ubuntu-24.04"
5435 env :
55- INVOKE_LOCAL : " True"
36+ INVOKE_JDIFF_LOCAL : " True"
5637 steps :
5738 - name : " Check out repository code"
5839 uses : " actions/checkout@v4"
5940 - name : " Setup environment"
6041 uses : " networktocode/gh-action-setup-poetry-environment@v6"
6142 with :
6243 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 :
6661 runs-on : " ubuntu-24.04"
6762 env :
68- INVOKE_LOCAL : " True"
63+ INVOKE_JDIFF_LOCAL : " True"
6964 steps :
7065 - name : " Check out repository code"
7166 uses : " actions/checkout@v4"
7267 - name : " Setup environment"
7368 uses : " networktocode/gh-action-setup-poetry-environment@v6"
7469 with :
7570 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"
7877 yamllint :
7978 runs-on : " ubuntu-24.04"
8079 env :
81- INVOKE_LOCAL : " True"
80+ INVOKE_JDIFF_LOCAL : " True"
8281 steps :
8382 - name : " Check out repository code"
8483 uses : " actions/checkout@v4"
@@ -88,55 +87,83 @@ jobs:
8887 poetry-version : " 1.8.5"
8988 - name : " Linting: yamllint"
9089 run : " poetry run invoke yamllint"
91- pylint :
9290 needs :
93- - " bandit"
94- - " pydocstyle"
95- - " flake8"
96- - " yamllint"
97- - " black"
98- - " mypy"
91+ - " ruff-format"
92+ - " ruff-lint"
93+ pylint :
9994 runs-on : " ubuntu-24.04"
10095 strategy :
10196 fail-fast : true
10297 matrix :
103- python-version : ["3.8 "]
98+ python-version : ["3.9", "3.10", "3.11", "3.12", "3.13 "]
10499 env :
105100 PYTHON_VER : " ${{ matrix.python-version }}"
106- INVOKE_LOCAL : " True"
107101 steps :
108102 - name : " Check out repository code"
109103 uses : " actions/checkout@v4"
110104 - name : " Setup environment"
111105 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
112113 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"
116126 - name : " Linting: Pylint"
117127 run : " poetry run invoke pylint"
118- pytest :
119128 needs :
120- - " pylint"
129+ - " poetry"
130+ pytest :
121131 strategy :
122132 fail-fast : true
123133 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 "]
125135 runs-on : " ubuntu-24.04"
126136 env :
127137 PYTHON_VER : " ${{ matrix.python-version }}"
128- INVOKE_LOCAL : " True"
129138 steps :
130139 - name : " Check out repository code"
131140 uses : " actions/checkout@v4"
132141 - name : " Setup environment"
133142 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
134150 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"
138163 - name : " Run Tests"
139164 run : " poetry run invoke pytest"
165+ needs :
166+ - " poetry"
140167 changelog :
141168 if : >
142169 contains(fromJson('["develop"]'), github.base_ref) &&
@@ -156,11 +183,10 @@ jobs:
156183 git fetch --no-tags origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
157184 poetry run towncrier check --compare-with origin/${{ github.base_ref }}
158185 publish_gh :
159- needs :
160- - " pytest"
161186 name : " Publish to GitHub"
162187 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')
164190 steps :
165191 - name : " Check out repository code"
166192 uses : " actions/checkout@v4"
@@ -174,22 +200,21 @@ jobs:
174200 run : " echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
175201 - name : " Run Poetry Version"
176202 run : " poetry version $RELEASE_VERSION"
203+ - name : " Build Documentation"
204+ run : " poetry run invoke build-and-check-docs"
177205 - name : " Run Poetry Build"
178206 run : " poetry build"
179207 - 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 }}"
188211 needs :
189212 - " pytest"
213+ publish_pypi :
190214 name : " Push Package to PyPI"
191215 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')
193218 steps :
194219 - name : " Check out repository code"
195220 uses : " actions/checkout@v4"
@@ -206,15 +231,16 @@ jobs:
206231 - name : " Run Poetry Build"
207232 run : " poetry build"
208233 - name : " Push to PyPI"
209- uses : " pypa/gh-action-pypi-publish@release/v1 "
234+ uses : " pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc " # v1.12.4
210235 with :
211236 user : " __token__"
212237 password : " ${{ secrets.PYPI_API_TOKEN }}"
238+ needs :
239+ - " pytest"
213240 slack-notify :
214241 needs :
215242 - " publish_gh"
216243 - " publish_pypi"
217- name : " Send notification to the Slack"
218244 runs-on : " ubuntu-24.04"
219245 env :
220246 SLACK_WEBHOOK_URL : " ${{ secrets.SLACK_WEBHOOK_URL }}"
@@ -227,8 +253,8 @@ jobs:
227253 - name : " Send a notification to Slack"
228254 # ENVs cannot be used directly in job.if. This is a workaround to check
229255 # 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
232258 with :
233259 payload : |
234260 {
0 commit comments