Skip to content

Commit b587d46

Browse files
WasimFei-Away
authored andcommitted
ci: Add GitHub Actions workflow for static checks
1 parent 1ab7128 commit b587d46

4 files changed

Lines changed: 118 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ci-${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
static-checks:
18+
name: Static checks
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: "22"
25+
26+
- name: Check shell syntax
27+
shell: bash
28+
run: |
29+
while IFS= read -r file; do
30+
bash -n "$file"
31+
done < <(
32+
find macos -type f \( -name '*.sh' -o -name '*.command' \) \
33+
! -path '*/release/*' -print
34+
)
35+
36+
- name: Check Node.js syntax
37+
shell: bash
38+
run: |
39+
while IFS= read -r file; do
40+
node --check "$file" >/dev/null
41+
done < <(
42+
find macos windows -type f \( -name '*.mjs' -o -name '*.js' \) -print
43+
)
44+
45+
- name: Check Windows PowerShell source encoding
46+
shell: bash
47+
run: |
48+
node <<'NODE'
49+
const fs = require("node:fs");
50+
const path = require("node:path");
51+
52+
function visit(directory) {
53+
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
54+
const file = path.join(directory, entry.name);
55+
if (entry.isDirectory()) visit(file);
56+
if (!entry.isFile() || path.extname(file) !== ".ps1") continue;
57+
const bytes = fs.readFileSync(file);
58+
const hasBom = bytes.subarray(0, 3).equals(Buffer.from([0xef, 0xbb, 0xbf]));
59+
const content = hasBom ? bytes.subarray(3) : bytes;
60+
if (content.some((byte) => byte >= 0x80) && !hasBom) {
61+
throw new Error(`${file}: non-ASCII PowerShell 5.1 source requires a UTF-8 BOM`);
62+
}
63+
}
64+
}
65+
66+
visit("windows");
67+
NODE
68+
69+
- name: Check runtime safety assertions
70+
shell: bash
71+
run: |
72+
if grep -R -n -E 'dream-skin-skin|DREAM_SKIN_SKIN|1\.0\.0-rc2' \
73+
macos/scripts macos/assets >/dev/null; then
74+
printf 'Legacy release-candidate identifiers remain in runtime files.\n' >&2
75+
exit 1
76+
fi
77+
if grep -R -n -E '(writeFile|rename|copyFile|rm).*app\.asar' \
78+
macos/scripts >/dev/null; then
79+
printf 'A runtime script appears to mutate app.asar.\n' >&2
80+
exit 1
81+
fi
82+
if grep -n -E '/usr/bin/python3|(^|[[:space:]])eval([[:space:]]|$)' \
83+
macos/scripts/common-macos.sh >/dev/null; then
84+
printf 'The macOS runtime must parse state without python3 or eval.\n' >&2
85+
exit 1
86+
fi
87+
88+
- name: Check version consistency
89+
shell: bash
90+
run: |
91+
expected="$(tr -d '\r\n' < macos/VERSION)"
92+
common="$(sed -n 's/^SKIN_VERSION="\([^"]*\)"$/\1/p' macos/scripts/common-macos.sh)"
93+
macos_injector="$(sed -n 's/^const SKIN_VERSION = "\([^"]*\)";$/\1/p' macos/scripts/injector.mjs)"
94+
windows_injector="$(sed -n 's/^const SKIN_VERSION = "\([^"]*\)";$/\1/p' windows/scripts/injector.mjs)"
95+
test -n "$expected"
96+
test "$common" = "$expected"
97+
test "$macos_injector" = "$expected"
98+
test "$windows_injector" = "$expected"
99+
100+
windows-tests:
101+
name: Windows tests
102+
runs-on: windows-latest
103+
steps:
104+
- uses: actions/checkout@v4
105+
- uses: actions/setup-node@v4
106+
with:
107+
node-version: "22"
108+
109+
- name: Windows PowerShell 5.1
110+
shell: cmd
111+
run: powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\windows\tests\run-tests.ps1
112+
113+
- name: PowerShell 7
114+
shell: pwsh
115+
run: .\windows\tests\run-tests.ps1

windows/scripts/theme-windows.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if (-not (Get-Command Read-DreamSkinUtf8File -ErrorAction SilentlyContinue)) {
1+
if (-not (Get-Command Read-DreamSkinUtf8File -ErrorAction SilentlyContinue)) {
22
. (Join-Path $PSScriptRoot 'config-utf8.ps1')
33
}
44

windows/scripts/tray-dream-skin.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[CmdletBinding()]
1+
[CmdletBinding()]
22
param([int]$Port = 9335)
33

44
$ErrorActionPreference = 'Stop'

windows/tests/run-tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[CmdletBinding()]
1+
[CmdletBinding()]
22
param()
33

44
$ErrorActionPreference = 'Stop'

0 commit comments

Comments
 (0)