Repository navigation
162 lines (147 loc) · 6.32 KB
/
Copy pathlinux.yml
File metadata and controls
162 lines (147 loc) · 6.32 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
name: Linux CI
on:
pull_request:
branches:
- main
paths-ignore:
- README.md
- docs/**
push:
branches:
- main
paths-ignore:
- README.md
- docs/**
workflow_dispatch:
concurrency:
group: linux-${{ github.workflow }}-${{ github.ref }}
# PR 的新提交取消旧运行;main 上每个提交都必须完整验收。
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions:
contents: read
jobs:
build:
name: Build unsigned Linux artifacts
runs-on: ubuntu-24.04
timeout-minutes: 25
steps:
- name: Check out source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- name: Run acceptance checks
shell: bash
run: |
set -euo pipefail
go mod verify
formatted="$(gofmt -l $(git ls-files '*.go'))"
if [ -n "$formatted" ]; then
printf 'These Go files are not formatted:\n%s\n' "$formatted" >&2
exit 1
fi
go build -trimpath -p 4 ./...
go vet -trimpath -p 4 ./...
# Linux 最小可发行版本明确不实现的能力:AAC/M4A 解码
# (internal/service/audio)、视频流(internal/service/video)、
# 随包字体(internal/ui/widgets/typo)。这些包的测试在 Linux 上
# 确定性失败——排除是「当前不支持」,不是「测试坏了」,能力落地时
# 从这里删掉对应行,不是把测试改绿。
LINUX_UNSUPPORTED_TEST_PACKAGES=(
github.com/ShellMonster/PudMusic/internal/service/audio
github.com/ShellMonster/PudMusic/internal/service/video
github.com/ShellMonster/PudMusic/internal/ui/widgets/typo
)
printf -v unsupported '%s\n' "${LINUX_UNSUPPORTED_TEST_PACKAGES[@]}"
go test -p 4 $(
go list ./... \
| grep -v '/internal/ui$' \
| grep -vxFf <(printf '%s' "$unsupported")
)
go test ./internal/licensing/
go generate ./internal/platform/ ./internal/licensing/
git diff --exit-code -- resources
- name: Build unsigned Linux artifacts
shell: bash
run: |
set -euo pipefail
unset MYGO_UPDATER_PRIVATE_KEY
go tool mygo build -platform linux/amd64,linux/arm64
- name: Validate Linux artifacts
shell: bash
run: |
set -euo pipefail
for target in linux-amd64 linux-arm64; do
dir="build/$target"
test -d "$dir" || { echo "missing $dir"; exit 1; }
# 原生 UI:不拉 WebKitGTK。这是 mygo.json 的 linux.webview=false
# 该换来的产物事实——少了它就是配置没生效。
test -f "$dir/pudmusic" || { echo "$target: missing executable"; exit 1; }
test -f "$dir/pudmusic.desktop" || { echo "$target: missing desktop entry"; exit 1; }
test -f "$dir/install.sh" || { echo "$target: missing install.sh"; exit 1; }
tar -tzf "$dir"/*-linux-*.tar.gz >/dev/null
# Linux 上没有 AAC 解码器:desktop entry 不得登记 m4a / aac。
# 这是「Linux 不登记放不了的格式」那份承诺在产物上的样子——
# mygo.json 的 fileAssociations 已裁掉,这里断的是「真打出来
# 的包里没有」,免得哪天配置又被加回去。
if grep -qiE 'm4a|aac' "$dir/pudmusic.desktop"; then
echo "$target desktop entry still registers AAC/M4A:"; cat "$dir/pudmusic.desktop"; exit 1
fi
deps="$(ar p "$dir"/*.deb control.tar.gz 2>/dev/null | tar -xzOf - ./control 2>/dev/null | grep '^Depends:' || true)"
echo "$target deb Depends: $deps"
case "$deps" in
*webkit*) echo "$target deb still depends on WebKitGTK: $deps"; exit 1 ;;
esac
case "$deps" in
*ayatana*|*appindicator*) ;;
*) echo "$target deb lacks the tray dependency (ayatana-appindicator): $deps"; exit 1 ;;
esac
done
echo "Linux artifacts look right"
- name: Upload Linux artifacts
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: linux-artifacts
path: |
build/linux-amd64
build/linux-arm64
retention-days: 14
if-no-files-found: error
e2e:
name: Linux lifecycle E2E
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- name: Check out source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- name: Install a virtual display and the GTK tray library
run: |
sudo apt-get update
sudo apt-get install -y xvfb libgtk-3-0t64 libayatana-appindicator3-1 dbus-x11
- name: Run Linux lifecycle E2E under Xvfb
shell: bash
run: |
set -euo pipefail
# 三条一起跑(一条命令、一次编译):
# 起得来(窗口画得出来)、第二个实例递完命令行自己退出、
# 托盘菜单的「退出程序」真的让进程退出来(走 E2E 钩子——
# Xvfb 下没有面板画 AppIndicator 菜单,窗口上也没有菜单栏)。
# 外加文件关联那一族:.m4a 有一句「放不了」、.flac 真的放起来。
#
# ⚠️ dbus-x11 + dbus-run-session:托盘是 AppIndicator,要走
# session bus;没有它 `installTray` 只是建不出来(记一行日志、
# 应用继续跑),而「窗口收进托盘之后怎么回来」这条就没人验。
xvfb-run -a dbus-run-session -- \
env BIU_RUN_MYGO_E2E=1 \
go test -tags e2e ./internal/e2e \
-run 'TestLinuxLifecycle|TestLinuxFileAssociations' \
-count=1 -timeout 300s