-
-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (58 loc) · 2.06 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Run tests
on:
pull_request:
push:
branches:
- 'main'
jobs:
build:
runs-on: ubuntu-latest
environment: Deploy
steps:
- name: Get starting time for reporting
id: start
run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
- name: Checkout repository
uses: actions/checkout@v3
- name: Install python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install poetry and run tests
run: |
git tag 0.0.0.dev
pip install poetry
poetry config virtualenvs.in-project true
make install
. .venv/bin/activate
make test
- name: Record job end time, calculate elapsed time, and get the latest commit message
id: end
run: |
end_time=$(date +%s)
start_time=${{ steps.start.outputs.start_time }}
elapsed_time=$(($end_time-$start_time))
formatted_time=$(date -u -d @$elapsed_time +"%M:%S")
echo $formatted_time
echo "overall_time=$formatted_time" >> $GITHUB_OUTPUT
echo "commit_message=$(git log --format=%B -n 1)" >> $GITHUB_OUTPUT
- name: Post to a Slack channel
if: always()
id: slack
uses: slackapi/[email protected]
with:
channel-id: 'C05P40DCGAK'
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "G3 CI/PR-${{ github.event.pull_request.number }}: ${{ job.status }}\n```Time : ${{ steps.end.outputs.overall_time }}\nBranch : ${{ github.head_ref }}\nPR : ${{ github.event.pull_request.html_url }}\nDiff : ${{ github.event.pull_request.html_url }}/commits/${{ github.event.pull_request.head.sha }}\n\n ${{ steps.end.outputs.commit_message }}```"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_WORKABLE_APP_OAUTH_TOKEN }}