-
Notifications
You must be signed in to change notification settings - Fork 4
150 lines (139 loc) · 4.3 KB
/
check.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
name: Check
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
paths-ignore:
- "**/*.md"
merge_group:
jobs:
check-dev:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Setup python tools
- name: Get pipx environment
id: pipx-env
run: |
echo "VERSION=$(pipx --version)" >> $GITHUB_OUTPUT
echo "BIN_DIR=$(pipx environment -v PIPX_BIN_DIR)" >> $GITHUB_OUTPUT
echo "LOCAL_VENVS=$(pipx environment -v PIPX_LOCAL_VENVS)" >> $GITHUB_OUTPUT
- name: Cache poetry
uses: actions/cache@v4
with:
key: ${{ runner.os }}-pipx@${{ steps.pipx-env.outputs.VERSION }}[email protected]
path: |
${{ steps.pipx-env.outputs.LOCAL_VENVS }}/poetry/
${{ steps.pipx-env.outputs.BIN_DIR }}/poetry
- name: Install poetry
run: pipx install poetry==1.8.1
- name: Configure poetry for in-project venv
run: |
poetry config virtualenvs.in-project true
echo 'PYTHON = "./.venv/bin/python"' > .env
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: poetry
# Setup other tools
- name: Setup just
uses: taiki-e/install-action@v2
with:
tool: just
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 18
cache: pnpm
cache-dependency-path: |
contest/*/static_src/pnpm-lock.yaml
# Install and update
- run: just update-dependencies
# Build and check
- run: just build-theme
- run: just build-js
- name: Upload front-end artifacts
uses: actions/upload-artifact@v4
with:
name: front-end
path: |
contest/js/static/js/dist/
contest/theme/static/css/dist/
# The root directory of the artifact is the least common ancestor, i.e. `contest/`.
if-no-files-found: error
retention-days: 7
- name: Find recent commits
id: git-rev
run: |
echo "HEAD=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "MERGE_BASE=$(git merge-base HEAD origin/main)" >> $GITHUB_OUTPUT
- name: Cache mypy
uses: actions/cache@v4
with:
key: mypy-cache-${{ steps.git-rev.outputs.HEAD }}
restore-keys: |
mypy-cache-${{ steps.git-rev.outputs.MERGE_BASE }}
mypy-cache-
path: |
.mypy_cache/
- run: just check-all
check-deploy:
runs-on: ubuntu-latest
needs: check-dev
env:
# 内容都不重要
DJANGO_PRODUCTION: Israfel
SECRET_KEY: Israfel is the Seventh Angel, capable of splitting itself into two identical copies for simultaneous attacks.
steps:
- uses: actions/checkout@v4
# Setup python tools
- name: Get pipx environment
id: pipx-env
run: |
echo "VERSION=$(pipx --version)" >> $GITHUB_OUTPUT
echo "BIN_DIR=$(pipx environment -v PIPX_BIN_DIR)" >> $GITHUB_OUTPUT
echo "LOCAL_VENVS=$(pipx environment -v PIPX_LOCAL_VENVS)" >> $GITHUB_OUTPUT
- name: Cache poetry
uses: actions/cache@v4
with:
key: ${{ runner.os }}-pipx@${{ steps.pipx-env.outputs.VERSION }}[email protected]
path: |
${{ steps.pipx-env.outputs.LOCAL_VENVS }}/poetry/
${{ steps.pipx-env.outputs.BIN_DIR }}/poetry
- name: Install poetry
run: pipx install poetry==1.8.1
- name: Configure poetry for in-project venv
run: |
poetry config virtualenvs.in-project true
echo 'PYTHON = "./.venv/bin/python"' > .env
- name: Cache python dependencies
uses: actions/cache@v4
with:
key: |
venv-without-dev-${{ runner.os }}[email protected]@1.8.1-${{ hashFiles('poetry.lock') }}
# 这里忽略了 python 小版本
path: |
.venv/
- uses: actions/setup-python@v5
with:
python-version: '3.12'
# Setup other tools
- name: Setup just
uses: taiki-e/install-action@v2
with:
tool: just
# Install and update
- run: just update-dependencies
- name: Download front-end artifacts
uses: actions/download-artifact@v4
with:
name: front-end
path: contest/
# Check
- run: just check-deploy
# 会有警告,但正常退出