Skip to content

Commit 096b7b1

Browse files
committed
chore: add github workflows
1 parent 24b2645 commit 096b7b1

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: slack-notification
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
job_status:
7+
description: 'The status of the job'
8+
required: true
9+
type: string
10+
channel:
11+
description: 'The channel to notify'
12+
required: false
13+
default: '#test-zone'
14+
type: string
15+
16+
jobs:
17+
slackNotification:
18+
name: Slack Notification
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Post to a Slack channel
22+
id: slack
23+
uses: slackapi/[email protected]
24+
with:
25+
channel-id: ${{ inputs.channel }}
26+
payload: |
27+
{
28+
"attachments": [
29+
{
30+
"color": "#e01e5a",
31+
"fields": [
32+
{
33+
"title": "Repo",
34+
"short": true,
35+
"value": "<${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>"
36+
},
37+
{
38+
"title": "${{ github.workflow }}",
39+
"short": true,
40+
"value": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ inputs.job_status }}>"
41+
},
42+
{
43+
"title": "Triggered by",
44+
"short": true,
45+
"value": "<${{ github.server_url }}/${{ github.triggering_actor }}|${{ github.triggering_actor }}>"
46+
},
47+
{
48+
"title": "Branch",
49+
"short": "true",
50+
"value": "${{ github.ref_name }}"
51+
}
52+
]
53+
}
54+
]
55+
}
56+
env:
57+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

.github/workflows/verify.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: verify
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
7+
# job ideas taken from here: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
8+
jobs:
9+
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-python@v4
15+
with:
16+
python-version: '3.11'
17+
- name: Install dependencies
18+
run: |
19+
python -m pip install --upgrade pip
20+
pip install ruff
21+
- name: Lint with Ruff
22+
run: ruff check --output-format=github .
23+
continue-on-error: false
24+
25+
test:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
- uses: actions/setup-python@v4
30+
with:
31+
python-version: '3.11'
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install -r requirements.txt
36+
- name: Run tests
37+
run: python -m unittest
38+
39+
build:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: actions/setup-python@v4
44+
with:
45+
python-version: '3.11'
46+
- name: Install dependencies
47+
run: |
48+
python -m pip install --upgrade pip
49+
pip install build
50+
- name: Build package
51+
run: python -m build
52+
53+
slackNotificaton:
54+
if: failure()
55+
needs: [lint, test, build]
56+
uses: ./.github/workflows/slack-notification.yaml
57+
with:
58+
channel: '#dada-prime'
59+
job_status: 'failure'
60+
secrets: inherit
61+

0 commit comments

Comments
 (0)