From c8eff32cafe00d33bd3dca9f62da31b13e234f2a Mon Sep 17 00:00:00 2001 From: qiyinxi Date: Sat, 5 Dec 2026 22:36:36 +0100 Subject: [PATCH 1/2] =?UTF-8?q?CI=EF=BC=9AWindows=20=E4=B8=8A=E8=B7=B3?= =?UTF-8?q?=E8=BF=87=E5=AE=A2=E4=BD=93=20shell=20=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=EF=BC=8Cgo=20=E7=BC=96=E8=AF=91=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit internal/guest 的 *_sh_test.go(dldisk、gles32、installerx、libfix、playstore、quietnotifs、reswatch、vkmode)、 internal/emu 的 appproxy、bridge 和 game_import 里用真 sh 的几个测试,测的都是只在安卓客体里跑的脚本。 Windows 的 CI 上它们用 Git 自带的 sh,起子进程极慢(internal/guest 375 秒),Linux 和 macOS 的 portable 作业已经在跑同一批且很快。加 testutil.SkipGuestShellOnWindows,在这些测试开头跳过。 ci.yml:checks 作业不再把 Git 的 usr\bin 放进 PATH、不再设 MODAVD_REQUIRE_INSTALLERX_SH;这条「不许因缺工具而跳过」 的保护改到 portable 的 ubuntu 上。两处 setup-go 打开编译缓存(没有 go.sum,按 go.mod 作缓存键)。 Refs ModAVD/ModAVD#403 --- .github/workflows/ci.yml | 17 +++++++++-------- internal/emu/appproxy_sh_test.go | 1 + internal/emu/bridge_sh_test.go | 1 + internal/emu/game_import_parse_test.go | 2 ++ internal/emu/game_import_stage_test.go | 2 ++ internal/emu/game_import_test.go | 2 ++ internal/guest/dldisk_sh_test.go | 1 + internal/guest/gles32_sh_test.go | 1 + internal/guest/installerx_sh_test.go | 1 + internal/guest/libfix_sh_test.go | 1 + internal/guest/playstore_sh_test.go | 1 + internal/guest/quietnotifs_sh_test.go | 1 + internal/guest/reswatch_sh_test.go | 1 + internal/guest/vkmode_sh_test.go | 1 + internal/testutil/guestsh.go | 19 +++++++++++++++++++ 15 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 internal/testutil/guestsh.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33095eba..4be26d87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,8 @@ jobs: - uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0 with: go-version: ${{ steps.go.outputs.version }} - cache: false + cache: true + cache-dependency-path: go.mod - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 @@ -53,13 +54,9 @@ jobs: if ($bad) { $bad; throw 'gofmt required' } - name: go vet run: go vet ./... + # Guest shell script tests are skipped on Windows (Git's sh is far too slow); Linux and macOS run them. - name: go test - shell: pwsh - run: | - $gitRoot = Split-Path -Parent (Split-Path -Parent (Get-Command git).Source) - $env:Path = "$(Join-Path $gitRoot 'usr\bin');$env:Path" - $env:MODAVD_REQUIRE_INSTALLERX_SH = '1' - go test ./... + run: go test ./... - name: cross-platform vet shell: pwsh run: | @@ -149,10 +146,14 @@ jobs: - uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0 with: go-version: ${{ steps.go.outputs.version }} - cache: false + cache: true + cache-dependency-path: go.mod - name: go vet run: go vet ./... - name: go test + # Linux must run the InstallerX guest script tests, not skip them for a missing tool. + env: + MODAVD_REQUIRE_INSTALLERX_SH: ${{ matrix.os == 'ubuntu-24.04' && '1' || '' }} run: go test ./... create-cancel: diff --git a/internal/emu/appproxy_sh_test.go b/internal/emu/appproxy_sh_test.go index 77e88ac8..34ad10fa 100644 --- a/internal/emu/appproxy_sh_test.go +++ b/internal/emu/appproxy_sh_test.go @@ -21,6 +21,7 @@ func TestReplaceDaemonScriptSh(t *testing.T) { t.Fatalf("a single quote (Manager.su puts the script inside single quotes): %s", s) } } + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/emu/bridge_sh_test.go b/internal/emu/bridge_sh_test.go index d7749209..fccb3f5d 100644 --- a/internal/emu/bridge_sh_test.go +++ b/internal/emu/bridge_sh_test.go @@ -18,6 +18,7 @@ import ( // files: one current, one different, one missing and, where permissions can deny reading (not as root, not on // Windows), one unreadable. Its output goes through payloadStale. func TestBridgeGuestHashScriptSh(t *testing.T) { + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/emu/game_import_parse_test.go b/internal/emu/game_import_parse_test.go index 95153412..c45b83e5 100644 --- a/internal/emu/game_import_parse_test.go +++ b/internal/emu/game_import_parse_test.go @@ -9,6 +9,7 @@ import ( "testing" "modavd/internal/errs" + "modavd/internal/testutil" ) // The functions below take text the source emulator produced, or build commands from it. Nothing here starts adb. @@ -31,6 +32,7 @@ func TestImportQuote(t *testing.T) { } func TestImportQuoteWithRealShell(t *testing.T) { + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/emu/game_import_stage_test.go b/internal/emu/game_import_stage_test.go index 973dfa83..aabc5531 100644 --- a/internal/emu/game_import_stage_test.go +++ b/internal/emu/game_import_stage_test.go @@ -15,12 +15,14 @@ import ( "modavd/internal/errs" "modavd/internal/logx" + "modavd/internal/testutil" ) // posixShell runs guest scripts with a real POSIX shell on this computer (the test is skipped without one). Git for // Windows keeps its tools in ..\usr\bin; Windows' own find.exe and sort.exe must not be the ones that run. func posixShell(t *testing.T) (string, func(script string) (string, error)) { t.Helper() + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/emu/game_import_test.go b/internal/emu/game_import_test.go index a876139d..fb7dd8d7 100644 --- a/internal/emu/game_import_test.go +++ b/internal/emu/game_import_test.go @@ -18,6 +18,7 @@ import ( "modavd/internal/errs" "modavd/internal/logx" + "modavd/internal/testutil" ) // scriptedGuest answers the shell commands of the import code the way a guest would, and records every script. @@ -215,6 +216,7 @@ func TestRemoveStaleImportDirsKeepsGoingAfterAFailure(t *testing.T) { // Runs the generated command with a real POSIX shell (skipped without one) on a temporary directory. func TestRemoveStaleImportDirsOnDisk(t *testing.T) { + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/guest/dldisk_sh_test.go b/internal/guest/dldisk_sh_test.go index c564c661..9f08ca5f 100644 --- a/internal/guest/dldisk_sh_test.go +++ b/internal/guest/dldisk_sh_test.go @@ -42,6 +42,7 @@ const ( func newDDGuest(t *testing.T) *ddGuest { t.Helper() + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/guest/gles32_sh_test.go b/internal/guest/gles32_sh_test.go index c11fd61f..cc8bdd5e 100644 --- a/internal/guest/gles32_sh_test.go +++ b/internal/guest/gles32_sh_test.go @@ -29,6 +29,7 @@ type glGuest struct { func newGLGuest(t *testing.T) *glGuest { t.Helper() + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/guest/installerx_sh_test.go b/internal/guest/installerx_sh_test.go index 83d4ce0d..573011c1 100644 --- a/internal/guest/installerx_sh_test.go +++ b/internal/guest/installerx_sh_test.go @@ -30,6 +30,7 @@ func newIXGuest(t *testing.T) *ixGuest { } t.Skip(reason) } + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { missing("no sh") diff --git a/internal/guest/libfix_sh_test.go b/internal/guest/libfix_sh_test.go index fc45278f..1665f75f 100644 --- a/internal/guest/libfix_sh_test.go +++ b/internal/guest/libfix_sh_test.go @@ -50,6 +50,7 @@ func (l lfLib) args() []string { func newLFGuest(t *testing.T) *lfGuest { t.Helper() + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/guest/playstore_sh_test.go b/internal/guest/playstore_sh_test.go index 425f7fcf..6639a2d8 100644 --- a/internal/guest/playstore_sh_test.go +++ b/internal/guest/playstore_sh_test.go @@ -29,6 +29,7 @@ type psGuest struct { func newPSGuest(t *testing.T) *psGuest { t.Helper() + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/guest/quietnotifs_sh_test.go b/internal/guest/quietnotifs_sh_test.go index a01487ca..ff624def 100644 --- a/internal/guest/quietnotifs_sh_test.go +++ b/internal/guest/quietnotifs_sh_test.go @@ -37,6 +37,7 @@ const qnStockPolicy = " NetworkPolicy{template=NetworkTemplate: matchRule=CARRI func newQNGuest(t *testing.T) *qnGuest { t.Helper() + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/guest/reswatch_sh_test.go b/internal/guest/reswatch_sh_test.go index d697d9d3..7f20aa33 100644 --- a/internal/guest/reswatch_sh_test.go +++ b/internal/guest/reswatch_sh_test.go @@ -53,6 +53,7 @@ const ( func newRWGuest(t *testing.T) *rwGuest { t.Helper() + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/guest/vkmode_sh_test.go b/internal/guest/vkmode_sh_test.go index d112c127..21e941a7 100644 --- a/internal/guest/vkmode_sh_test.go +++ b/internal/guest/vkmode_sh_test.go @@ -37,6 +37,7 @@ func vkFiles(pkg string) string { return vkMedia + "/" + pkg + "/files" } func newVKGuest(t *testing.T) *vkGuest { t.Helper() + testutil.SkipGuestShellOnWindows(t) sh, err := exec.LookPath("sh") if err != nil { t.Skip("no sh") diff --git a/internal/testutil/guestsh.go b/internal/testutil/guestsh.go new file mode 100644 index 00000000..663d655e --- /dev/null +++ b/internal/testutil/guestsh.go @@ -0,0 +1,19 @@ +// Copyright 2026 Ji Mao Cai +// SPDX-License-Identifier: AGPL-3.0-or-later + +package testutil + +import ( + "runtime" + "testing" +) + +// SkipGuestShellOnWindows skips a test that runs a guest (Android) shell script in a POSIX sh on this computer. +// The scripts only ever run in the guest, and Linux and macOS CI cover them; Git's sh on Windows starts child +// processes so slowly that these tests took minutes there. +func SkipGuestShellOnWindows(t testing.TB) { + t.Helper() + if runtime.GOOS == "windows" { + t.Skip("guest shell scripts are tested on Linux and macOS; Git's sh on Windows is too slow") + } +} From 26b8d405e34540ca37a0292de4925ff522292cf6 Mon Sep 17 00:00:00 2001 From: qiyinxi Date: Sat, 5 Dec 2026 22:38:17 +0100 Subject: [PATCH 2/2] =?UTF-8?q?CI=EF=BC=9A=E6=92=A4=E5=9B=9E=20Go=20?= =?UTF-8?q?=E7=BC=93=E5=AD=98=EF=BC=88zizmor=20=E5=88=A4=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=8A=95=E6=AF=92=E9=A3=8E=E9=99=A9=EF=BC=8C=E7=9C=81=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E4=B8=8D=E5=A4=9A=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs ModAVD/ModAVD#403 --- .github/workflows/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4be26d87..f6b39ddd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,8 +34,7 @@ jobs: - uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0 with: go-version: ${{ steps.go.outputs.version }} - cache: true - cache-dependency-path: go.mod + cache: false - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 @@ -146,8 +145,7 @@ jobs: - uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0 with: go-version: ${{ steps.go.outputs.version }} - cache: true - cache-dependency-path: go.mod + cache: false - name: go vet run: go vet ./... - name: go test