forked from AstrBotDevs/AstrBot
-
Notifications
You must be signed in to change notification settings - Fork 1
143 lines (134 loc) · 4.73 KB
/
Copy pathcode-format.yml
File metadata and controls
143 lines (134 loc) · 4.73 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
name: Code Format Check
on:
pull_request:
branches: [master, staging]
push:
branches: [master, staging]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
python:
name: Python (ruff)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
with:
python-version: '3.14.6'
- name: Install uv
run: pip install uv
- name: Install dependencies
run: bash scripts/uv_sync_ci.sh --group dev --locked
- name: ruff format + check
run: make check-py
web:
name: Web (eslint + prettier)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
with:
python-version: '3.14.6'
- name: Install uv
run: python -m pip install uv
- name: Install Python dependencies
run: bash scripts/uv_sync_ci.sh --group dev --locked
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: '26.5.0'
package-manager-cache: false
- name: Setup pnpm
uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
with:
version: 11.21.0
- name: Install root toolchain
run: npm ci
- name: Install dashboard deps
working-directory: dashboard
run: pnpm install --frozen-lockfile
- name: typecheck + eslint + prettier
run: make check-web
data:
name: Data (json/css/html/toml/yaml/markdown)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
with:
python-version: '3.14.6'
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
with:
node-version: '26.5.0'
package-manager-cache: false
- name: Install uv
run: pip install uv
- name: Install dependencies
run: bash scripts/uv_sync_ci.sh --group dev --locked
- name: Install root toolchain
run: npm ci
- name: Check json/css/html
run: make check-data
- name: Check toml
run: make check-toml
- name: Check yaml
run: make check-yaml
- name: Check markdown
run: make check-md
shell:
name: Shell (shellcheck + shfmt)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: Install shellcheck + shfmt
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
curl --fail --location --proto '=https' --tlsv1.2 --http1.1 \
--retry 5 --retry-all-errors --retry-delay 2 --connect-timeout 30 \
"https://github.com/mvdan/sh/releases/download/v3.13.1/shfmt_v3.13.1_linux_amd64" \
-o "$tmpdir/shfmt"
sudo install -m 0755 "$tmpdir/shfmt" /usr/local/bin/shfmt
shfmt --version
- name: shfmt + shellcheck
run: make check-shell
docker:
name: Dockerfile and Compose
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: hadolint
uses: hadolint/hadolint-action@2332a7b74a6de0dda2e2221d575162eba76ba5e5 # v3.3.0
with:
dockerfile: Dockerfile
config: .hadolint.yaml
- name: Validate Compose and Docker build definitions
run: |
docker compose -f compose.yml config --quiet
docker compose -f compose-with-napcat.yml config --quiet
for attempt in 1 2 3; do
if docker compose --dry-run -f compose.yml build astrbot && \
docker build --check --file Dockerfile .; then
exit 0
fi
if [ "$attempt" -lt 3 ]; then
sleep $((attempt * 10))
fi
done
exit 1
powershell:
name: PowerShell (PSScriptAnalyzer)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: Install PSScriptAnalyzer
shell: pwsh
run: Install-Module PSScriptAnalyzer -Scope CurrentUser -Force -SkipPublisherCheck
- name: Invoke-ScriptAnalyzer
shell: pwsh
run: ./scripts/lint_powershell.ps1