@@ -13,107 +13,76 @@ on: # yamllint disable-line rule:truthy rule:comments
1313 pull_request : ~
1414
1515env :
16- IMAGE_NAME : " pyntc"
16+ INVOKE_PYNTC_IMAGE_NAME : " pyntc"
17+ INVOKE_PYNTC_IMAGE_VER : " latest"
1718
1819jobs :
19- black :
20+ ruff-format :
2021 runs-on : " ubuntu-24.04"
2122 env :
22- INVOKE_LOCAL : " True"
23+ INVOKE_PYNTC_LOCAL : " True"
2324 steps :
2425 - name : " Check out repository code"
2526 uses : " actions/checkout@v4"
2627 - name : " Setup environment"
2728 uses : " networktocode/gh-action-setup-poetry-environment@v6"
28- - name : " Linting: black"
29- run : " poetry run invoke black"
30- bandit :
31- runs-on : " ubuntu-24.04"
32- env :
33- INVOKE_LOCAL : " True"
34- steps :
35- - name : " Check out repository code"
36- uses : " actions/checkout@v4"
37- - name : " Setup environment"
38- uses : " networktocode/gh-action-setup-poetry-environment@v6"
39- - name : " Linting: bandit"
40- run : " poetry run invoke bandit"
41- needs :
42- - " black"
43- pydocstyle :
29+ with :
30+ poetry-version : " 1.8.5"
31+ - name : " Linting: ruff format"
32+ run : " poetry run invoke ruff --action format"
33+ ruff-lint :
4434 runs-on : " ubuntu-24.04"
4535 env :
46- INVOKE_LOCAL : " True"
36+ INVOKE_PYNTC_LOCAL : " True"
4737 steps :
4838 - name : " Check out repository code"
4939 uses : " actions/checkout@v4"
5040 - name : " Setup environment"
5141 uses : " networktocode/gh-action-setup-poetry-environment@v6"
52- - name : " Linting: pydocstyle"
53- run : " poetry run invoke pydocstyle"
54- needs :
55- - " black"
56- flake8 :
42+ with :
43+ poetry-version : " 1.8.5"
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_PYNTC_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 :
5761 runs-on : " ubuntu-24.04"
5862 env :
59- INVOKE_LOCAL : " True"
63+ INVOKE_PYNTC_LOCAL : " True"
6064 steps :
6165 - name : " Check out repository code"
6266 uses : " actions/checkout@v4"
6367 - name : " Setup environment"
6468 uses : " networktocode/gh-action-setup-poetry-environment@v6"
65- - name : " Linting: flake8 "
66- run : " poetry run invoke flake8 "
67- needs :
68- - " black "
69+ with :
70+ poetry-version : " 1.8.5 "
71+ - name : " Checking: poetry lock file "
72+ run : " poetry lock --check "
6973 yamllint :
7074 runs-on : " ubuntu-24.04"
7175 env :
72- INVOKE_LOCAL : " True"
76+ INVOKE_PYNTC_LOCAL : " True"
7377 steps :
7478 - name : " Check out repository code"
7579 uses : " actions/checkout@v4"
7680 - name : " Setup environment"
7781 uses : " networktocode/gh-action-setup-poetry-environment@v6"
82+ with :
83+ poetry-version : " 1.8.5"
7884 - name : " Linting: yamllint"
7985 run : " poetry run invoke yamllint"
80- needs :
81- - " black"
82- build :
83- strategy :
84- fail-fast : true
85- matrix :
86- python-version : ["3.9", "3.10", "3.11", "3.12"]
87- runs-on : " ubuntu-24.04"
88- env :
89- PYTHON_VER : " ${{ matrix.python-version }}"
90- steps :
91- - name : " Check out repository code"
92- uses : " actions/checkout@v4"
93- - name : " Setup environment"
94- uses : " networktocode/gh-action-setup-poetry-environment@v6"
95- - name : " Get image version"
96- run : " echo IMAGE_VER=`poetry version -s`-py${{ matrix.python-version }} >> $GITHUB_ENV"
97- - name : " Set up Docker Buildx"
98- id : " buildx"
99- uses : " docker/setup-buildx-action@v3"
100- - name : " Build"
101- uses : " docker/build-push-action@v6"
102- with :
103- builder : " ${{ steps.buildx.outputs.name }}"
104- context : " ./"
105- push : false
106- tags : " ${{ env.IMAGE_NAME }}:${{ env.IMAGE_VER }}"
107- file : " ./Dockerfile"
108- cache-from : " type=gha,scope=${{ env.IMAGE_NAME }}-${{ env.IMAGE_VER }}-py${{ matrix.python-version }}"
109- cache-to : " type=gha,scope=${{ env.IMAGE_NAME }}-${{ env.IMAGE_VER }}-py${{ matrix.python-version }}"
110- build-args : |
111- PYTHON_VER=${{ env.PYTHON_VER }}
112- needs :
113- - " bandit"
114- - " pydocstyle"
115- - " flake8"
116- - " yamllint"
11786 pylint :
11887 runs-on : " ubuntu-24.04"
11988 strategy :
@@ -128,29 +97,27 @@ jobs:
12897 - name : " Setup environment"
12998 uses : " networktocode/gh-action-setup-poetry-environment@v6"
13099 - name : " Get image version"
131- run : " echo IMAGE_VER =`poetry version -s`-py${{ matrix.python-version }} >> $GITHUB_ENV"
100+ run : " echo INVOKE_PYNTC_IMAGE_VER =`poetry version -s`-py${{ matrix.python-version }} >> $GITHUB_ENV"
132101 - name : " Set up Docker Buildx"
133102 id : " buildx"
134- uses : " docker/setup-buildx-action@v3 "
135- - name : " Load the image from cache "
136- uses : " docker/build-push-action@v6 "
103+ uses : " docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 " # v3.10.0
104+ - name : " Build "
105+ uses : " docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 " # v5.4.0
137106 with :
138107 builder : " ${{ steps.buildx.outputs.name }}"
139108 context : " ./"
140109 push : false
141110 load : true
142- tags : " ${{ env.IMAGE_NAME }}:${{ env.IMAGE_VER }}"
111+ tags : " ${{ env.INVOKE_PYNTC_IMAGE_NAME }}:${{ env.INVOKE_PYNTC_IMAGE_VER }}"
143112 file : " ./Dockerfile"
144- cache-from : " type=gha,scope=${{ env.IMAGE_NAME }}-${{ env.IMAGE_VER }}-py${{ matrix.python-version }}"
145- cache-to : " type=gha,scope=${{ env.IMAGE_NAME }}-${{ env.IMAGE_VER }}-py${{ matrix.python-version }}"
113+ cache-from : " type=gha,scope=${{ env.INVOKE_PYNTC_IMAGE_NAME }}-${{ env.INVOKE_PYNTC_IMAGE_VER }}-py${{ matrix.python-version }}"
114+ cache-to : " type=gha,scope=${{ env.INVOKE_PYNTC_IMAGE_NAME }}-${{ env.INVOKE_PYNTC_IMAGE_VER }}-py${{ matrix.python-version }}"
146115 build-args : |
147116 PYTHON_VER=${{ env.PYTHON_VER }}
148117 - name : " Debug: Show docker images"
149118 run : " docker image ls"
150119 - name : " Linting: Pylint"
151120 run : " poetry run invoke pylint"
152- needs :
153- - " build"
154121 pytest :
155122 strategy :
156123 fail-fast : true
@@ -165,33 +132,27 @@ jobs:
165132 - name : " Setup environment"
166133 uses : " networktocode/gh-action-setup-poetry-environment@v6"
167134 - name : " Get image version"
168- run : " echo IMAGE_VER =`poetry version -s`-py${{ matrix.python-version }} >> $GITHUB_ENV"
135+ run : " echo INVOKE_PYNTC_IMAGE_VER =`poetry version -s`-py${{ matrix.python-version }} >> $GITHUB_ENV"
169136 - name : " Set up Docker Buildx"
170137 id : " buildx"
171- uses : " docker/setup-buildx-action@v3 "
172- - name : " Load the image from cache "
173- uses : " docker/build-push-action@v6 "
138+ uses : " docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 " # v3.10.0
139+ - name : " Build "
140+ uses : " docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 " # v5.4.0
174141 with :
175142 builder : " ${{ steps.buildx.outputs.name }}"
176143 context : " ./"
177144 push : false
178145 load : true
179- tags : " ${{ env.IMAGE_NAME }}:${{ env.IMAGE_VER }}"
146+ tags : " ${{ env.INVOKE_PYNTC_IMAGE_NAME }}:${{ env.INVOKE_PYNTC_IMAGE_VER }}"
180147 file : " ./Dockerfile"
181- cache-from : " type=gha,scope=${{ env.IMAGE_NAME }}-${{ env.IMAGE_VER }}-py${{ matrix.python-version }}"
182- cache-to : " type=gha,scope=${{ env.IMAGE_NAME }}-${{ env.IMAGE_VER }}-py${{ matrix.python-version }}"
148+ cache-from : " type=gha,scope=${{ env.INVOKE_PYNTC_IMAGE_NAME }}-${{ env.INVOKE_PYNTC_IMAGE_VER }}-py${{ matrix.python-version }}"
149+ cache-to : " type=gha,scope=${{ env.INVOKE_PYNTC_IMAGE_NAME }}-${{ env.INVOKE_PYNTC_IMAGE_VER }}-py${{ matrix.python-version }}"
183150 build-args : |
184151 PYTHON_VER=${{ env.PYTHON_VER }}
185152 - name : " Debug: Show docker images"
186153 run : " docker image ls"
187154 - name : " Run Tests"
188155 run : " poetry run invoke pytest"
189- needs :
190- - " pylint"
191- - " bandit"
192- - " pydocstyle"
193- - " flake8"
194- - " yamllint"
195156 publish_gh :
196157 name : " Publish to GitHub"
197158 runs-on : " ubuntu-24.04"
@@ -210,16 +171,14 @@ jobs:
210171 run : " echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV"
211172 - name : " Run Poetry Version"
212173 run : " poetry version $RELEASE_VERSION"
174+ - name : " Build Documentation"
175+ run : " poetry run invoke build-and-check-docs"
213176 - name : " Run Poetry Build"
214177 run : " poetry build"
215178 - name : " Upload binaries to release"
216- uses : " svenstaro/upload-release-action@v2"
217- with :
218- repo_token : " ${{ secrets.NTC_GITHUB_TOKEN }}"
219- file : " dist/*"
220- tag : " ${{ github.ref }}"
221- overwrite : true
222- file_glob : true
179+ run : " gh release upload ${{ github.ref_name }} dist/*.{tar.gz,whl}"
180+ env :
181+ GH_TOKEN : " ${{ secrets.NTC_GITHUB_TOKEN }}"
223182 needs :
224183 - " pytest"
225184 publish_pypi :
@@ -243,9 +202,44 @@ jobs:
243202 - name : " Run Poetry Build"
244203 run : " poetry build"
245204 - name : " Push to PyPI"
246- uses : " pypa/gh-action-pypi-publish@release/v1 "
205+ uses : " pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc " # v1.12.4
247206 with :
248207 user : " __token__"
249208 password : " ${{ secrets.PYPI_API_TOKEN }}"
250209 needs :
251210 - " pytest"
211+ slack-notify :
212+ needs :
213+ - " publish_gh"
214+ - " publish_pypi"
215+ runs-on : " ubuntu-24.04"
216+ env :
217+ SLACK_WEBHOOK_URL : " ${{ secrets.SLACK_WEBHOOK_URL }}"
218+ SLACK_MESSAGE : >-
219+ *NOTIFICATION: NEW-RELEASE-PUBLISHED*\n
220+ Repository: <${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>\n
221+ Release: <${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}|${{ github.ref_name }}>\n
222+ Published by: <${{ github.server_url }}/${{ github.actor }}|${{ github.actor }}>
223+ steps :
224+ - name : " Send a notification to Slack"
225+ # ENVs cannot be used directly in job.if. This is a workaround to check
226+ # if SLACK_WEBHOOK_URL is present.
227+ if : " env.SLACK_WEBHOOK_URL != ''"
228+ uses : " slackapi/slack-github-action@fcfb566f8b0aab22203f066d80ca1d7e4b5d05b3" # v1.27.1
229+ with :
230+ payload : |
231+ {
232+ "text": "${{ env.SLACK_MESSAGE }}",
233+ "blocks": [
234+ {
235+ "type": "section",
236+ "text": {
237+ "type": "mrkdwn",
238+ "text": "${{ env.SLACK_MESSAGE }}"
239+ }
240+ }
241+ ]
242+ }
243+ env :
244+ SLACK_WEBHOOK_URL : " ${{ secrets.SLACK_WEBHOOK_URL }}"
245+ SLACK_WEBHOOK_TYPE : " INCOMING_WEBHOOK"
0 commit comments