-
Notifications
You must be signed in to change notification settings - Fork 30
122 lines (106 loc) · 3.96 KB
/
main.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: 🚀 CI/CD for Panoply Python SDK
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
python_version: 3.8.2
jobs:
check-version:
name: 🔍 Check version
runs-on: ubuntu-20.04
outputs:
version: ${{ steps.retrieve-version.outputs.version }}
steps:
- name: 🐙 Checkout repository
uses: actions/checkout@v3
- name: 📝 Retrieve version
id: retrieve-version
run: |
echo "::set-output name=version::$(python setup.py --version 2> /dev/null)"
- name: 🔍 Check git tag availability
run: |
! git ls-remote --exit-code --tags origin v${{ steps.retrieve-version.outputs.version }}
run-tests:
name: 🧪 Run tests
runs-on: ubuntu-20.04
steps:
- name: 🐙 Checkout repository
uses: actions/checkout@v3
- name: 🔧 Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.python_version }}
cache: pip
cache-dependency-path: setup.py
- name: 📦 Install dependencies
run: |
python -m pip install -e .[test]
- name: 👁️ Run linters
run: |
pycodestyle --format=pylint --max-line-length=120 --count .
- name: 🧪 Run tests
run: |
coverage run -m unittest discover tests
- name: 📢 Report coverage
run: |
coverage report -im
create-release:
name: 🎉 Create release
needs: [check-version, run-tests]
if: github.event_name == 'push'
runs-on: ubuntu-20.04
permissions:
contents: write
steps:
- name: 🎉 Create release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.check-version.outputs.version }}
target_commitish: ${{ github.sha }}
send-notifications:
name: 🔔 Send notifications
needs: [check-version, run-tests, create-release]
if: github.event_name == 'push' && always()
runs-on: ubuntu-20.04
steps:
- name: 📝 Retrieve workflow result
id: retrieve-workflow-result
run: |
if [ ${{ needs.check-version.result }} = 'success' ] \
&& [ ${{ needs.run-tests.result }} = 'success' ] \
&& [ ${{ needs.create-release.result }} = 'success' ]
then
echo "::set-output name=result::success"
echo "::set-output name=message::succeeded"
elif [ ${{ needs.check-version.result }} = 'cancelled' ] \
|| [ ${{ needs.run-tests.result }} = 'cancelled' ] \
|| [ ${{ needs.create-release.result }} = 'cancelled' ]
then
echo "::set-output name=result::cancelled"
echo "::set-output name=message::canceled"
else
echo "::set-output name=result::failure"
echo "::set-output name=message::failed"
fi
- name: 📝 Retrieve origin url message
id: retrieve-origin-url-message
run: |
echo "::set-output name=message::<https://github.com/${{ github.repository }}/commit/${{ github.sha }}|$(echo ${{ github.sha }} | cut -c1-9)>"
- name: 🔔 Send Slack notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_TITLE: ' '
SLACK_COLOR: ${{ steps.retrieve-workflow-result.outputs.result }}
SLACK_MESSAGE: >-
<https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks|Workflow>
of ${{ steps.retrieve-origin-url-message.outputs.message }}
on <https://github.com/${{ github.repository }}/tree/v${{ needs.check-version.outputs.version }}|${{ github.repository }}@v${{ needs.check-version.outputs.version }}>
by ${{ github.actor }}
${{ steps.retrieve-workflow-result.outputs.message }}
SLACK_MSG_AUTHOR: ' '
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: ' '
MSG_MINIMAL: true