Skip to content

Add erofs support to apko. #1236

Add erofs support to apko.

Add erofs support to apko. #1236

Workflow file for this run

name: Test Examples
on:
pull_request:
branches: [ "main" ]
push:
branches: [ "main" ]
workflow_dispatch:
permissions:
contents: read
jobs:
test-on-top-of-base:
name: Test on_top_of_base example (${{ matrix.arch }})
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
arch: [x86_64, aarch64]
steps:
- uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: block
allowed-endpoints: >
*.blob.core.windows.net:443
*.githubapp.com:443
9236a389bd48b984df91adc1bc924620.r2.cloudflarestorage.com:443
api.github.com:443
auth.docker.io:443
cgr.dev:443
dl.google.com:443
github.com:443
go.dev:443
objects.githubusercontent.com:443
packages.wolfi.dev:443
production.cloudflare.docker.com:443
production.cloudfront.docker.com:443
proxy.golang.org:443
registry-1.docker.io:443
release-assets.githubusercontent.com:443
storage.googleapis.com:443
sum.golang.org:443
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: 'go.mod'
check-latest: true
- name: Setup QEMU
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
- name: Install crane
uses: imjasonh/setup-crane@feee3b6bb0d4c68370f256a4502498c9227e5c6b # v0.7
- name: Build apko
run: make apko
- name: Test on_top_of_base example - usr-merge base image handling
env:
MATRIX_ARCH: ${{ matrix.arch }}
MATRIX_PLATFORM: ${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }}
run: |
set -euxo pipefail
# Test with busybox base image (has usr-merge layout with /lib -> /usr/lib symlink)
# This verifies that apko correctly handles building on top of base images with usr-merge layout
BASE_IMAGE="cgr.dev/chainguard/busybox:latest"
OUTPUT_TAR="test-output-${MATRIX_ARCH}.tar"
echo "Testing on_top_of_base example with ${MATRIX_ARCH} architecture..."
# Build image on top of base using the parameterized build.sh script
./examples/on_top_of_base/build.sh \
./apko \
"$BASE_IMAGE" \
"$OUTPUT_TAR" \
"${MATRIX_ARCH}"
# Load the built image
docker load -i "$OUTPUT_TAR"
# Determine the correct image tag based on architecture
if [ "${MATRIX_ARCH}" = "x86_64" ]; then
IMAGE_TAG="base_image:latest-amd64"
else
IMAGE_TAG="base_image:latest-arm64"
fi
# Test that shell works (verifies /lib symlink is preserved correctly)
echo "Testing shell execution on ${MATRIX_ARCH}..."
if docker run --rm --platform "linux/${MATRIX_PLATFORM}" \
--entrypoint /bin/sh "$IMAGE_TAG" \
-c "echo 'Shell works on ${MATRIX_ARCH}'" | grep -q "Shell works"; then
echo "Shell executes correctly on ${MATRIX_ARCH}"
else
echo "FAILED: Shell failed to execute on ${MATRIX_ARCH} (indicates broken /lib symlink)"
exit 1
fi
# Test another binary to be thorough
echo "Testing busybox execution on ${MATRIX_ARCH}..."
if docker run --rm --platform "linux/${MATRIX_PLATFORM}" \
--entrypoint /bin/busybox "$IMAGE_TAG" echo "Busybox works" | grep -q "Busybox works"; then
echo "Busybox executes correctly on ${MATRIX_ARCH}"
else
echo "FAILED: Busybox failed to execute on ${MATRIX_ARCH}"
exit 1
fi
echo "PASSED: on_top_of_base example test for ${MATRIX_ARCH}"
- name: Clean up
if: always()
run: |
# Clean up docker images
docker rmi base_image:latest-amd64 2>/dev/null || true
docker rmi base_image:latest-arm64 2>/dev/null || true
# Clean up build artifacts
rm -rf ./examples/on_top_of_base/{base_image,apkindexes,fs_dump,top_image,*.lock.json,*.tar}