aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Ibrahim2750mi <[email protected]>2023-02-18 02:51:17 +0530
committerGravatar Ibrahim2750mi <[email protected]>2023-02-18 02:51:17 +0530
commit1bd03100ad13020f878abc99fa917b808a74c79c (patch)
treefc7668cf66df590fe8680e389b41398924f5f644
parentMerge branch 'main' into migration/tag (diff)
parentMerge pull request #2409 from shtlrs/bump-isort-in-precommit (diff)
Merge branch 'main' into migration/tag
-rw-r--r--.github/workflows/build.yml13
-rw-r--r--.github/workflows/deploy.yml12
-rw-r--r--.github/workflows/lint-test.yml32
-rw-r--r--.github/workflows/status_embed.yaml65
-rw-r--r--.pre-commit-config.yaml2
5 files changed, 64 insertions, 60 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 211116f14..f8f2c8888 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -14,9 +14,6 @@ concurrency:
jobs:
build:
- outputs:
- job_status: ${{ job.status }}
-
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push'
name: Build & Push
runs-on: ubuntu-latest
@@ -64,13 +61,3 @@ jobs:
ghcr.io/python-discord/bot:${{ steps.sha_tag.outputs.tag }}
build-args: |
git_sha=${{ github.sha }}
-
- call_status_embed:
- name: Trigger the status embed workflow
- needs: build
- if: always()
- uses: ./.github/workflows/status_embed.yaml
- with:
- job_status: ${{ needs.build.outputs.job_status }}
- secrets:
- webhook_token: ${{ secrets.GHA_WEBHOOK_TOKEN }}
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 481311ef6..79eef8821 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -14,8 +14,6 @@ concurrency:
jobs:
build:
- outputs:
- job_status: ${{ job.status }}
environment: production
if: github.event.workflow_run.conclusion == 'success'
name: Build & Push
@@ -46,13 +44,3 @@ jobs:
namespaces/default/bot/deployment.yaml
images: 'ghcr.io/python-discord/bot:${{ steps.sha_tag.outputs.tag }}'
kubectl-version: 'latest'
-
- call_status_embed:
- name: Trigger the status embed workflow
- needs: build
- if: always()
- uses: ./.github/workflows/status_embed.yaml
- with:
- job_status: ${{ needs.build.outputs.job_status }}
- secrets:
- webhook_token: ${{ secrets.GHA_WEBHOOK_TOKEN }}
diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml
index 3d4453be9..a331659e6 100644
--- a/.github/workflows/lint-test.yml
+++ b/.github/workflows/lint-test.yml
@@ -12,8 +12,6 @@ concurrency:
jobs:
lint-test:
- outputs:
- job_status: ${{ job.status }}
runs-on: ubuntu-latest
env:
# List of licenses that are compatible with the MIT License and
@@ -77,12 +75,24 @@ jobs:
- name: Run tests and generate coverage report
run: pytest -n auto --cov --disable-warnings -q
- call_status_embed:
- name: Trigger the status embed workflow
- needs: lint-test
- if: always()
- uses: ./.github/workflows/status_embed.yaml
- with:
- job_status: ${{ needs.lint-test.outputs.job_status }}
- secrets:
- webhook_token: ${{ secrets.GHA_WEBHOOK_TOKEN }}
+ # Prepare the Pull Request Payload artifact. If this fails, we
+ # we fail silently using the `continue-on-error` option. It's
+ # nice if this succeeds, but if it fails for any reason, it
+ # does not mean that our lint-test checks failed.
+ - name: Prepare Pull Request Payload artifact
+ id: prepare-artifact
+ if: always() && github.event_name == 'pull_request'
+ continue-on-error: true
+ run: cat $GITHUB_EVENT_PATH | jq '.pull_request' > pull_request_payload.json
+
+ # This only makes sense if the previous step succeeded. To
+ # get the original outcome of the previous step before the
+ # `continue-on-error` conclusion is applied, we use the
+ # `.outcome` value. This step also fails silently.
+ - name: Upload a Build Artifact
+ if: always() && steps.prepare-artifact.outcome == 'success'
+ continue-on-error: true
+ uses: actions/upload-artifact@v2
+ with:
+ name: pull-request-payload
+ path: pull_request_payload.json
diff --git a/.github/workflows/status_embed.yaml b/.github/workflows/status_embed.yaml
index e81875b3a..4178c366d 100644
--- a/.github/workflows/status_embed.yaml
+++ b/.github/workflows/status_embed.yaml
@@ -1,17 +1,16 @@
name: Status Embed
on:
- workflow_call:
- inputs:
- job_status:
- required: true
- type: string
- secrets:
- webhook_token:
- required: true
+ workflow_run:
+ workflows:
+ - Lint & Test
+ - Build
+ - Deploy
+ types:
+ - completed
concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}-${{ github.sha }}
+ group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
@@ -28,14 +27,34 @@ jobs:
#
# 3. If any workflow ends in failure or was cancelled.
if: >-
- (github.workflow == 'Deploy' && ${{ inputs.job_status }} != 'skipped') ||
- github.event_name == 'pull_request' ||
- ${{ inputs.job_status }} == 'failure' ||
- ${{ inputs.job_status }} == 'cancelled'
+ (github.event.workflow_run.name == 'Deploy' && github.event.workflow_run.conclusion != 'skipped') ||
+ github.event.workflow_run.event == 'pull_request' ||
+ github.event.workflow_run.conclusion == 'failure' ||
+ github.event.workflow_run.conclusion == 'cancelled'
name: Send Status Embed to Discord
runs-on: ubuntu-latest
steps:
+ # A workflow_run event does not contain all the information
+ # we need for a PR embed. That's why we upload an artifact
+ # with that information in the Lint workflow.
+ - name: Get Pull Request Information
+ id: pr_info
+ if: github.event.workflow_run.event == 'pull_request'
+ run: |
+ curl -s -H "Authorization: token $GITHUB_TOKEN" ${{ github.event.workflow_run.artifacts_url }} > artifacts.json
+ DOWNLOAD_URL=$(cat artifacts.json | jq -r '.artifacts[] | select(.name == "pull-request-payload") | .archive_download_url')
+ [ -z "$DOWNLOAD_URL" ] && exit 1
+ wget --quiet --header="Authorization: token $GITHUB_TOKEN" -O pull_request_payload.zip $DOWNLOAD_URL || exit 2
+ unzip -p pull_request_payload.zip > pull_request_payload.json
+ [ -s pull_request_payload.json ] || exit 3
+ echo "::set-output name=pr_author_login::$(jq -r '.user.login // empty' pull_request_payload.json)"
+ echo "::set-output name=pr_number::$(jq -r '.number // empty' pull_request_payload.json)"
+ echo "::set-output name=pr_title::$(jq -r '.title // empty' pull_request_payload.json)"
+ echo "::set-output name=pr_source::$(jq -r '.head.label // empty' pull_request_payload.json)"
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
# Send an informational status embed to Discord instead of the
# standard embeds that Discord sends. This embed will contain
# more information and we can fine tune when we actually want
@@ -45,19 +64,19 @@ jobs:
with:
# Our GitHub Actions webhook
webhook_id: '784184528997842985'
- webhook_token: ${{ secrets.webhook_token }}
+ webhook_token: ${{ secrets.GHA_WEBHOOK_TOKEN }}
# Workflow information
- workflow_name: ${{ github.workflow }}
- run_id: ${{ github.run_id }}
- run_number: ${{ github.run_number }}
- status: ${{ inputs.job_status }}
+ workflow_name: ${{ github.event.workflow_run.name }}
+ run_id: ${{ github.event.workflow_run.id }}
+ run_number: ${{ github.event.workflow_run.run_number }}
+ status: ${{ github.event.workflow_run.conclusion }}
actor: ${{ github.actor }}
repository: ${{ github.repository }}
ref: ${{ github.ref }}
- sha: ${{ github.sha }}
+ sha: ${{ github.event.workflow_run.head_sha }}
- pr_author_login: ${{ github.event.pull_request.user.login}}
- pr_number: ${{ github.event.pull_request.number }}
- pr_title: ${{ github.event.pull_request.title }}
- pr_source: ${{ github.event.pull_request.head.label }}
+ pr_author_login: ${{ steps.pr_info.outputs.pr_author_login }}
+ pr_number: ${{ steps.pr_info.outputs.pr_number }}
+ pr_title: ${{ steps.pr_info.outputs.pr_title }}
+ pr_source: ${{ steps.pr_info.outputs.pr_source }}
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index d8a90ac00..47fd80f97 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -14,7 +14,7 @@ repos:
hooks:
- id: python-check-blanket-noqa
- repo: https://github.com/pycqa/isort
- rev: 5.8.0
+ rev: 5.12.0
hooks:
- id: isort
name: isort (python)