From e53a7b4eb68d2a8ee15aa240ed6a2af54ca3d595 Mon Sep 17 00:00:00 2001 From: Sam <109683132+kernelsam@users.noreply.github.com> Date: Tue, 15 Apr 2025 16:15:01 -0700 Subject: [PATCH] senzing-factory/build-resources#179 add slack notifications --- .../workflows/add-labels-standardized.yaml | 9 ++++++++ .../add-to-project-garage-dependabot.yaml | 9 ++++++++ .github/workflows/add-to-project-garage.yaml | 9 ++++++++ .github/workflows/bandit.yaml | 2 ++ .github/workflows/black.yaml | 6 ++++- .github/workflows/build-distribution.yaml | 11 +++++++++ .../check-development-dependencies.yaml | 4 +++- .../create-sphinx-documentation.yaml | 11 +++++++++ .github/workflows/flake8.yaml | 6 ++++- .github/workflows/isort.yaml | 6 ++++- .github/workflows/mypy.yaml | 6 ++++- .github/workflows/publish-to-pypi.yaml | 23 +++++++++++++++---- .github/workflows/pylint.yaml | 11 +++++++++ .github/workflows/pytest-linux.yaml | 11 +++++++++ 14 files changed, 115 insertions(+), 9 deletions(-) diff --git a/.github/workflows/add-labels-standardized.yaml b/.github/workflows/add-labels-standardized.yaml index 59ca6b29..c7f1c7a0 100644 --- a/.github/workflows/add-labels-standardized.yaml +++ b/.github/workflows/add-labels-standardized.yaml @@ -15,3 +15,12 @@ jobs: ORG_MEMBERSHIP_TOKEN: ${{ secrets.ORG_MEMBERSHIP_TOKEN }} SENZING_MEMBERS: ${{ secrets.SENZING_MEMBERS }} uses: senzing-factory/build-resources/.github/workflows/add-labels-to-issue.yaml@v2 + + slack-notification: + needs: [add-issue-labels] + if: ${{ always() && contains(fromJSON('["failure", "cancelled"]'), needs.add-issue-labels.outputs.job-status) }} + secrets: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + uses: senzing-factory/build-resources/.github/workflows/build-failure-slack-notification.yaml@v2 + with: + job-status: ${{ needs.add-issue-labels.outputs.job-status }} diff --git a/.github/workflows/add-to-project-garage-dependabot.yaml b/.github/workflows/add-to-project-garage-dependabot.yaml index 125bc58b..f71293e6 100644 --- a/.github/workflows/add-to-project-garage-dependabot.yaml +++ b/.github/workflows/add-to-project-garage-dependabot.yaml @@ -14,3 +14,12 @@ jobs: uses: senzing-factory/build-resources/.github/workflows/add-to-project-dependabot.yaml@v2 with: project: ${{ vars.SENZING_PROJECT_GARAGE }} + + slack-notification: + needs: [add-to-project-dependabot] + if: ${{ always() && contains(fromJSON('["failure", "cancelled"]'), needs.add-to-project-dependabot.outputs.job-status) }} + secrets: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + uses: senzing-factory/build-resources/.github/workflows/build-failure-slack-notification.yaml@v2 + with: + job-status: ${{ needs.add-to-project-dependabot.outputs.job-status }} diff --git a/.github/workflows/add-to-project-garage.yaml b/.github/workflows/add-to-project-garage.yaml index 8397880e..a8b70f2e 100644 --- a/.github/workflows/add-to-project-garage.yaml +++ b/.github/workflows/add-to-project-garage.yaml @@ -18,3 +18,12 @@ jobs: classic: false project-number: ${{ vars.SENZING_PROJECT_GARAGE }} org: ${{ vars.SENZING_GITHUB_ACCOUNT_NAME }} + + slack-notification: + needs: [add-to-project] + if: ${{ always() && contains(fromJSON('["failure", "cancelled"]'), needs.add-to-project.outputs.job-status) }} + secrets: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + uses: senzing-factory/build-resources/.github/workflows/build-failure-slack-notification.yaml@v2 + with: + job-status: ${{ needs.add-to-project.outputs.job-status }} diff --git a/.github/workflows/bandit.yaml b/.github/workflows/bandit.yaml index d3be5baf..b1721431 100644 --- a/.github/workflows/bandit.yaml +++ b/.github/workflows/bandit.yaml @@ -1,6 +1,8 @@ name: bandit on: + push: + branches-ignore: [main] pull_request: branches: [main] diff --git a/.github/workflows/black.yaml b/.github/workflows/black.yaml index d0848c81..8c53804c 100644 --- a/.github/workflows/black.yaml +++ b/.github/workflows/black.yaml @@ -1,6 +1,10 @@ name: black -on: [push, pull_request] +on: + push: + branches-ignore: [main] + pull_request: + branches: [main] permissions: contents: read diff --git a/.github/workflows/build-distribution.yaml b/.github/workflows/build-distribution.yaml index c3dae5a2..592f0240 100644 --- a/.github/workflows/build-distribution.yaml +++ b/.github/workflows/build-distribution.yaml @@ -8,6 +8,8 @@ permissions: jobs: build-distribution: name: Build distribution + outputs: + status: ${{ job.status }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -42,3 +44,12 @@ jobs: with: name: python-package-distributions path: dist/ + + slack-notification: + needs: [build-distribution] + if: ${{ always() && contains(fromJSON('["failure", "cancelled"]'), needs.build-distribution.outputs.status ) && github.ref_name == github.event.repository.default_branch }} + secrets: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + uses: senzing-factory/build-resources/.github/workflows/build-failure-slack-notification.yaml@v2 + with: + job-status: ${{ needs.build-distribution.outputs.status }} diff --git a/.github/workflows/check-development-dependencies.yaml b/.github/workflows/check-development-dependencies.yaml index 016e45bd..a80f570f 100644 --- a/.github/workflows/check-development-dependencies.yaml +++ b/.github/workflows/check-development-dependencies.yaml @@ -1,6 +1,8 @@ name: Check development dependencies -on: [pull_request] +on: + pull_request: + branches: [main] permissions: contents: read diff --git a/.github/workflows/create-sphinx-documentation.yaml b/.github/workflows/create-sphinx-documentation.yaml index d66e44f1..93bcccb2 100644 --- a/.github/workflows/create-sphinx-documentation.yaml +++ b/.github/workflows/create-sphinx-documentation.yaml @@ -11,6 +11,8 @@ permissions: jobs: docs: + outputs: + status: ${{ job.status }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -43,3 +45,12 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: _build/ force_orphan: true + + slack-notification: + needs: [docs] + if: ${{ always() && contains(fromJSON('["failure", "cancelled"]'), needs.docs.outputs.status ) }} + secrets: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + uses: senzing-factory/build-resources/.github/workflows/build-failure-slack-notification.yaml@v2 + with: + job-status: ${{ needs.docs.outputs.status }} diff --git a/.github/workflows/flake8.yaml b/.github/workflows/flake8.yaml index 8f154a44..d6b64f2e 100644 --- a/.github/workflows/flake8.yaml +++ b/.github/workflows/flake8.yaml @@ -1,6 +1,10 @@ name: flake8 -on: [push, pull_request] +on: + push: + branches-ignore: [main] + pull_request: + branches: [main] permissions: contents: read diff --git a/.github/workflows/isort.yaml b/.github/workflows/isort.yaml index 3052672a..d0e75464 100644 --- a/.github/workflows/isort.yaml +++ b/.github/workflows/isort.yaml @@ -1,6 +1,10 @@ name: isort -on: [push, pull_request] +on: + push: + branches-ignore: [main] + pull_request: + branches: [main] permissions: contents: read diff --git a/.github/workflows/mypy.yaml b/.github/workflows/mypy.yaml index 1c1cc827..733105b6 100644 --- a/.github/workflows/mypy.yaml +++ b/.github/workflows/mypy.yaml @@ -1,6 +1,10 @@ name: mypy -on: [push, pull_request] +on: + push: + branches-ignore: [main] + pull_request: + branches: [main] permissions: contents: read diff --git a/.github/workflows/publish-to-pypi.yaml b/.github/workflows/publish-to-pypi.yaml index 17b9ad62..5e204d54 100644 --- a/.github/workflows/publish-to-pypi.yaml +++ b/.github/workflows/publish-to-pypi.yaml @@ -11,6 +11,8 @@ permissions: jobs: build-distribution: name: Build distribution + outputs: + status: ${{ job.status }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -42,13 +44,15 @@ jobs: path: dist/ publish-to-pypi: - name: Publish Python distribution to PyPI - if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes - needs: - - build-distribution environment: name: pypi url: https://pypi.org/p/senzing + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + name: Publish Python distribution to PyPI + needs: + - build-distribution + outputs: + status: ${{ job.status }} permissions: id-token: write runs-on: ubuntu-latest @@ -67,6 +71,8 @@ jobs: name: Sign the Python distribution with Sigstore and upload them to GitHub Release needs: - publish-to-pypi + outputs: + status: ${{ job.status }} permissions: contents: write # IMPORTANT: mandatory for making GitHub Releases id-token: write # IMPORTANT: mandatory for sigstore @@ -93,3 +99,12 @@ jobs: # `dist/` contains the built packages, and the # sigstore-produced signatures and certificates. run: gh release upload '${{ github.ref_name }}' dist/** --repo '${{ github.repository }}' + + slack-notification: + needs: [build-distribution, publish-to-pypi, github-release] + if: ${{ always() && contains(fromJSON('["failure", "cancelled"]'), needs.build-distribution.outputs.status ) && contains(fromJSON('["failure", "cancelled"]'), needs.publish-to-pypi.outputs.status ) && contains(fromJSON('["failure", "cancelled"]'), needs.github-release.outputs.status ) && github.ref_name == github.event.repository.default_branch }} + secrets: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + uses: senzing-factory/build-resources/.github/workflows/build-failure-slack-notification.yaml@v2 + with: + job-status: ${{ needs.build-distribution.outputs.status && needs.publish-to-pypi.outputs.status && needs.github-release.outputs.status }} diff --git a/.github/workflows/pylint.yaml b/.github/workflows/pylint.yaml index b24e1013..f2cffc82 100644 --- a/.github/workflows/pylint.yaml +++ b/.github/workflows/pylint.yaml @@ -7,6 +7,8 @@ permissions: jobs: pylint: + outputs: + status: ${{ job.status }} runs-on: ubuntu-latest strategy: matrix: @@ -35,3 +37,12 @@ jobs: run: | # shellcheck disable=SC2046 pylint $(git ls-files '*.py' ':!:docs/source/*') + + slack-notification: + needs: [pylint] + if: ${{ always() && contains(fromJSON('["failure", "cancelled"]'), needs.pylint.outputs.status ) && github.ref_name == github.event.repository.default_branch }} + secrets: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + uses: senzing-factory/build-resources/.github/workflows/build-failure-slack-notification.yaml@v2 + with: + job-status: ${{ needs.pylint.outputs.status }} diff --git a/.github/workflows/pytest-linux.yaml b/.github/workflows/pytest-linux.yaml index be761ac9..3a6e7b33 100644 --- a/.github/workflows/pytest-linux.yaml +++ b/.github/workflows/pytest-linux.yaml @@ -12,6 +12,8 @@ permissions: jobs: pytest-linux: name: "pytest with Senzing: ${{ matrix.senzingsdk-version }}; OS: ${{ matrix.os }}; Python ${{ matrix.python-version }}" + outputs: + status: ${{ job.status }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -123,3 +125,12 @@ jobs: pull-requests: write contents: write uses: senzing-factory/build-resources/.github/workflows/python-coverage-comment.yaml@v2 + + slack-notification: + needs: [pytest-linux, coverage] + if: ${{ always() && contains(fromJSON('["failure", "cancelled"]'), needs.pytest-linux.outputs.status ) && contains(fromJSON('["failure", "cancelled"]'), needs.coverage.outputs.job-status ) && github.ref_name == github.event.repository.default_branch }} + secrets: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + uses: senzing-factory/build-resources/.github/workflows/build-failure-slack-notification.yaml@v2 + with: + job-status: ${{ needs.pytest-linux.outputs.status && needs.coverage.outputs.job-status }}