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,89 @@ 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+ mypy :
5347 runs-on : " ubuntu-24.04"
5448 env :
55- INVOKE_LOCAL : " True"
49+ INVOKE_JDIFF_LOCAL : " True"
5650 steps :
5751 - name : " Check out repository code"
5852 uses : " actions/checkout@v4"
5953 - name : " Setup environment"
6054 uses : " networktocode/gh-action-setup-poetry-environment@v6"
6155 with :
62- poetry-version : " 1.8.5"
63- - name : " Linting: pydocstyle"
64- run : " poetry run invoke pydocstyle"
65- flake8 :
56+ python-version : " 3.13"
57+ - name : " Type-Hints: mypy"
58+ run : " poetry run invoke mypy"
59+ needs :
60+ - " ruff-format"
61+ - " ruff-lint"
62+ # Temporarily disabled due to issues with the docs build and needing best practices for NTC python builds.
63+ # check-docs-build:
64+ # runs-on: "ubuntu-24.04"
65+ # env:
66+ # INVOKE_JDIFF_LOCAL: "True"
67+ # steps:
68+ # - name: "Check out repository code"
69+ # uses: "actions/checkout@v4"
70+ # - name: "Setup environment"
71+ # uses: "networktocode/gh-action-setup-poetry-environment@v6"
72+ # with:
73+ # poetry-version: "1.8.5"
74+ # - name: "Check Docs Build"
75+ # run: "poetry run invoke build-and-check-docs"
76+ poetry :
6677 runs-on : " ubuntu-24.04"
6778 env :
68- INVOKE_LOCAL : " True"
79+ INVOKE_JDIFF_LOCAL : " True"
6980 steps :
7081 - name : " Check out repository code"
7182 uses : " actions/checkout@v4"
7283 - name : " Setup environment"
7384 uses : " networktocode/gh-action-setup-poetry-environment@v6"
7485 with :
7586 poetry-version : " 1.8.5"
76- - name : " Linting: flake8"
77- run : " poetry run invoke flake8"
87+ - name : " Checking: poetry lock file"
88+ run : " poetry lock --check"
89+ needs :
90+ - " ruff-format"
91+ - " ruff-lint"
92+ - " mypy"
93+ - " yamllint"
7894 yamllint :
7995 runs-on : " ubuntu-24.04"
8096 env :
81- INVOKE_LOCAL : " True"
97+ INVOKE_JDIFF_LOCAL : " True"
8298 steps :
8399 - name : " Check out repository code"
84100 uses : " actions/checkout@v4"
@@ -88,61 +104,88 @@ jobs:
88104 poetry-version : " 1.8.5"
89105 - name : " Linting: yamllint"
90106 run : " poetry run invoke yamllint"
91- pylint :
92107 needs :
93- - " bandit"
94- - " pydocstyle"
95- - " flake8"
96- - " yamllint"
97- - " black"
98- - " mypy"
108+ - " ruff-format"
109+ - " ruff-lint"
110+ pylint :
99111 runs-on : " ubuntu-24.04"
100112 strategy :
101113 fail-fast : true
102114 matrix :
103- python-version : ["3.8 "]
115+ python-version : ["3.9", "3.10", "3.11", "3.12", "3.13 "]
104116 env :
105117 PYTHON_VER : " ${{ matrix.python-version }}"
106- INVOKE_LOCAL : " True"
107118 steps :
108119 - name : " Check out repository code"
109120 uses : " actions/checkout@v4"
110121 - name : " Setup environment"
111122 uses : " networktocode/gh-action-setup-poetry-environment@v6"
123+ - name : " Get image version"
124+ run : " echo INVOKE_JDIFF_IMAGE_VER=`poetry version -s`-py${{ matrix.python-version }} >> $GITHUB_ENV"
125+ - name : " Set up Docker Buildx"
126+ id : " buildx"
127+ uses : " docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2" # v3.10.0
128+ - name : " Build"
129+ uses : " docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25" # v5.4.0
112130 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 : " "
131+ builder : " ${{ steps.buildx.outputs.name }}"
132+ context : " ./"
133+ push : false
134+ load : true
135+ tags : " ${{ env.INVOKE_JDIFF_IMAGE_NAME }}:${{ env.INVOKE_JDIFF_IMAGE_VER }}"
136+ file : " ./Dockerfile"
137+ cache-from : " type=gha,scope=${{ env.INVOKE_JDIFF_IMAGE_NAME }}-${{ env.INVOKE_JDIFF_IMAGE_VER }}-py${{ matrix.python-version }}"
138+ cache-to : " type=gha,scope=${{ env.INVOKE_JDIFF_IMAGE_NAME }}-${{ env.INVOKE_JDIFF_IMAGE_VER }}-py${{ matrix.python-version }}"
139+ build-args : |
140+ PYTHON_VER=${{ env.PYTHON_VER }}
141+ - name : " Debug: Show docker images"
142+ run : " docker image ls"
116143 - name : " Linting: Pylint"
117144 run : " poetry run invoke pylint"
118- pytest :
119145 needs :
120- - " pylint"
146+ - " poetry"
147+ pytest :
121148 strategy :
122149 fail-fast : true
123150 matrix :
124- python-version : ["3.8 ", "3.9 ", "3.10 ", "3.11 "]
151+ python-version : ["3.9 ", "3.10 ", "3.11 ", "3.12", "3.13 "]
125152 runs-on : " ubuntu-24.04"
126153 env :
127154 PYTHON_VER : " ${{ matrix.python-version }}"
128- INVOKE_LOCAL : " True"
129155 steps :
130156 - name : " Check out repository code"
131157 uses : " actions/checkout@v4"
132158 - name : " Setup environment"
133159 uses : " networktocode/gh-action-setup-poetry-environment@v6"
160+ - name : " Get image version"
161+ run : " echo INVOKE_JDIFF_IMAGE_VER=`poetry version -s`-py${{ matrix.python-version }} >> $GITHUB_ENV"
162+ - name : " Set up Docker Buildx"
163+ id : " buildx"
164+ uses : " docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2" # v3.10.0
165+ - name : " Build"
166+ uses : " docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25" # v5.4.0
134167 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 : " "
168+ builder : " ${{ steps.buildx.outputs.name }}"
169+ context : " ./"
170+ push : false
171+ load : true
172+ tags : " ${{ env.INVOKE_JDIFF_IMAGE_NAME }}:${{ env.INVOKE_JDIFF_IMAGE_VER }}"
173+ file : " ./Dockerfile"
174+ cache-from : " type=gha,scope=${{ env.INVOKE_JDIFF_IMAGE_NAME }}-${{ env.INVOKE_JDIFF_IMAGE_VER }}-py${{ matrix.python-version }}"
175+ cache-to : " type=gha,scope=${{ env.INVOKE_JDIFF_IMAGE_NAME }}-${{ env.INVOKE_JDIFF_IMAGE_VER }}-py${{ matrix.python-version }}"
176+ build-args : |
177+ PYTHON_VER=${{ env.PYTHON_VER }}
178+ - name : " Debug: Show docker images"
179+ run : " docker image ls"
138180 - name : " Run Tests"
139181 run : " poetry run invoke pytest"
140- publish_gh :
141182 needs :
142- - " pytest"
183+ - " poetry"
184+ publish_gh :
143185 name : " Publish to GitHub"
144186 runs-on : " ubuntu-24.04"
145- if : " startsWith(github.ref, 'refs/tags/v')"
187+ # yamllint disable-line rule:quoted-strings
188+ if : startsWith(github.ref, 'refs/tags/v')
146189 steps :
147190 - name : " Check out repository code"
148191 uses : " actions/checkout@v4"
@@ -156,22 +199,21 @@ jobs:
156199 run : " echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
157200 - name : " Run Poetry Version"
158201 run : " poetry version $RELEASE_VERSION"
202+ - name : " Build Documentation"
203+ run : " poetry run invoke build-and-check-docs"
159204 - name : " Run Poetry Build"
160205 run : " poetry build"
161206 - 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 :
207+ run : " gh release upload ${{ github.ref_name }} dist/*.{tar.gz,whl}"
208+ env :
209+ GH_TOKEN : " ${{ secrets.NTC_GITHUB_TOKEN }}"
170210 needs :
171211 - " pytest"
212+ publish_pypi :
172213 name : " Push Package to PyPI"
173214 runs-on : " ubuntu-24.04"
174- if : " startsWith(github.ref, 'refs/tags/v')"
215+ # yamllint disable-line rule:quoted-strings
216+ if : startsWith(github.ref, 'refs/tags/v')
175217 steps :
176218 - name : " Check out repository code"
177219 uses : " actions/checkout@v4"
@@ -188,15 +230,16 @@ jobs:
188230 - name : " Run Poetry Build"
189231 run : " poetry build"
190232 - name : " Push to PyPI"
191- uses : " pypa/gh-action-pypi-publish@release/v1 "
233+ uses : " pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc " # v1.12.4
192234 with :
193235 user : " __token__"
194236 password : " ${{ secrets.PYPI_API_TOKEN }}"
237+ needs :
238+ - " pytest"
195239 slack-notify :
196240 needs :
197241 - " publish_gh"
198242 - " publish_pypi"
199- name : " Send notification to the Slack"
200243 runs-on : " ubuntu-24.04"
201244 env :
202245 SLACK_WEBHOOK_URL : " ${{ secrets.SLACK_WEBHOOK_URL }}"
@@ -209,8 +252,8 @@ jobs:
209252 - name : " Send a notification to Slack"
210253 # ENVs cannot be used directly in job.if. This is a workaround to check
211254 # if SLACK_WEBHOOK_URL is present.
212- if : " ${{ env.SLACK_WEBHOOK_URL != '' }} "
213- uses : " slackapi/slack-github-action@v1.17.0 "
255+ if : " env.SLACK_WEBHOOK_URL != ''"
256+ uses : " slackapi/slack-github-action@fcfb566f8b0aab22203f066d80ca1d7e4b5d05b3 " # v1.27.1
214257 with :
215258 payload : |
216259 {
0 commit comments