Skip to content

Commit

Permalink
Add Notify on Failure workflow alert & minor linting/deps (#45)
Browse files Browse the repository at this point in the history
* failure workflow and minor linting

* contributing

* remove main branch'

---------

Co-authored-by: jamie zieziula <[email protected]>
  • Loading branch information
jamiezieziula and jamie zieziula authored Oct 2, 2024
1 parent 150a84a commit ee961e8
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 5 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/helm-chart-release.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: Create prefect-helm release
---
name: Trigger Downstream Helm Chart Release

on:
"on":
# As soon as this repo creates an official release, we will
# create a corresponding release in the helm chart repo
release:
types: [released]

permissions: {}

jobs:
create_helm_release:
runs-on: ubuntu-latest
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/notify-on-failure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: Notify on Failure

"on":
workflow_run:
workflows:
- Build and Publish prometheus-prefect-exporter Image
- Trigger Downstream Helm Chart Release
types: [completed]

permissions: {}

jobs:
notify:
name: Notify on Failure
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
permissions:
# required to introspect the workflow run
actions: read
# required to read from the repo
contents: read
steps:
- name: Format date
run: |
formatted_date=$(date -d "${{ github.event.workflow_run.run_started_at }}" "+%b %d at %I:%M %p")
echo "FORMATTED_DATE=$formatted_date" >> $GITHUB_ENV
- name: Send Slack notification
uses: 8398a7/action-slack@v3
with:
status: custom
# https://api.slack.com/reference/messaging/attachments
custom_payload: |
{
attachments: [{
pretext: ':x: Workflow triggered by ${{ github.actor }} failed',
title: '${{ github.event.workflow_run.display_title }} #${{github.event.workflow_run.run_number}}',
title_link: '${{ github.event.workflow_run.html_url }}',
footer: '${{ github.repository }} | ${{ env.FORMATTED_DATE }} UTC',
footer_icon: 'https://slack-imgs.com/?c=1&o1=wi32.he32.si&url=https%3A%2F%2Fslack.github.com%2Fstatic%2Fimg%2Ffavicon-neutral.png',
color: 'danger',
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_GHA_JOB_STATUS }}
6 changes: 3 additions & 3 deletions .github/workflows/release-build-deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: Build and publish prometheus-prefect-exporter image
---
name: Build and Publish prometheus-prefect-exporter Image

"on":
push:
tags:
- '*'

# Do not grant jobs any permissions by default
permissions: {}

jobs:
build_push_exporter:
permissions:
# required to clone repository
# required to read from the repo
contents: read
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Python artifacts
__pycache__/

# OS
.DS_Store
6 changes: 6 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[tools]
actionlint = '1.7.1'
pre-commit = '3.7.1'
python = '3.11'
ruff = '0.4.9'
shellcheck = '0.10.0'
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@ repos:
- id: end-of-file-fixer
- id: no-commit-to-branch
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
hooks:
- id: ruff
language_version: python3
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
- id: ruff-format

- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.7.2
hooks:
- id: shellcheck
args: ["--severity=error"]

- repo: https://github.com/rhysd/actionlint
rev: v1.7.1
hooks:
- id: actionlint
args:
- -shellcheck=
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Contributing to Prometheus Prefect Exporter

## Local development

To get started, ensure you have the required dependencies installed:

```shell
mise install
```

Be sure to run `pre-commit install` before starting any development. [`pre-commit`](https://pre-commit.com/)
will help catch simple issues before committing.

0 comments on commit ee961e8

Please sign in to comment.