Repository navigation
233 lines (210 loc) · 7.92 KB
/
Copy pathci.yml
File metadata and controls
233 lines (210 loc) · 7.92 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# Continuous Integration
# This workflow downloads Slack over different environments
# and perform test runs of the install script
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: "0 0 * * *"
env:
CI_VERSION: ci-v2.1
jobs:
# Job to download slack for eacg platform and cache the installer
download_slack:
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: [ubuntu, windows, macOS]
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install Dependencies
run: |
pip install autoscraper==1.1.10
shell: bash
- name: Find Latest Slack URL and Versions
run: |
export SLACK_VERSION=`python .github/workflows/download_slack.py --get-version ${{ matrix.os }}`
echo "${SLACK_VERSION}" > ${{ matrix.os }}-version.txt
echo "SLACK_VERSION=${SLACK_VERSION}" >> $GITHUB_ENV
shell: bash
# Save the versions as caches
- name: Save Slack Version
uses: actions/cache@v2
with:
path: ${{ matrix.os }}-version.txt
key: ${{ env.CI_VERSION }}-${{ matrix.os }}-slack-version=${{ env.SLACK_VERSION }}
# Cache downloaded Slack
- name: Cache Slack
id: cache-download
uses: actions/cache@v2
with:
path: slack-download-${{ matrix.os }}
key: ${{ env.CI_VERSION }}-${{ matrix.os }}-slack-${{ env.SLACK_VERSION }}
# Actual download if cache misses
- name: Get Slack Download URL and Prepare Download
if: steps.cache-download.outputs.cache-hit != 'true'
run: |
export SLACK_DOWNLOAD_URL=$(python .github/workflows/download_slack.py --get-download-url ${{ matrix.os }})
echo "SLACK_DOWNLOAD_URL=${SLACK_DOWNLOAD_URL}" >> $GITHUB_ENV
mkdir -p slack-download-${{ matrix.os }}
shell: bash
- name: Download Slack Ubuntu
if: steps.cache-download.outputs.cache-hit != 'true' && matrix.os == 'ubuntu'
run: |
wget "${{ env.SLACK_DOWNLOAD_URL }}" -O slack-download-ubuntu/slack.rpm
- name: Download Slack MacOS
if: steps.cache-download.outputs.cache-hit != 'true' && matrix.os == 'macOS'
run: |
wget "${{ env.SLACK_DOWNLOAD_URL }}" -O slack-download-macOS/slack.dmg
- name: Download Slack Windows
if: steps.cache-download.outputs.cache-hit != 'true' && matrix.os == 'windows'
run: |
$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile("${{ env.SLACK_DOWNLOAD_URL }}", "slack-download-windows\slack.exe")
build:
needs: download_slack
continue-on-error: true
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: [ubuntu]
python-version: [3.7, 3.8, 3.9, pypy-3.7]
include:
- os: macOS
python-version: 3.6
- os: windows
python-version: 3.6
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
shell: bash
- name: Get Slack Version (step 1)
uses: actions/cache@v2
with:
path: ${{ matrix.os }}-version.txt
key: ${{ env.CI_VERSION }}-${{ matrix.os }}-${{ github.run_number }}
restore-keys: ${{ env.CI_VERSION }}-${{ matrix.os }}-slack-version=
- name: Get Slack Version (step 2)
run: |
version=`cat ${{ matrix.os }}-version.txt`
echo "SLACK_VERSION=${version}" >> $GITHUB_ENV
shell: bash
- name: Get Slack Downloaded from cache
uses: actions/cache@v2
with:
path: slack-download-${{ matrix.os }}
key: ${{ env.CI_VERSION }}-${{ matrix.os }}-slack-${{ env.SLACK_VERSION }}
- name: Install Slack (Ubuntu)
run: |
sudo apt-get install alien
sudo alien -i -k slack-download-ubuntu/slack.rpm
if: matrix.os == 'ubuntu'
- name: Install Slack (MacOS)
run: |
hdiutil attach slack-download-macOS/slack.dmg
sudo cp -rf /Volumes/Slack/Slack.app /Applications
if: matrix.os == 'macOS'
- name: Install Slack (Windows)
run: |
.\slack-download-windows\slack.exe
while (!(Test-Path "$env:LOCALAPPDATA\slack\app-${{ env.SLACK_VERSION }}\resources\app.asar")) { Start-Sleep 10 }
Stop-Process -Name slack -passthru| Wait-Process
if: matrix.os == 'windows'
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test run the script (Ubuntu and MacOS)
run: |
sudo python math-with-slack.py
if: matrix.os == 'ubuntu' || matrix.os == 'macOS'
- name: Test run the script (Windows)
run: |
python math-with-slack.py -a "${LOCALAPPDATA}\slack\app-${{ env.SLACK_VERSION }}\resources\app.asar"
shell: bash
if: matrix.os == 'windows'
- name: Prepare Badge Creation
run: |
if [ "${{ matrix.os }}" = "macOS" ]; then
BADGE_LOGO="apple"
else
BADGE_LOGO=${{ matrix.os }}
fi
echo "BADGE_LOGO=${BADGE_LOGO}" >> $GITHUB_ENV
shell: bash
if: ${{ always() && github.event_name != 'pull_request' }}
- name: Create Success Badge
uses: schneegans/dynamic-badges-action@v1.0.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ secrets.BADGE_GIST_ID }}
filename: ${{ matrix.os }}-${{ matrix.python-version }}.json
label: ${{ matrix.os }} | Python ${{ matrix.python-version }} | Slack ${{ env.SLACK_VERSION }}
namedLogo: ${{ env.BADGE_LOGO }}
message: passing
color: green
if: ${{ success() && github.event_name != 'pull_request' }}
- name: Create Unknown Badge
uses: schneegans/dynamic-badges-action@v1.0.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ secrets.BADGE_GIST_ID }}
filename: ${{ matrix.os }}-${{ matrix.python-version }}.json
label: ${{ matrix.os }} | Python ${{ matrix.python-version }} | Slack ${{ env.SLACK_VERSION }}
message: unknown
namedLogo: ${{ env.BADGE_LOGO }}
color: lightgrey
if: ${{ cancelled() && github.event_name != 'pull_request' }}
- name: Create Failure Badge
uses: schneegans/dynamic-badges-action@v1.0.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ secrets.BADGE_GIST_ID }}
filename: ${{ matrix.os }}-${{ matrix.python-version }}.json
label: ${{ matrix.os }} | Python ${{ matrix.python-version }} | Slack ${{ env.SLACK_VERSION }}
message: failed
namedLogo: ${{ env.BADGE_LOGO }}
isError: true
if: ${{ failure() && github.event_name != 'pull_request' }}
- name: Set exit code (Step 1)
run: touch failed.txt
shell: bash
if: ${{ failure() }}
- name: Set exit code (Step 2)
uses: pat-s/always-upload-cache@v2.1.3
with:
path: failed.txt
key: ${{ env.CI_VERSION }}-${{ github.run_number }}-failed
if: ${{ failure() }}
summary:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Get exit code from cache
id: get_exit_code
uses: actions/cache@v2
with:
path: failed.txt
key: ${{ env.CI_VERSION }}-${{ github.run_number }}-failed
- name: Set CI Status
if: steps.get_exit_code.outputs.cache-hit == 'true'
run: |
echo "At least a job failed"
exit 1