-
Notifications
You must be signed in to change notification settings - Fork 5
287 lines (284 loc) · 9.38 KB
/
ci.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
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
name: CI
on:
push:
pull_request:
release:
types: [released]
defaults:
run:
shell: pwsh
jobs:
package:
runs-on: ubuntu-latest
env:
PYTHONUTF8: 1
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: "3.12"
- name: Build
run: |
python -m pip install build
python -m build
- name: Upload package artifacts
uses: actions/upload-artifact@v4
with:
name: package
path: ./dist
- name: Prepare
run: |
python -m pip install ./dist/*.whl
aexpy --help
mkdir -p ./cache
- name: Test Preprocess
run: |
aexpy -vvv preprocess -r -p generator-oj-problem@0.0.1 ./cache ./cache/distribution1.json
aexpy -vvv preprocess -r -p generator-oj-problem@0.0.2 ./cache ./cache/distribution2.json
- name: Test Extraction
continue-on-error: false
run: |
aexpy -vvv extract ./cache/distribution1.json ./cache/api1.json
aexpy -vvv extract ./cache/distribution2.json ./cache/api2.json
- name: Test Extraction in Temp env
continue-on-error: false
run: |
aexpy -vvv extract ./cache/distribution1.json ./cache/api3.json --no-temp
aexpy -vvv extract ./cache/distribution1.json ./cache/api4.json --temp
- name: Test Difference
continue-on-error: false
run: |
aexpy -vvv diff ./cache/api1.json ./cache/api2.json ./cache/diff.json
- name: Test Report
continue-on-error: false
run: |
aexpy -vvv report ./cache/diff.json ./cache/report.json
- name: Test View
continue-on-error: false
run: |
aexpy -vvv view ./cache/distribution1.json
aexpy -vvv view ./cache/distribution2.json
aexpy -vvv view ./cache/api1.json
aexpy -vvv view ./cache/api2.json
aexpy -vvv view ./cache/api3.json
aexpy -vvv view ./cache/diff.json
aexpy -vvv view ./cache/report.json
- name: Upload results
uses: actions/upload-artifact@v4
with:
name: package-cache
path: ./cache
image:
runs-on: ubuntu-latest
env:
PYTHONUTF8: 1
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x64'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build
run: |
docker build -t aexpy/aexpy .
- name: Prepare
run: |
docker run aexpy/aexpy --help
mkdir -p ./cache
- name: Test Preprocess
run: |
docker run -v ${{ github.workspace }}/cache:/data aexpy/aexpy -vvv preprocess -r -p generator-oj-problem@0.0.1 /data /data/distribution1.json
docker run -v ${{ github.workspace }}/cache:/data aexpy/aexpy -vvv preprocess -r -p generator-oj-problem@0.0.2 /data /data/distribution2.json
- name: Test Extraction
continue-on-error: false
run: |
docker run -v ${{ github.workspace }}/cache:/data aexpy/aexpy -vvv extract /data/distribution1.json /data/api1.json
docker run -v ${{ github.workspace }}/cache:/data aexpy/aexpy -vvv extract /data/distribution2.json /data/api2.json
- name: Test Extraction in Env
continue-on-error: false
run: |
docker run -v ${{ github.workspace }}/cache:/data aexpy/aexpy -vvv extract /data/distribution1.json /data/api3.json --temp
docker run -v ${{ github.workspace }}/cache:/data aexpy/aexpy -vvv extract /data/distribution1.json /data/api4.json --no-temp
- name: Test Difference
continue-on-error: false
run: |
docker run -v ${{ github.workspace }}/cache:/data aexpy/aexpy -vvv diff /data/api1.json /data/api2.json /data/diff.json
- name: Test Report
continue-on-error: false
run: |
docker run -v ${{ github.workspace }}/cache:/data aexpy/aexpy -vvv report /data/diff.json /data/report.json
- name: Test View
continue-on-error: false
run: |
docker run -v ${{ github.workspace }}/cache:/data aexpy/aexpy -vvv view /data/distribution1.json
docker run -v ${{ github.workspace }}/cache:/data aexpy/aexpy -vvv view /data/distribution2.json
docker run -v ${{ github.workspace }}/cache:/data aexpy/aexpy -vvv view /data/api1.json
docker run -v ${{ github.workspace }}/cache:/data aexpy/aexpy -vvv view /data/api2.json
docker run -v ${{ github.workspace }}/cache:/data aexpy/aexpy -vvv view /data/api3.json
docker run -v ${{ github.workspace }}/cache:/data aexpy/aexpy -vvv view /data/diff.json
docker run -v ${{ github.workspace }}/cache:/data aexpy/aexpy -vvv view /data/report.json
- name: Upload results
uses: actions/upload-artifact@v4
with:
name: image-cache
path: ./cache
web:
runs-on: ubuntu-latest
env:
PYTHONUTF8: 1
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Prepare Vite
run: |
cd ./src/web && npm install
- name: Set Build Env
shell: bash
run: |
echo -e "VITE_NOSERVER=1\nVITE_COMMIT_ID=${{ github.sha }}\nVITE_BUILD_DATE=$(date -Iseconds)" > ./src/web/.env
- name: Build
run: |
cd ./src/web && npm run build
- name: Upload results
uses: actions/upload-artifact@v4
with:
name: web-dist
path: ./src/web/dist
docs:
runs-on: ubuntu-latest
env:
PYTHONUTF8: 1
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x64'
- name: Setup paperead
run: pip install paperead
- name: Generate documents
run: |
cd docs
paperead build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: docs
path: ./docs/dist
deploy:
if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' || github.event_name == 'release' }}
needs: [image, docs, package, web]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
deploy-docs:
needs: [deploy]
runs-on: ubuntu-latest
env:
PYTHONUTF8: 1
steps:
- name: Download docs artifacts
uses: actions/download-artifact@v4
with:
name: docs
path: ./dist
- name: Add redirects
shell: bash
run: |
echo -e "/* /index.html 200" > ./dist/_redirects
- name: Deploy docs to netlify
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: netlify/actions/cli@master
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DOC_SITE_ID }}
with:
args: deploy --dir=./dist --prod
secrets: '["NETLIFY_AUTH_TOKEN", "NETLIFY_SITE_ID"]'
deploy-web:
needs: [deploy]
runs-on: ubuntu-latest
steps:
- name: Download app artifacts
uses: actions/download-artifact@v4
with:
name: web-dist
path: ./dist
- name: Add redirects
shell: bash
run: |
echo -e "/data https://aexpy-docs.netlify.app/data 301\n/change-spec https://aexpy-docs.netlify.app/change-spec 301\n/* /index.html 200" > ./dist/_redirects
- name: Deploy docs to netlify
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: netlify/actions/cli@master
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_APP_SITE_ID }}
with:
args: deploy --dir=./dist --prod
secrets: '["NETLIFY_AUTH_TOKEN", "NETLIFY_SITE_ID"]'
deploy-package:
needs: [deploy]
runs-on: ubuntu-latest
steps:
- name: Download package artifacts
uses: actions/download-artifact@v4
with:
name: package
path: ./dist
- name: Deploy packages
if: ${{ github.event_name == 'release' }}
env:
TWINE_USERNAME: '__token__'
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python -m pip install --upgrade twine
python -m twine upload --skip-existing --repository pypi "dist/*"
deploy-image:
needs: [deploy]
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Image Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: stardustdl/aexpy
- name: Set BUILD_DATE
run: echo "BUILD_DATE=$(date -Ins)" >> $GITHUB_ENV
- name: Deploy image
uses: docker/build-push-action@v5
with:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GIT_COMMIT=${{ github.sha }}
BUILD_DATE=${{ env.BUILD_DATE }}