Files
magpie/.github/workflows/test.yml
T
XYenonandAmp 69368007b0 termux: support Android builds and installation (#644)
* termux: build natively and run plugins on Bun 1.4.2

Select nogui for Android builds, open browser and OAuth links with
termux-open-url, and write an executable Termux:Boot script that starts
the gateway with shell-quoted paths.

Bun 1.3 has no official Android build. Upgrade the default plugin runtime
to 1.4.2, add the official Android arm64 and amd64 download targets, and
update SHA-256 checksums for every supported platform.

Document Termux installation, startup and source updates.

Validation on Termux arm64:
- Native build and go vet pass.
- A fresh config downloads and verifies Android Bun 1.4.2 and loads a
  test plugin.
- Boot startup can be enabled and disabled.
- The Web page, authenticated state API, unauthenticated API rejection,
  gateway healthcheck and Web quit action work.
- Browser argument preservation, boot path quoting and permissions, and
  plugin tests pass.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a10014-56c1-73d3-b3ee-2ea569713989

* site: install Android builds in Termux

Detect Termux through TERMUX_VERSION or its PREFIX and select the Android
CLI asset instead of a Linux binary. Install into PREFIX/bin by default,
keep MAGPIE_BIN_DIR overrides, and suggest the Web or terminal interface
without Linux desktop setup instructions.

When the release has no Android asset, explain how to build from source.
Add android/arm64 to release-cli and stop the build loop on failure.
Document the installer and its release-asset requirement.

Shell syntax and all 11 site tests pass, covering platform selection,
custom paths, missing assets, checksum rejection and existing Linux
installation paths. The Android arm64 release build succeeds on Termux;
with a simulated release feed, the installer verifies and installs that
binary into PREFIX/bin and the installed command runs successfully.

Amp-Thread-ID: https://ampcode.com/threads/T-01a10014-56c1-73d3-b3ee-2ea569713989
Co-authored-by: Amp <amp@ampcode.com>

* ci: check Android releases and the installer

Build both linux/amd64 and android/arm64 through make release-cli in the
CLI test matrix. Run the site and installer tests in the Linux job with
Node 22, and check the installer's shell syntax.

The release workflow in yetone/magpie-releases already calls the source
Makefile's release-cli target, uploads dist/magpie-cli-*, and generates
checksums for every artifact. The Android target added to TARGETS is
therefore included without changing that workflow.

Replace the full Termux README section with a short platform note beside
the Linux and Windows installation requirements, removing duplicate
commands, the fork URL and temporary release availability details.

Both CLI release builds, all 11 site tests, shell syntax checks and
actionlint validation pass locally.

Amp-Thread-ID: https://ampcode.com/threads/T-01a10014-56c1-73d3-b3ee-2ea569713989
Co-authored-by: Amp <amp@ampcode.com>

---------

Co-authored-by: Amp <amp@ampcode.com>
2026-10-03 14:29:32 +08:00

111 lines
3.7 KiB
YAML

name: Test
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: test-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
# The GUI links GTK 3 and WebKitGTK 4.1 through cgo on Linux (see the
# Makefile), so vet and test need their headers and the gtk3 tag.
- name: Install GTK and WebKitGTK
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev
- name: Tags
id: tags
shell: bash
run: |
if [ "$RUNNER_OS" = Linux ]; then echo "tags=gtk3" >> "$GITHUB_OUTPUT"; fi
- name: Vet
run: go vet -tags "${{ steps.tags.outputs.tags }}" ./...
- name: Test
if: runner.os != 'Windows'
run: go test -tags "${{ steps.tags.outputs.tags }}" ./...
# The redaction tests reuse this binary in fresh processes to check
# first-use races, so it must include the race detector.
- name: Race
if: runner.os != 'Windows'
# The full gateway suite can exceed Go's default 10-minute package
# timeout under the race detector on hosted macOS runners.
run: go test -race -timeout 20m -tags "${{ steps.tags.outputs.tags }}" ./internal/gateway/ ./internal/redact/
# Account usage mixes cached results with concurrent fetches.
- name: Race account usage
if: runner.os != 'Windows'
run: go test -race -tags "${{ steps.tags.outputs.tags }}" ./internal/provider/ -run '^Test(LoginUsage|SubscriptionUsageEachAccount)'
# Some tests fake a home through $HOME, which Windows doesn't read
# (USERPROFILE), or assume Unix file modes. Compile the full suite
# on Windows and run the isolated native checks below.
- name: Compile tests
if: runner.os == 'Windows'
run: go test -run '^$' ./...
# Usage isolates USERPROFILE and the agent homes; execute its native
# ChangeTime checks rather than only cross-compiling the Windows API.
- name: Windows usage cache
if: runner.os == 'Windows'
run: go test -v -count=1 ./internal/usage -run '^(TestWindows|TestLogChange|TestLogFileInfoPreservesIdentity$|TestUsageSameSizeAndMtimeRewrite$|TestLogGrowingRewriteThenAppend$|TestUsagePageCacheAfterUncachedQuery$)'
# Install tests keep their files in t.TempDir; exercise real Windows
# executable and held-handle rename/rollback behavior.
- name: Windows update install
if: runner.os == 'Windows'
run: go test -v -count=1 -timeout 2m ./internal/update -run '^(TestInstallBinary|TestMoveAside)'
cli:
name: cli (${{ matrix.goos }}/${{ matrix.goarch }}, nogui)
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
- goos: android
goarch: arm64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build the terminal-only release
env:
CGO_ENABLED: '0'
run: make release-cli TARGETS="${{ matrix.goos }}/${{ matrix.goarch }}"
- uses: actions/setup-node@v4
if: matrix.goos == 'linux'
with:
node-version: 22
- name: Test the site and installer
if: matrix.goos == 'linux'
run: |
sh -n site/public/install.sh
node --test site/*.test.mjs