Fix Stack ownership error in ARM64 Docker builds #107
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: [push] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - arch: x86_64 | |
| arch_alt: amd64 | |
| - arch: arm64 | |
| arch_alt: aarch64 | |
| steps: | |
| # Setup QEMU for ARM64 emulation | |
| - name: Set up QEMU | |
| if: matrix.arch == 'arm64' | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: arm64 | |
| # Use run-on-arch for ARM64 builds | |
| - name: Checkout (ARM64) | |
| if: matrix.arch == 'arm64' | |
| uses: actions/checkout@v2 | |
| - name: Build on ARM64 | |
| if: matrix.arch == 'arm64' | |
| uses: uraimo/run-on-arch-action@v2 | |
| with: | |
| arch: aarch64 | |
| distro: ubuntu22.04 | |
| githubToken: ${{ github.token }} | |
| dockerRunArgs: | | |
| --volume "${PWD}:/workspace" | |
| install: | | |
| apt-get update -q -y | |
| apt-get install -q -y curl gcc g++ make libgmp-dev libtinfo-dev libncurses5-dev libc6-dev zlib1g-dev | |
| # Install Stack | |
| curl -sSL https://get.haskellstack.org/ | sh | |
| run: | | |
| cd /workspace | |
| # Build | |
| export PATH=/root/.local/bin:$PATH | |
| stack --allow-different-user --no-terminal build --test --only-dependencies | |
| mkdir -p dist | |
| stack --allow-different-user --no-terminal build --test --no-run-tests --copy-bins --local-bin-path dist | |
| # Test (skip S3 tests for ARM64 builds) | |
| export SKIP_S3_TESTS=1 | |
| stack --allow-different-user --no-terminal build --test | |
| # Package | |
| cd dist | |
| tar czvf taskrunner-linux-arm64.tar.gz taskrunner | |
| # Regular x86_64 build | |
| - name: Checkout (x86_64) | |
| if: matrix.arch == 'x86_64' | |
| uses: actions/checkout@v2 | |
| - name: Start MinIO service container (x86_64) | |
| if: matrix.arch == 'x86_64' | |
| run: | | |
| docker run --rm -d --name minio -p 9000:9000 \ | |
| -e MINIO_ROOT_USER=minioadmin \ | |
| -e MINIO_ROOT_PASSWORD=minioadmin \ | |
| quay.io/minio/minio server /data | |
| sleep 3 | |
| curl -s -D- http://localhost:9000 | |
| - name: Setup Haskell (x86_64) | |
| if: matrix.arch == 'x86_64' | |
| uses: haskell-actions/setup@v2 | |
| with: | |
| enable-stack: true | |
| stack-version: 'latest' | |
| - name: Cache (x86_64) | |
| if: matrix.arch == 'x86_64' | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: cache-stack | |
| with: | |
| path: ~/.stack | |
| key: ${{ runner.os }}-${{ matrix.arch }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/stack.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ matrix.arch }}-build-${{ env.cache-name }}- | |
| ${{ runner.os }}-${{ matrix.arch }}-build- | |
| ${{ runner.os }}-${{ matrix.arch }}- | |
| - name: Build dependencies (x86_64) | |
| if: matrix.arch == 'x86_64' | |
| run: | | |
| stack --no-terminal build --test --only-dependencies | |
| - name: Build (x86_64) | |
| if: matrix.arch == 'x86_64' | |
| run: | | |
| mkdir dist | |
| stack --no-terminal build --test --no-run-tests --copy-bins --local-bin-path dist | |
| - name: Test (x86_64) | |
| if: matrix.arch == 'x86_64' | |
| run: | | |
| export TASKRUNNER_TEST_S3_ENDPOINT=http://localhost:9000 | |
| export TASKRUNNER_TEST_S3_ACCESS_KEY=minioadmin | |
| export TASKRUNNER_TEST_S3_SECRET_KEY=minioadmin | |
| stack --no-terminal build --test | |
| - name: Package (x86_64) | |
| if: matrix.arch == 'x86_64' | |
| run: | | |
| cd dist | |
| # Create architecture-specific archive | |
| tar czvf taskrunner-linux-x86_64.tar.gz taskrunner | |
| # Also create legacy name for compatibility | |
| cp taskrunner-linux-x86_64.tar.gz taskrunner-linux.tar.gz | |
| # Upload artifacts for both architectures | |
| - name: Archive production artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: taskrunner-linux-${{ matrix.arch }} | |
| path: | | |
| dist/*.tar.gz |