@@ -81,12 +81,26 @@ jobs:
8181 poetry-version : " 1.8.5"
8282 - name : " Linting: yamllint"
8383 run : " poetry run invoke yamllint"
84+ markdownlint :
85+ runs-on : " ubuntu-22.04"
86+ env :
87+ INVOKE_NAUTOBOT_SSOT_LOCAL : " True"
88+ steps :
89+ - name : " Check out repository code"
90+ uses : " actions/checkout@v4"
91+ - name : " Setup environment"
92+ uses : " networktocode/gh-action-setup-poetry-environment@v6"
93+ with :
94+ poetry-version : " 1.8.5"
95+ - name : " Linting: markdownlint"
96+ run : " poetry run invoke markdownlint"
8497 check-in-docker :
8598 needs :
8699 - " ruff-format"
87100 - " ruff-lint"
88101 - " poetry"
89102 - " yamllint"
103+ - " markdownlint"
90104 runs-on : " ubuntu-22.04"
91105 strategy :
92106 fail-fast : true
@@ -111,9 +125,9 @@ jobs:
111125 run : " poetry run invoke lock --constrain-nautobot-ver --constrain-python-ver"
112126 - name : " Set up Docker Buildx"
113127 id : " buildx"
114- uses : " docker/setup-buildx-action@v3 "
128+ uses : " docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 " # v3.10.0
115129 - name : " Build"
116- uses : " docker/build-push-action@v5 "
130+ uses : " docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 " # v5.4.0
117131 with :
118132 builder : " ${{ steps.buildx.outputs.name }}"
119133 context : " ./"
@@ -127,8 +141,6 @@ jobs:
127141 NAUTOBOT_VER=${{ matrix.nautobot-version }}
128142 PYTHON_VER=${{ matrix.python-version }}
129143 CI=true
130- - name : " Copy credentials"
131- run : " cp development/creds.example.env development/creds.env"
132144 - name : " Linting: pylint"
133145 run : " poetry run invoke pylint"
134146 - name : " Checking: App Config"
@@ -141,7 +153,7 @@ jobs:
141153 strategy :
142154 fail-fast : true
143155 matrix :
144- python-version : ["3.9", " 3.12"]
156+ python-version : ["3.9"] # 3.12 stable is tested in unittest_report stage.
145157 db-backend : ["postgresql"]
146158 nautobot-version : ["stable"]
147159 include :
@@ -170,9 +182,60 @@ jobs:
170182 run : " poetry run invoke lock --constrain-nautobot-ver --constrain-python-ver"
171183 - name : " Set up Docker Buildx"
172184 id : " buildx"
173- uses : " docker/setup-buildx-action@v3"
185+ uses : " docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2" # v3.10.0
186+ - name : " Build"
187+ uses : " docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25" # v5.4.0
188+ with :
189+ builder : " ${{ steps.buildx.outputs.name }}"
190+ context : " ./"
191+ push : false
192+ load : true
193+ tags : " ${{ env.APP_NAME }}/nautobot:${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
194+ file : " ./development/Dockerfile"
195+ cache-from : " type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
196+ cache-to : " type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
197+ build-args : |
198+ NAUTOBOT_VER=${{ matrix.nautobot-version }}
199+ PYTHON_VER=${{ matrix.python-version }}
200+ CI=true
201+ - name : " Use Mysql invoke settings when needed"
202+ run : " cp invoke.mysql.yml invoke.yml"
203+ if : " matrix.db-backend == 'mysql'"
204+ - name : " Run Tests"
205+ run : " poetry run invoke unittest"
206+
207+ unittest_report :
208+ needs :
209+ - " check-in-docker"
210+ strategy :
211+ fail-fast : true
212+ matrix :
213+ python-version : ["3.12"]
214+ db-backend : ["postgresql"]
215+ nautobot-version : ["stable"]
216+ runs-on : " ubuntu-22.04"
217+ permissions :
218+ pull-requests : " write"
219+ contents : " write"
220+ env :
221+ INVOKE_NAUTOBOT_SSOT_PYTHON_VER : " ${{ matrix.python-version }}"
222+ INVOKE_NAUTOBOT_SSOT_NAUTOBOT_VER : " ${{ matrix.nautobot-version }}"
223+ steps :
224+ - name : " Check out repository code"
225+ uses : " actions/checkout@v4"
226+ - name : " Setup environment"
227+ uses : " networktocode/gh-action-setup-poetry-environment@v6"
228+ with :
229+ poetry-version : " 1.8.5"
230+ - name : " Constrain Nautobot version and regenerate lock file"
231+ env :
232+ INVOKE_NAUTOBOT_SSOT_LOCAL : " true"
233+ run : " poetry run invoke lock --constrain-nautobot-ver --constrain-python-ver"
234+ - name : " Set up Docker Buildx"
235+ id : " buildx"
236+ uses : " docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2" # v3.10.0
174237 - name : " Build"
175- uses : " docker/build-push-action@v5 "
238+ uses : " docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 " # v5.4.0
176239 with :
177240 builder : " ${{ steps.buildx.outputs.name }}"
178241 context : " ./"
@@ -192,7 +255,28 @@ jobs:
192255 run : " cp invoke.mysql.yml invoke.yml"
193256 if : " matrix.db-backend == 'mysql'"
194257 - name : " Run Tests"
195- run : " poetry run invoke unittest"
258+ run : " poetry run invoke unittest --coverage"
259+ - name : " Generate Coverage Comment"
260+ if : >
261+ contains(fromJson('["develop","ltm-1.6"]'), github.base_ref) &&
262+ (github.head_ref != 'main') && (!startsWith(github.head_ref, 'release'))
263+ id : " coverage_comment"
264+ uses : " py-cov-action/python-coverage-comment-action@d1ff8fbb5ff80feedb3faa0f6d7b424f417ad0e1" # v3.30
265+ with :
266+ GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
267+ MINIMUM_GREEN : 90
268+ MINIMUM_ORANGE : 80
269+ ANNOTATE_MISSING_LINES : true
270+ ANNOTATION_TYPE : " warning"
271+ - name : " Store Pull Request comment to be posted"
272+ if : >
273+ contains(fromJson('["develop","ltm-1.6"]'), github.base_ref) &&
274+ (github.head_ref != 'main') && (!startsWith(github.head_ref, 'release'))
275+ uses : " actions/upload-artifact@v4"
276+ with :
277+ name : " python-coverage-comment-action"
278+ path : " python-coverage-comment-action.txt"
279+
196280 changelog :
197281 if : >
198282 contains(fromJson('["develop","ltm-1.6"]'), github.base_ref) &&
@@ -214,41 +298,39 @@ jobs:
214298 publish_gh :
215299 needs :
216300 - " unittest"
301+ - " unittest_report"
217302 name : " Publish to GitHub"
218303 runs-on : " ubuntu-22.04"
219304 if : " startsWith(github.ref, 'refs/tags/v')"
220305 env :
221306 INVOKE_NAUTOBOT_SSOT_LOCAL : " True"
307+ permissions :
308+ contents : " write"
222309 steps :
223310 - name : " Check out repository code"
224311 uses : " actions/checkout@v4"
225- - name : " Set up Python "
226- uses : " actions/ setup-python@v5 "
312+ - name : " Setup environment "
313+ uses : " networktocode/gh-action- setup-poetry-environment@v6 "
227314 with :
315+ poetry-version : " 1.8.5"
228316 python-version : " 3.12"
229- - name : " Install Python Packages"
230- run : " pip install poetry"
317+ poetry-install-options : " --no-root"
231318 - name : " Set env"
232319 run : " echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
233320 - name : " Run Poetry Version"
234321 run : " poetry version $RELEASE_VERSION"
235- - name : " Install Dependencies (needed for mkdocs)"
236- run : " poetry install --no-root"
237322 - name : " Build Documentation"
238323 run : " poetry run invoke build-and-check-docs"
239324 - name : " Run Poetry Build"
240325 run : " poetry build"
241326 - name : " Upload binaries to release"
242- uses : " svenstaro/upload-release-action@v2"
243- with :
244- repo_token : " ${{ secrets.GH_NAUTOBOT_BOT_TOKEN }}"
245- file : " dist/*"
246- tag : " ${{ github.ref }}"
247- overwrite : true
248- file_glob : true
327+ run : " gh release upload ${{ github.ref_name }} dist/*.{tar.gz,whl}"
328+ env :
329+ GH_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
249330 publish_pypi :
250331 needs :
251332 - " unittest"
333+ - " unittest_report"
252334 name : " Push Package to PyPI"
253335 runs-on : " ubuntu-22.04"
254336 if : " startsWith(github.ref, 'refs/tags/v')"
@@ -257,24 +339,22 @@ jobs:
257339 steps :
258340 - name : " Check out repository code"
259341 uses : " actions/checkout@v4"
260- - name : " Set up Python "
261- uses : " actions/ setup-python@v5 "
342+ - name : " Setup environment "
343+ uses : " networktocode/gh-action- setup-poetry-environment@v6 "
262344 with :
345+ poetry-version : " 1.8.5"
263346 python-version : " 3.12"
264- - name : " Install Python Packages"
265- run : " pip install poetry"
347+ poetry-install-options : " --no-root"
266348 - name : " Set env"
267349 run : " echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
268350 - name : " Run Poetry Version"
269351 run : " poetry version $RELEASE_VERSION"
270- - name : " Install Dependencies (needed for mkdocs)"
271- run : " poetry install --no-root"
272352 - name : " Build Documentation"
273353 run : " poetry run invoke build-and-check-docs"
274354 - name : " Run Poetry Build"
275355 run : " poetry build"
276356 - name : " Push to PyPI"
277- uses : " pypa/gh-action-pypi-publish@release/v1 "
357+ uses : " pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc " # v1.12.4
278358 with :
279359 user : " __token__"
280360 password : " ${{ secrets.PYPI_API_TOKEN }}"
@@ -295,7 +375,7 @@ jobs:
295375 # ENVs cannot be used directly in job.if. This is a workaround to check
296376 # if SLACK_WEBHOOK_URL is present.
297377 if : " env.SLACK_WEBHOOK_URL != ''"
298- uses : " slackapi/slack-github-action@v1 "
378+ uses : " slackapi/slack-github-action@fcfb566f8b0aab22203f066d80ca1d7e4b5d05b3 " # v1.27.1
299379 with :
300380 payload : |
301381 {
0 commit comments