Add Alpine package test shell

This commit is contained in:
Joachim Schlöffel
2026-06-07 22:29:58 +02:00
parent 6ef5cae2b2
commit 772eba1e20
3 changed files with 70 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ mise run apk:checksum
mise run apk:lint
mise run apk:packages
mise run apk:smoke
mise run apk:test-shell
mise run apk:publish-check
mise run apk:shell
mise run apk:clean
@@ -53,11 +54,16 @@ cached in `.cache/abuild/` and `.cache/apk-distfiles/`.
```sh
mise run apk:smoke
mise run apk:test-shell
mise run apk:publish-check
```
`apk:publish-check` runs APKBUILD linting, rebuilds configured architectures,
lists package metadata, and installs the built packages in an Alpine container.
`apk:test-shell` builds the selected architecture, installs the local package
set in an Alpine container, and opens a shell. Use `SKIP_BUILD=1` to reuse an
existing local repository. Set `TEST_SHELL_TIMEOUT` to adjust the timeout for
`apk update` and `apk add` inside the test container.
Install from the local repo with the base package plus the role-specific OpenRC
subpackage you need:

View File

@@ -35,6 +35,10 @@ run = "scripts/apk/build.sh lint"
description = "Install-test built packages from the local repository in Docker"
run = "scripts/apk/smoke.sh"
[tasks."apk:test-shell"]
description = "Open an Alpine shell with the current local package build installed"
run = "scripts/apk/test-shell.sh"
[tasks."apk:packages"]
description = "List built Alpine packages and dependencies"
run = "scripts/apk/list-packages.sh"

60
scripts/apk/test-shell.sh Executable file
View File

@@ -0,0 +1,60 @@
#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
alpine_version="${ALPINE_VERSION:-3.22}"
platform="${ALPINE_BUILD_PLATFORM:-linux/amd64}"
arch="${ALPINE_ARCH:-x86_64}"
packages="${TEST_SHELL_PACKAGES:-seaweedfs seaweedfs-doc bash-completion seaweedfs-master-openrc seaweedfs-filer-openrc seaweedfs-worker-openrc}"
shell="${TEST_SHELL:-/bin/bash}"
timeout_seconds="${TEST_SHELL_TIMEOUT:-120}"
case "${arch}" in
x86_64|aarch64) ;;
*) printf 'unsupported Alpine architecture: %s\n' "${arch}" >&2; exit 2 ;;
esac
if [[ "${SKIP_BUILD:-0}" != "1" ]]; then
"${repo_root}/scripts/apk/build.sh" build "${arch}"
fi
if [[ ! -d "${repo_root}/packages/local/${arch}" ]]; then
printf 'missing local repository: packages/local/%s\n' "${arch}" >&2
printf 'run: mise run apk:build\n' >&2
exit 1
fi
docker_args=(--rm --platform "${platform}")
if [[ -t 0 && -t 1 ]]; then
docker_args+=(-it)
fi
docker run "${docker_args[@]}" \
-e "ALPINE_ARCH=${arch}" \
-e "PACKAGE_LIST=${packages}" \
-e "TEST_SHELL=${shell}" \
-e "TEST_SHELL_TIMEOUT=${timeout_seconds}" \
-v "${repo_root}:/work:ro" \
-v "${repo_root}/packages/local:/repo:ro" \
"alpine:${alpine_version}" \
sh -lc '
set -e
printf "Installing repository key for %s...\n" "${ALPINE_ARCH}"
cp "/repo/${ALPINE_ARCH}"/*.rsa.pub /etc/apk/keys/
echo /repo >> /etc/apk/repositories
printf "Refreshing apk indexes...\n"
timeout "${TEST_SHELL_TIMEOUT}" apk update
printf "Installing test packages: %s\n" "${PACKAGE_LIST}"
timeout "${TEST_SHELL_TIMEOUT}" apk add ${PACKAGE_LIST}
printf "\nInstalled SeaweedFS packages:\n"
apk info -e seaweedfs seaweedfs-doc seaweedfs-bash-completion \
seaweedfs-master-openrc seaweedfs-filer-openrc seaweedfs-worker-openrc \
| sort
printf "\nSeaweedFS version:\n"
weed version
printf "\nEntering %s. Repository mounted read-only at /work.\n\n" "${TEST_SHELL}"
exec "${TEST_SHELL}"
'