name: Build Zero OS Initramfs on: push: branches: [ main, master, development ] pull_request: branches: [ main, master ] workflow_dispatch: env: ALPINE_VERSION: "3.22" KERNEL_VERSION: "6.12.44" RUST_TARGET: "x86_64-unknown-linux-musl" OPTIMIZATION_LEVEL: "max" jobs: build: runs-on: ubuntu-latest timeout-minutes: 120 steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup rootless containers run: | # Configure subuid/subgid for runner user echo "runner:100000:65536" | sudo tee -a /etc/subuid echo "runner:100000:65536" | sudo tee -a /etc/subgid # Install container runtime sudo apt-get update sudo apt-get install -y podman # Verify rootless setup podman system info - name: Install build dependencies run: | sudo apt-get update sudo apt-get install -y \ build-essential \ rustc \ cargo \ upx-ucl \ binutils \ git \ wget \ qemu-system-x86 \ musl-tools \ bc \ flex \ bison \ libelf-dev \ libssl-dev - name: Setup Rust environment run: | rustup target add x86_64-unknown-linux-musl rustup component add clippy rustfmt - name: Cache Rust dependencies uses: actions/cache@v4 with: path: | ~/.cargo/registry ~/.cargo/git components/*/target key: ${{ runner.os }}-rust-${{ hashFiles('config/sources.conf') }} restore-keys: | ${{ runner.os }}-rust- - name: Cache Alpine downloads uses: actions/cache@v4 with: path: | /tmp/alpine-miniroot*.tar.gz /tmp/linux-*.tar.xz key: ${{ runner.os }}-downloads-${{ env.ALPINE_VERSION }}-${{ env.KERNEL_VERSION }} restore-keys: | ${{ runner.os }}-downloads- - name: Build initramfs run: | echo "Starting Zero OS build..." ./scripts/build.sh --no-container - name: Test with QEMU run: | echo "Testing with QEMU..." timeout 120 ./scripts/test.sh --qemu --timeout 60 || echo "Test completed (timeout expected)" - name: Analyze build artifacts run: | echo "Build artifacts:" ls -la dist/ || echo "No dist directory" if [ -f dist/vmlinuz.efi ]; then echo "Kernel size: $(du -h dist/vmlinuz.efi | cut -f1)" fi if [ -f dist/initramfs.cpio.xz ]; then echo "Initramfs size: $(du -h dist/initramfs.cpio.xz | cut -f1)" fi # Test archive integrity if [ -f dist/initramfs.cpio.xz ]; then echo "Testing initramfs archive integrity..." xz -t dist/initramfs.cpio.xz && echo "Archive integrity: OK" fi - name: Upload build artifacts uses: actions/upload-artifact@v4 with: name: zero-os-initramfs-${{ github.sha }} path: | dist/vmlinuz.efi dist/initramfs.cpio.xz retention-days: 30 if-no-files-found: warn - name: Upload build logs uses: actions/upload-artifact@v4 if: always() with: name: build-logs-${{ github.sha }} path: | /tmp/qemu-*.log /tmp/cloud-hypervisor-*.log retention-days: 7 if-no-files-found: ignore - name: Create release if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' uses: softprops/action-gh-release@v1 with: tag_name: v${{ github.run_number }} name: Zero OS Alpine Initramfs v${{ github.run_number }} body: | Zero OS Alpine Initramfs build ${{ github.run_number }} Built from commit: ${{ github.sha }} Alpine version: ${{ env.ALPINE_VERSION }} Kernel version: ${{ env.KERNEL_VERSION }} ## Files - `vmlinuz.efi`: Kernel with embedded initramfs - `initramfs.cpio.xz`: Standalone initramfs archive files: | dist/vmlinuz.efi dist/initramfs.cpio.xz draft: false prerelease: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} test-matrix: runs-on: ubuntu-latest needs: build if: success() strategy: matrix: test_type: [basic, serial] runner: [qemu] fail-fast: false steps: - name: Checkout code uses: actions/checkout@v4 - name: Download build artifacts uses: actions/download-artifact@v4 with: name: zero-os-initramfs-${{ github.sha }} path: dist/ - name: Install test dependencies run: | sudo apt-get update sudo apt-get install -y qemu-system-x86 - name: Test boot - ${{ matrix.runner }} ${{ matrix.test_type }} run: | chmod +x scripts/test.sh timeout 90 ./scripts/test.sh --${{ matrix.runner }} --${{ matrix.test_type }} --timeout 60 || echo "Test completed"