Cache Rust build artifacts for Alpine packages
Some checks failed
Build Alpine Packages / build-and-publish (push) Has been cancelled
Some checks failed
Build Alpine Packages / build-and-publish (push) Has been cancelled
This commit is contained in:
@@ -25,10 +25,15 @@ jobs:
|
|||||||
PACKAGE_USER: "${{ secrets.PACKAGE_USER }}"
|
PACKAGE_USER: "${{ secrets.PACKAGE_USER }}"
|
||||||
PACKAGE_TOKEN: "${{ secrets.PACKAGE_TOKEN }}"
|
PACKAGE_TOKEN: "${{ secrets.PACKAGE_TOKEN }}"
|
||||||
PACKAGER: "Joachim Schlöffel <me@joachim-schloeffel.com>"
|
PACKAGER: "Joachim Schlöffel <me@joachim-schloeffel.com>"
|
||||||
|
CARGO_HOME: "/cache/public-alpine-packages/greptimedb/cargo"
|
||||||
|
RUSTUP_HOME: "/cache/public-alpine-packages/greptimedb/rustup"
|
||||||
|
CARGO_TARGET_DIR: "/cache/public-alpine-packages/greptimedb/target"
|
||||||
steps:
|
steps:
|
||||||
- name: Prepare Environment
|
- name: Prepare Environment
|
||||||
run: |
|
run: |
|
||||||
apk add --no-cache --update abuild-rootbld alpine-sdk atools-apkbuild-lint bash ca-certificates curl doas git nodejs sudo tar
|
apk add --no-cache --update abuild-rootbld alpine-sdk atools-apkbuild-lint bash ca-certificates curl doas git nodejs sudo tar
|
||||||
|
mkdir -p "$CARGO_HOME" "$RUSTUP_HOME" "$CARGO_TARGET_DIR"
|
||||||
|
chown 1000:1000 /cache /cache/public-alpine-packages /cache/public-alpine-packages/greptimedb "$CARGO_HOME" "$RUSTUP_HOME" "$CARGO_TARGET_DIR"
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|||||||
@@ -241,6 +241,13 @@ ALPINE_PACKAGE=greptimedb mise run apk:build
|
|||||||
ALPINE_PACKAGE=greptimedb SKIP_BUILD=1 mise run apk:test-install
|
ALPINE_PACKAGE=greptimedb SKIP_BUILD=1 mise run apk:test-install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Docker-backed build tasks keep Cargo registry, Rustup, and Cargo target caches in named Docker volumes. The default volume scope is derived from the Git remote owner/repository and is split by package and architecture. Override it when needed:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ALPINE_APK_CACHE_SCOPE=public-alpine-packages ALPINE_PACKAGE=greptimedb mise run apk:build
|
||||||
|
ALPINE_APK_CACHE_PREFIX=alpine-apk-ci ALPINE_PACKAGE=greptimedb mise run apk:build
|
||||||
|
```
|
||||||
|
|
||||||
Use the test shell to inspect the package in Alpine with the current build
|
Use the test shell to inspect the package in Alpine with the current build
|
||||||
installed:
|
installed:
|
||||||
|
|
||||||
|
|||||||
@@ -54,8 +54,9 @@ source="
|
|||||||
|
|
||||||
_rust_toolchain="nightly-2026-03-21"
|
_rust_toolchain="nightly-2026-03-21"
|
||||||
_cargo_profile="nightly"
|
_cargo_profile="nightly"
|
||||||
export CARGO_HOME="$srcdir/cargo"
|
export CARGO_HOME="${CARGO_HOME:-$srcdir/cargo}"
|
||||||
export RUSTUP_HOME="$srcdir/rustup"
|
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$builddir/target}"
|
||||||
|
export RUSTUP_HOME="${RUSTUP_HOME:-$srcdir/rustup}"
|
||||||
export CARGO_BUILD_JOBS="${CARGO_BUILD_JOBS:-2}"
|
export CARGO_BUILD_JOBS="${CARGO_BUILD_JOBS:-2}"
|
||||||
export CARGO_PROFILE_NIGHTLY_CODEGEN_UNITS="${CARGO_PROFILE_NIGHTLY_CODEGEN_UNITS:-16}"
|
export CARGO_PROFILE_NIGHTLY_CODEGEN_UNITS="${CARGO_PROFILE_NIGHTLY_CODEGEN_UNITS:-16}"
|
||||||
export CARGO_PROFILE_NIGHTLY_DEBUG="${CARGO_PROFILE_NIGHTLY_DEBUG:-false}"
|
export CARGO_PROFILE_NIGHTLY_DEBUG="${CARGO_PROFILE_NIGHTLY_DEBUG:-false}"
|
||||||
@@ -80,11 +81,11 @@ build() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
check() {
|
check() {
|
||||||
"$builddir"/target/"$_cargo_profile"/greptime --version
|
"$CARGO_TARGET_DIR"/"$_cargo_profile"/greptime --version
|
||||||
}
|
}
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
install -Dm755 "$builddir"/target/"$_cargo_profile"/greptime \
|
install -Dm755 "$CARGO_TARGET_DIR"/"$_cargo_profile"/greptime \
|
||||||
"$pkgdir"/usr/bin/greptime
|
"$pkgdir"/usr/bin/greptime
|
||||||
local _config
|
local _config
|
||||||
for _config in datanode flownode frontend metasrv standalone; do
|
for _config in datanode flownode frontend metasrv standalone; do
|
||||||
|
|||||||
@@ -18,9 +18,15 @@ RUN addgroup -g "${BUILDER_GID}" builder \
|
|||||||
&& adduser -D -u "${BUILDER_UID}" -G builder builder \
|
&& adduser -D -u "${BUILDER_UID}" -G builder builder \
|
||||||
&& addgroup builder abuild \
|
&& addgroup builder abuild \
|
||||||
&& addgroup builder wheel \
|
&& addgroup builder wheel \
|
||||||
&& mkdir -p /var/cache/distfiles /home/builder/packages \
|
&& mkdir -p \
|
||||||
|
/var/cache/distfiles \
|
||||||
|
/home/builder/.cache/cargo \
|
||||||
|
/home/builder/.cache/cargo-target \
|
||||||
|
/home/builder/.cache/rustup \
|
||||||
|
/home/builder/packages \
|
||||||
&& chgrp abuild /var/cache/distfiles /home/builder/packages \
|
&& chgrp abuild /var/cache/distfiles /home/builder/packages \
|
||||||
&& chmod g+w /var/cache/distfiles /home/builder/packages \
|
&& chmod g+w /var/cache/distfiles /home/builder/packages \
|
||||||
|
&& chown -R builder:builder /home/builder/.cache \
|
||||||
&& printf 'permit nopass :wheel\n' > /etc/doas.d/wheel.conf \
|
&& printf 'permit nopass :wheel\n' > /etc/doas.d/wheel.conf \
|
||||||
&& printf '%%wheel ALL=(ALL) NOPASSWD: ALL\n' > /etc/sudoers.d/wheel
|
&& printf '%%wheel ALL=(ALL) NOPASSWD: ALL\n' > /etc/sudoers.d/wheel
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,39 @@ if [[ "${builder_gid}" == "0" ]]; then
|
|||||||
builder_gid=1000
|
builder_gid=1000
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cache_scope_from_remote() {
|
||||||
|
local remote
|
||||||
|
local path
|
||||||
|
local owner
|
||||||
|
local repo
|
||||||
|
|
||||||
|
remote="$(git -C "${repo_root}" remote get-url origin 2>/dev/null || true)"
|
||||||
|
remote="${remote%.git}"
|
||||||
|
|
||||||
|
case "${remote}" in
|
||||||
|
ssh://*/*/*)
|
||||||
|
path="${remote#ssh://*/}"
|
||||||
|
;;
|
||||||
|
http://*/*/*|https://*/*/*)
|
||||||
|
path="${remote#*://*/}"
|
||||||
|
;;
|
||||||
|
*:*)
|
||||||
|
path="${remote#*:}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
path="$(basename "${repo_root}")"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
owner="$(basename "$(dirname "${path}")")"
|
||||||
|
repo="$(basename "${path}")"
|
||||||
|
if [[ -n "${owner}" && "${owner}" != "." && -n "${repo}" ]]; then
|
||||||
|
printf '%s-%s\n' "${owner}" "${repo}" | sed 's/[^A-Za-z0-9_.-]/-/g'
|
||||||
|
else
|
||||||
|
printf '%s\n' "$(basename "${repo_root}")" | sed 's/[^A-Za-z0-9_.-]/-/g'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
validate_arch() {
|
validate_arch() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
x86_64|aarch64) ;;
|
x86_64|aarch64) ;;
|
||||||
@@ -32,11 +65,17 @@ run_for_arch() {
|
|||||||
local package_dir="$3"
|
local package_dir="$3"
|
||||||
local image_name
|
local image_name
|
||||||
local container_package_dir
|
local container_package_dir
|
||||||
|
local package_name
|
||||||
|
local cache_scope
|
||||||
|
local cache_prefix
|
||||||
|
|
||||||
validate_arch "${arch}"
|
validate_arch "${arch}"
|
||||||
apk_validate_package_dir "${package_dir}"
|
apk_validate_package_dir "${package_dir}"
|
||||||
|
package_name="$(apk_package_name "${package_dir}")"
|
||||||
container_package_dir="$(apk_container_package_dir "${repo_root}" "${package_dir}")"
|
container_package_dir="$(apk_container_package_dir "${repo_root}" "${package_dir}")"
|
||||||
image_name="${ALPINE_APK_BUILDER_IMAGE:-alpine-apk-builder:${arch}}"
|
image_name="${ALPINE_APK_BUILDER_IMAGE:-alpine-apk-builder:${arch}}"
|
||||||
|
cache_scope="${ALPINE_APK_CACHE_SCOPE:-$(cache_scope_from_remote)}"
|
||||||
|
cache_prefix="${ALPINE_APK_CACHE_PREFIX:-alpine-apk}-${cache_scope}-${package_name}-${arch}"
|
||||||
|
|
||||||
docker build \
|
docker build \
|
||||||
--platform "${build_platform}" \
|
--platform "${build_platform}" \
|
||||||
@@ -57,7 +96,13 @@ run_for_arch() {
|
|||||||
-e "CARCH=${arch}" \
|
-e "CARCH=${arch}" \
|
||||||
-e "ALPINE_REPO_NAME=${repo_name}" \
|
-e "ALPINE_REPO_NAME=${repo_name}" \
|
||||||
-e "APKBUILD_DIR=${container_package_dir}" \
|
-e "APKBUILD_DIR=${container_package_dir}" \
|
||||||
|
-e "CARGO_HOME=/home/builder/.cache/cargo" \
|
||||||
|
-e "CARGO_TARGET_DIR=/home/builder/.cache/cargo-target" \
|
||||||
-e "PACKAGER=${PACKAGER:-Joachim Schlöffel <me@joachim-schloeffel.com>}" \
|
-e "PACKAGER=${PACKAGER:-Joachim Schlöffel <me@joachim-schloeffel.com>}" \
|
||||||
|
-e "RUSTUP_HOME=/home/builder/.cache/rustup" \
|
||||||
|
-v "${cache_prefix}-cargo:/home/builder/.cache/cargo" \
|
||||||
|
-v "${cache_prefix}-cargo-target:/home/builder/.cache/cargo-target" \
|
||||||
|
-v "${cache_prefix}-rustup:/home/builder/.cache/rustup" \
|
||||||
-v "${repo_root}:/work" \
|
-v "${repo_root}:/work" \
|
||||||
-v "${repo_root}/.cache/abuild:/home/builder/.abuild" \
|
-v "${repo_root}/.cache/abuild:/home/builder/.abuild" \
|
||||||
-v "${repo_root}/.cache/apk-distfiles:/var/cache/distfiles" \
|
-v "${repo_root}/.cache/apk-distfiles:/var/cache/distfiles" \
|
||||||
|
|||||||
Reference in New Issue
Block a user