@@ -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_BGP_MODELS_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
@@ -109,9 +123,9 @@ jobs:
109123 run : " poetry run invoke lock --constrain-nautobot-ver --constrain-python-ver"
110124 - name : " Set up Docker Buildx"
111125 id : " buildx"
112- uses : " docker/setup-buildx-action@v3 "
126+ uses : " docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 " # v3.10.0
113127 - name : " Build"
114- uses : " docker/build-push-action@v5 "
128+ uses : " docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 " # v5.4.0
115129 with :
116130 builder : " ${{ steps.buildx.outputs.name }}"
117131 context : " ./"
@@ -125,8 +139,6 @@ jobs:
125139 NAUTOBOT_VER=${{ matrix.nautobot-version }}
126140 PYTHON_VER=${{ matrix.python-version }}
127141 CI=true
128- - name : " Copy credentials"
129- run : " cp development/creds.example.env development/creds.env"
130142 - name : " Linting: pylint"
131143 run : " poetry run invoke pylint"
132144 - name : " Checking: App Config"
@@ -139,7 +151,7 @@ jobs:
139151 strategy :
140152 fail-fast : true
141153 matrix :
142- python-version : ["3.8", " 3.12"]
154+ python-version : ["3.8"] # 3.12 stable is tested in unittest_report stage.
143155 db-backend : ["postgresql"]
144156 nautobot-version : ["stable"]
145157 include :
@@ -166,9 +178,60 @@ jobs:
166178 run : " poetry run invoke lock --constrain-nautobot-ver --constrain-python-ver"
167179 - name : " Set up Docker Buildx"
168180 id : " buildx"
169- uses : " docker/setup-buildx-action@v3"
181+ uses : " docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2" # v3.10.0
182+ - name : " Build"
183+ uses : " docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25" # v5.4.0
184+ with :
185+ builder : " ${{ steps.buildx.outputs.name }}"
186+ context : " ./"
187+ push : false
188+ load : true
189+ tags : " ${{ env.APP_NAME }}/nautobot:${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
190+ file : " ./development/Dockerfile"
191+ cache-from : " type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
192+ cache-to : " type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
193+ build-args : |
194+ NAUTOBOT_VER=${{ matrix.nautobot-version }}
195+ PYTHON_VER=${{ matrix.python-version }}
196+ CI=true
197+ - name : " Use Mysql invoke settings when needed"
198+ run : " cp invoke.mysql.yml invoke.yml"
199+ if : " matrix.db-backend == 'mysql'"
200+ - name : " Run Tests"
201+ run : " poetry run invoke unittest"
202+
203+ unittest_report :
204+ needs :
205+ - " check-in-docker"
206+ strategy :
207+ fail-fast : true
208+ matrix :
209+ python-version : ["3.12"]
210+ db-backend : ["postgresql"]
211+ nautobot-version : ["stable"]
212+ runs-on : " ubuntu-22.04"
213+ permissions :
214+ pull-requests : " write"
215+ contents : " write"
216+ env :
217+ INVOKE_NAUTOBOT_BGP_MODELS_PYTHON_VER : " ${{ matrix.python-version }}"
218+ INVOKE_NAUTOBOT_BGP_MODELS_NAUTOBOT_VER : " ${{ matrix.nautobot-version }}"
219+ steps :
220+ - name : " Check out repository code"
221+ uses : " actions/checkout@v4"
222+ - name : " Setup environment"
223+ uses : " networktocode/gh-action-setup-poetry-environment@v6"
224+ with :
225+ poetry-version : " 1.8.5"
226+ - name : " Constrain Nautobot version and regenerate lock file"
227+ env :
228+ INVOKE_NAUTOBOT_BGP_MODELS_LOCAL : " true"
229+ run : " poetry run invoke lock --constrain-nautobot-ver --constrain-python-ver"
230+ - name : " Set up Docker Buildx"
231+ id : " buildx"
232+ uses : " docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2" # v3.10.0
170233 - name : " Build"
171- uses : " docker/build-push-action@v5 "
234+ uses : " docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 " # v5.4.0
172235 with :
173236 builder : " ${{ steps.buildx.outputs.name }}"
174237 context : " ./"
@@ -188,7 +251,28 @@ jobs:
188251 run : " cp invoke.mysql.yml invoke.yml"
189252 if : " matrix.db-backend == 'mysql'"
190253 - name : " Run Tests"
191- run : " poetry run invoke unittest"
254+ run : " poetry run invoke unittest --coverage"
255+ - name : " Generate Coverage Comment"
256+ if : >
257+ contains(fromJson('["develop","ltm-1.6"]'), github.base_ref) &&
258+ (github.head_ref != 'main') && (!startsWith(github.head_ref, 'release'))
259+ id : " coverage_comment"
260+ uses : " py-cov-action/python-coverage-comment-action@d1ff8fbb5ff80feedb3faa0f6d7b424f417ad0e1" # v3.30
261+ with :
262+ GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
263+ MINIMUM_GREEN : 90
264+ MINIMUM_ORANGE : 80
265+ ANNOTATE_MISSING_LINES : true
266+ ANNOTATION_TYPE : " warning"
267+ - name : " Store Pull Request comment to be posted"
268+ if : >
269+ contains(fromJson('["develop","ltm-1.6"]'), github.base_ref) &&
270+ (github.head_ref != 'main') && (!startsWith(github.head_ref, 'release'))
271+ uses : " actions/upload-artifact@v4"
272+ with :
273+ name : " python-coverage-comment-action"
274+ path : " python-coverage-comment-action.txt"
275+
192276 changelog :
193277 if : >
194278 contains(fromJson('["develop","ltm-1.6"]'), github.base_ref) &&
@@ -210,41 +294,39 @@ jobs:
210294 publish_gh :
211295 needs :
212296 - " unittest"
297+ - " unittest_report"
213298 name : " Publish to GitHub"
214299 runs-on : " ubuntu-22.04"
215300 if : " startsWith(github.ref, 'refs/tags/v')"
216301 env :
217302 INVOKE_NAUTOBOT_BGP_MODELS_LOCAL : " True"
303+ permissions :
304+ contents : " write"
218305 steps :
219306 - name : " Check out repository code"
220307 uses : " actions/checkout@v4"
221- - name : " Set up Python "
222- uses : " actions/ setup-python@v5 "
308+ - name : " Setup environment "
309+ uses : " networktocode/gh-action- setup-poetry-environment@v6 "
223310 with :
311+ poetry-version : " 1.8.5"
224312 python-version : " 3.12"
225- - name : " Install Python Packages"
226- run : " pip install poetry"
313+ poetry-install-options : " --no-root"
227314 - name : " Set env"
228315 run : " echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
229316 - name : " Run Poetry Version"
230317 run : " poetry version $RELEASE_VERSION"
231- - name : " Install Dependencies (needed for mkdocs)"
232- run : " poetry install --no-root"
233318 - name : " Build Documentation"
234319 run : " poetry run invoke build-and-check-docs"
235320 - name : " Run Poetry Build"
236321 run : " poetry build"
237322 - name : " Upload binaries to release"
238- uses : " svenstaro/upload-release-action@v2"
239- with :
240- repo_token : " ${{ secrets.GH_NAUTOBOT_BOT_TOKEN }}"
241- file : " dist/*"
242- tag : " ${{ github.ref }}"
243- overwrite : true
244- file_glob : true
323+ run : " gh release upload ${{ github.ref_name }} dist/*.{tar.gz,whl}"
324+ env :
325+ GH_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
245326 publish_pypi :
246327 needs :
247328 - " unittest"
329+ - " unittest_report"
248330 name : " Push Package to PyPI"
249331 runs-on : " ubuntu-22.04"
250332 if : " startsWith(github.ref, 'refs/tags/v')"
@@ -253,24 +335,22 @@ jobs:
253335 steps :
254336 - name : " Check out repository code"
255337 uses : " actions/checkout@v4"
256- - name : " Set up Python "
257- uses : " actions/ setup-python@v5 "
338+ - name : " Setup environment "
339+ uses : " networktocode/gh-action- setup-poetry-environment@v6 "
258340 with :
341+ poetry-version : " 1.8.5"
259342 python-version : " 3.12"
260- - name : " Install Python Packages"
261- run : " pip install poetry"
343+ poetry-install-options : " --no-root"
262344 - name : " Set env"
263345 run : " echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
264346 - name : " Run Poetry Version"
265347 run : " poetry version $RELEASE_VERSION"
266- - name : " Install Dependencies (needed for mkdocs)"
267- run : " poetry install --no-root"
268348 - name : " Build Documentation"
269349 run : " poetry run invoke build-and-check-docs"
270350 - name : " Run Poetry Build"
271351 run : " poetry build"
272352 - name : " Push to PyPI"
273- uses : " pypa/gh-action-pypi-publish@release/v1 "
353+ uses : " pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc " # v1.12.4
274354 with :
275355 user : " __token__"
276356 password : " ${{ secrets.PYPI_API_TOKEN }}"
@@ -291,7 +371,7 @@ jobs:
291371 # ENVs cannot be used directly in job.if. This is a workaround to check
292372 # if SLACK_WEBHOOK_URL is present.
293373 if : " env.SLACK_WEBHOOK_URL != ''"
294- uses : " slackapi/slack-github-action@v1 "
374+ uses : " slackapi/slack-github-action@fcfb566f8b0aab22203f066d80ca1d7e4b5d05b3 " # v1.27.1
295375 with :
296376 payload : |
297377 {
0 commit comments