-
-
Notifications
You must be signed in to change notification settings - Fork 1
89 lines (79 loc) · 3.73 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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@v4
with:
fetch-depth: 0
- name: Install python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- 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 data for Pull Request
if: ${{ github.event_name == 'pull_request' }}
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 "overall_time=$formatted_time" >> $GITHUB_ENV
echo "pr_number=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
echo "branch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
echo "pr_url=${{ github.event.pull_request.html_url }}" >> $GITHUB_ENV
echo "diff=${{ github.event.pull_request.html_url }}/commits/${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
echo "commit_message=$(git log --format=%s -n 1 ${{ github.event.pull_request.head.sha }})" >> $GITHUB_ENV
echo "commit=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
echo "author=$(git log --format='%an <%ae>' -n 1 ${{ github.sha }})" >> $GITHUB_ENV
echo "date=$(git show -s --format=%ci ${{ github.sha }} | xargs -I{} date -d {} +'%a %b %d %T %Y %z')" >> $GITHUB_ENV
echo "current_job_status=${{ job.status }}" >> $GITHUB_ENV
- name: Record job data for push event
if: ${{ github.event_name == 'push' }}
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 "overall_time=$formatted_time" >> $GITHUB_ENV
echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
echo "diff=${{ github.event.compare }}" >> $GITHUB_ENV
echo "commit_message=$(git log --format=%s -n 1 ${{ github.sha }})" >> $GITHUB_ENV
echo "commit=${{ github.sha }}" >> $GITHUB_ENV
echo "author=${{ github.event.pusher.name }}" >> $GITHUB_ENV
echo "date=$(git show -s --format=%ci ${{ github.sha }} | xargs -I{} date -d {} +'%a %b %d %T %Y %z')" >> $GITHUB_ENV
echo "current_job_status=${{ job.status }}" >> $GITHUB_ENV
- name: Post to Slack about the result of the Pull Request
if: ( always() && github.event_name == 'pull_request' && !(github.event.action == 'closed' && github.event.pull_request.merged == true) )
uses: slackapi/[email protected]
with:
channel-id: "C05P40DCGAK"
payload-file-path: ".github/workflows/payloads/pr_payload.json"
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_WORKABLE_APP_OAUTH_TOKEN }}
- name: Post to Slack about the result of the push
if: ( always() && github.event_name == 'push' && github.ref == 'refs/heads/main' )
id: slack
uses: slackapi/[email protected]
with:
channel-id: "C05P40DCGAK"
payload-file-path: ".github/workflows/payloads/push_payload.json"
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_WORKABLE_APP_OAUTH_TOKEN }}