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 :
20+ ruff-format :
2721 runs-on : " ubuntu-24.04"
2822 env :
29- INVOKE_LOCAL : " True"
23+ INVOKE_JDIFF_LOCAL : " True"
3024 steps :
3125 - name : " Check out repository code"
3226 uses : " actions/checkout@v4"
3327 - name : " Setup environment"
3428 uses : " networktocode/gh-action-setup-poetry-environment@v6"
3529 with :
3630 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 :
4034 runs-on : " ubuntu-24.04"
4135 env :
42- INVOKE_LOCAL : " True"
36+ INVOKE_JDIFF_LOCAL : " True"
4337 steps :
4438 - name : " Check out repository code"
4539 uses : " actions/checkout@v4"
4640 - name : " Setup environment"
4741 uses : " networktocode/gh-action-setup-poetry-environment@v6"
4842 with :
4943 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 :
5361 runs-on : " ubuntu-24.04"
5462 env :
55- INVOKE_LOCAL : " True"
63+ INVOKE_JDIFF_LOCAL : " True"
5664 steps :
5765 - name : " Check out repository code"
5866 uses : " actions/checkout@v4"
5967 - name : " Setup environment"
6068 uses : " networktocode/gh-action-setup-poetry-environment@v6"
6169 with :
6270 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"
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,61 +87,106 @@ 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"
140- publish_gh :
141165 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 :
143186 name : " Publish to GitHub"
144187 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')
146190 steps :
147191 - name : " Check out repository code"
148192 uses : " actions/checkout@v4"
@@ -156,22 +200,21 @@ jobs:
156200 run : " echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
157201 - name : " Run Poetry Version"
158202 run : " poetry version $RELEASE_VERSION"
203+ - name : " Build Documentation"
204+ run : " poetry run invoke build-and-check-docs"
159205 - name : " Run Poetry Build"
160206 run : " poetry build"
161207 - 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 }}"
170211 needs :
171212 - " pytest"
213+ publish_pypi :
172214 name : " Push Package to PyPI"
173215 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')
175218 steps :
176219 - name : " Check out repository code"
177220 uses : " actions/checkout@v4"
@@ -188,15 +231,16 @@ jobs:
188231 - name : " Run Poetry Build"
189232 run : " poetry build"
190233 - name : " Push to PyPI"
191- uses : " pypa/gh-action-pypi-publish@release/v1 "
234+ uses : " pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc " # v1.12.4
192235 with :
193236 user : " __token__"
194237 password : " ${{ secrets.PYPI_API_TOKEN }}"
238+ needs :
239+ - " pytest"
195240 slack-notify :
196241 needs :
197242 - " publish_gh"
198243 - " publish_pypi"
199- name : " Send notification to the Slack"
200244 runs-on : " ubuntu-24.04"
201245 env :
202246 SLACK_WEBHOOK_URL : " ${{ secrets.SLACK_WEBHOOK_URL }}"
@@ -209,8 +253,8 @@ jobs:
209253 - name : " Send a notification to Slack"
210254 # ENVs cannot be used directly in job.if. This is a workaround to check
211255 # 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
214258 with :
215259 payload : |
216260 {
0 commit comments