From d9341e76866eda46691ed9c70ba4dc0c4c15b65e Mon Sep 17 00:00:00 2001 From: jutty Date: Sat, 7 Mar 2026 17:28:47 -0300 Subject: [PATCH] Add dev containers, musl build --- .forgejo/workflows/publish.yaml | 32 +++++++++++++++----- .justfile | 36 ++++++++++------------- tests/containers/Containerfile.alpine-dev | 13 ++++++++ tests/containers/Containerfile.debian-dev | 13 ++++++++ tests/containers/build.sh | 20 ++++++++++--- tests/containers/run.sh | 8 +++-- 6 files changed, 86 insertions(+), 36 deletions(-) create mode 100644 tests/containers/Containerfile.alpine-dev create mode 100644 tests/containers/Containerfile.debian-dev diff --git a/.forgejo/workflows/publish.yaml b/.forgejo/workflows/publish.yaml index 532d4e1..833a7d6 100644 --- a/.forgejo/workflows/publish.yaml +++ b/.forgejo/workflows/publish.yaml @@ -22,21 +22,37 @@ jobs: run: | rustup component add llvm-tools-preview rustup component add --toolchain nightly rustfmt clippy + rustup target add x86_64-unknown-linux-musl - name: Setup additional tooling run: .forgejo/workflows/setup-tools.sh - - name: Build release binary - run: just full-build - - name: Calculate SHA-256 hash + - name: Build x64 glibc release binary + run: just full-build x86_64-unknown-linux-gnu + + - name: Build x64 musl release binary + run: just full-build x86_64-unknown-linux-musl + + - name: Calculate SHA-256 hashes run: just shasum - - name: Publish to git.jutty.dev package registry + - name: Publish x64 glibc binary to git.jutty.dev registry run: | - version=$(./target/release/en --version) + version=$(./target/x86_64-unknown-linux-gnu/en --version) api_root=https://git.jutty.dev/api - url=$api_root/packages/jutty/generic/en/$version/en-x86_64-linux-gnu + url=$api_root/packages/jutty/generic/en/$version/en-x64-linux-gnu curl -fsSL \ - --user jutty:${{ secrets.GJD_REGISTRY_TOKEN }} \ - --upload-file target/release/en $url + --user jutty:${{ secrets.GJD_REGISTRY_TOKEN }} \ + --upload-file target/x86_64-unknown-linux-gnu/en $url + + - name: Publish x64 musl binary to git.jutty.dev registry + run: | + version=$(./target/x86_64-unknown-linux-musl/en --version) + api_root=https://git.jutty.dev/api + url=$api_root/packages/jutty/generic/en/$version/en-x64-linux-musl + + curl -fsSL \ + --user jutty:${{ secrets.GJD_REGISTRY_TOKEN }} \ + --upload-file target/x86_64-unknown-linux-musl/en $url + diff --git a/.justfile b/.justfile index 8a1a9f2..866cb13 100644 --- a/.justfile +++ b/.justfile @@ -299,42 +299,30 @@ alias cl := clean # Build project with Cargo [group: 'build'] -build: update - cargo build --locked +build target=default_target: update + cargo build --target {{ target }} --locked alias b := build # Release build [group: 'build'] -release-build: update verify - cargo build --locked --release +release-build target=default_target: update verify + cargo build --target {{ target }} --locked --release alias rb := release-build # Clean, run assessments, release build [group: 'build'] -full-build: clean release-build +full-build target: clean (release-build target) alias fb := full-build -# Upload release build to git.jutty.dev package registry -[script, group: 'build'] -upload: full-build && shasum - version=$(./target/release/en --version) - api_root=https://git.jutty.dev/api/ - url=$api_root/packages/jutty/generic/en/$version/en-x86_64-linux-gnu - file=target/release/en - - curl -fsSL \ - --user jutty:$(secret-tool lookup Title gjd-registry-token) \ - --upload-file $file $url - -alias u := upload - -# Print sha256sum for CI logging +# Calculate SHA 256 hashes for release binaries [group: 'build'] shasum: - sha256sum target/release/en + find target -type d -name 'release' \ + -exec find '{}' -maxdepth 1 -type f -name en -executable ';' \ + | xargs sha256sum ## META @@ -342,8 +330,14 @@ shasum: default: @just --list --unsorted --justfile {{justfile()}} +choose: + @just --choose + +alias ch := choose + export CARGO_TERM_COLOR := 'always' +default_target := "x86_64-unknown-linux-gnu" debug_vars := 'DEBUG=${DEBUG:-} DEBUG_FILTER=${DEBUG_FILTER:-} RUST_BACKTRACE=${RUST_BACKTRACE:-} RUSTFLAGS=${RUSTFLAGS:-}' watch_cmd := "watchexec -qc -r -e rs,toml,html --color always -- " cover_cmd := 'cargo llvm-cov --color always --ignore-filename-regex "main\.rs|log\.rs"' diff --git a/tests/containers/Containerfile.alpine-dev b/tests/containers/Containerfile.alpine-dev new file mode 100644 index 0000000..d6a7e45 --- /dev/null +++ b/tests/containers/Containerfile.alpine-dev @@ -0,0 +1,13 @@ +FROM docker.io/library/rust:alpine +MAINTAINER Juno Takano juno@jutty.dev +ENV DEBUG=debug + +# Install +COPY en /usr/local/bin/en + +# Describe +RUN sha256sum $(which en) + +# Launch +WORKDIR /root +CMD ["en", "-p", "80"] diff --git a/tests/containers/Containerfile.debian-dev b/tests/containers/Containerfile.debian-dev new file mode 100644 index 0000000..95372cc --- /dev/null +++ b/tests/containers/Containerfile.debian-dev @@ -0,0 +1,13 @@ +FROM debian:stable-slim +MAINTAINER Juno Takano juno@jutty.dev +ENV DEBUG=debug + +# Install +COPY en /usr/local/bin/en + +# Describe +RUN sha256sum $(which en) + +# Launch +WORKDIR /root +CMD ["en", "-p", "80"] diff --git a/tests/containers/build.sh b/tests/containers/build.sh index df4aa02..f426ea2 100755 --- a/tests/containers/build.sh +++ b/tests/containers/build.sh @@ -1,9 +1,21 @@ #!/usr/bin/env sh set -eu -distro="$1" +suffix=$(printf '%s' "$1" | sed 's/.*\.//') +tag="en:$suffix" + +if podman container exists "$tag"; then + podman stop --time 3 "$tag" +fi + +if [ "$suffix" = 'debian-dev' ]; then + cp ../../target/release/en en +elif [ "$suffix" = 'alpine-dev' ]; then + cp ../../target/x86_64-unknown-linux-musl/release/en en +fi -podman stop --time 3 "en-$distro" podman build \ - --tag "en-$distro" \ - -f "Containerfile.$distro" + --tag "$tag" \ + -f "Containerfile.$suffix" + +rm en diff --git a/tests/containers/run.sh b/tests/containers/run.sh index 5a3efd5..784ec44 100755 --- a/tests/containers/run.sh +++ b/tests/containers/run.sh @@ -1,10 +1,12 @@ #!/usr/bin/env sh set -eu -distro="$1" +suffix=$(printf '%s' "$1" | sed 's/.*\.//') +name="en-$suffix" +tag="en:$suffix" podman run \ --replace \ - --name "en-$distro" \ + --name "$name" \ --publish 3008:80 \ - "en-$distro" + "$tag"