Update Rust to the latest version (#143) #392
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: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - "build/**" | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| env: | |
| NIGHTLY_TOOLCHAIN: nightly-2026-07-01 | |
| # Default environment variables for Cargo | |
| CARGO_INCREMENTAL: "0" | |
| CARGO_PROFILE_DEV_DEBUG: "false" | |
| CARGO_PROFILE_TEST_DEBUG: "false" | |
| jobs: | |
| check: | |
| name: Run checks | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| - name: Check formatting | |
| run: cargo fmt -- --check | |
| - name: Check Clippy | |
| run: cargo clippy --all -- -Dwarnings | |
| test: | |
| name: Run tests | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| runs-on: | |
| - ubuntu-24.04 | |
| - ubuntu-24.04-arm | |
| - macos-15 | |
| runs-on: ${{ matrix.runs-on }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| - name: Run tests | |
| run: cargo test --all | |
| build: | |
| name: Build artifacts [${{ matrix.name }}] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: x86_64-linux | |
| runs-on: ubuntu-24.04 | |
| target: x86_64-unknown-linux-gnu | |
| tools-target: x86_64-unknown-linux-musl | |
| packed-exec: brioche-packed-userland-exec | |
| - name: aarch64-linux | |
| runs-on: ubuntu-24.04-arm | |
| target: aarch64-unknown-linux-gnu | |
| tools-target: aarch64-unknown-linux-musl | |
| packed-exec: brioche-packed-userland-exec | |
| - name: x86_64-macos | |
| runs-on: macos-15 | |
| target: x86_64-apple-darwin | |
| tools-target: x86_64-apple-darwin | |
| packed-exec: brioche-packed-plain-exec | |
| - name: aarch64-macos | |
| runs-on: macos-15 | |
| target: aarch64-apple-darwin | |
| tools-target: aarch64-apple-darwin | |
| packed-exec: brioche-packed-plain-exec | |
| runs-on: ${{ matrix.runs-on }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| - name: Install Rust targets | |
| run: rustup target add "$TARGET" "$TOOLS_TARGET" | |
| env: | |
| TARGET: ${{ matrix.target }} | |
| TOOLS_TARGET: ${{ matrix.tools-target }} | |
| - name: Install Rust nightly toolchain | |
| run: | | |
| rustup toolchain install "$NIGHTLY_TOOLCHAIN" \ | |
| --target "$TOOLS_TARGET" \ | |
| --component rust-src | |
| env: | |
| TOOLS_TARGET: ${{ matrix.tools-target }} | |
| - name: Build Brioche runtime utils | |
| run: | | |
| cargo build \ | |
| --all \ | |
| --bin brioche-cc \ | |
| --bin brioche-ld \ | |
| --bin brioche-strip \ | |
| --bin brioche-packer \ | |
| --release \ | |
| --target="$TOOLS_TARGET" | |
| CARGO_PROFILE_RELEASE_TINY_PANIC=immediate-abort \ | |
| cargo +"$NIGHTLY_TOOLCHAIN" build \ | |
| --all \ | |
| --bin brioche-packed-plain-exec \ | |
| --bin brioche-packed-userland-exec \ | |
| --profile=release-tiny \ | |
| --target="$TOOLS_TARGET" \ | |
| -Z panic-immediate-abort \ | |
| -Z 'build-std=std,panic_abort' \ | |
| -Z 'build-std-features=optimize_for_size' | |
| env: | |
| TOOLS_TARGET: ${{ matrix.tools-target }} | |
| CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc | |
| CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER: x86_64-linux-gnu-gcc | |
| - name: Prepare artifact | |
| run: | | |
| mkdir -p "artifacts/brioche/$PLATFORM/" | |
| mkdir -p "artifacts/brioche-runtime-utils/$PLATFORM/bin/" | |
| cp \ | |
| "target/$TOOLS_TARGET/release/brioche-cc" \ | |
| "target/$TOOLS_TARGET/release/brioche-ld" \ | |
| "target/$TOOLS_TARGET/release/brioche-strip" \ | |
| "target/$TOOLS_TARGET/release/brioche-packer" \ | |
| "target/$TOOLS_TARGET/release-tiny/brioche-packed-plain-exec" \ | |
| "target/$TOOLS_TARGET/release-tiny/brioche-packed-userland-exec" \ | |
| "artifacts/brioche-runtime-utils/$PLATFORM/bin/" | |
| cp "artifacts/brioche-runtime-utils/$PLATFORM/bin/$PACKED_EXEC" "artifacts/brioche-runtime-utils/$PLATFORM/bin/brioche-packed-exec" | |
| (cd "artifacts/brioche-runtime-utils/$PLATFORM/" && tar --zstd -cf "../../brioche/$PLATFORM/brioche-runtime-utils.tar.zstd" .) | |
| if command -v tree &> /dev/null; then | |
| tree --du -h artifacts/brioche-runtime-utils | |
| tree --du -h artifacts/brioche | |
| fi | |
| env: | |
| PLATFORM: ${{ matrix.name }} | |
| TARGET: ${{ matrix.target }} | |
| TOOLS_TARGET: ${{ matrix.tools-target }} | |
| PACKED_EXEC: ${{ matrix.packed-exec }} | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: brioche-runtime-utils-${{ matrix.name }} | |
| if-no-files-found: error | |
| path: artifacts/brioche | |
| all-checks-passed: | |
| name: All checks passed | |
| needs: [check, test, build] | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - run: ":" | |
| push: | |
| name: Push artifacts | |
| # Only push artifacts when pushing to `main` and `build/*` branches | |
| if: github.event_name == 'push' && github.repository == 'brioche-dev/brioche-runtime-utils' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/')) | |
| needs: [all-checks-passed] | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Download artifacts (x86_64-linux) | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: brioche-runtime-utils-x86_64-linux | |
| path: artifacts/brioche | |
| - name: Download artifacts (aarch64-linux) | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: brioche-runtime-utils-aarch64-linux | |
| path: artifacts/brioche | |
| - name: Download artifacts (x86_64-macos) | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: brioche-runtime-utils-x86_64-macos | |
| path: artifacts/brioche | |
| - name: Download artifacts (aarch64-macos) | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: brioche-runtime-utils-aarch64-macos | |
| path: artifacts/brioche | |
| # Prepare the upload for the current commit and branch: | |
| # - The current branch will be uploaded with all artifacts | |
| # - The current commit will be uploaded with all artifacts | |
| # - The current files from the bucket will be downloaded first, | |
| # so that existing files are not overwritten. This is so that file | |
| # hashes never change under the commit e.g. if the GitHub Actions | |
| # workflow is re-run | |
| - name: Prepare upload | |
| run: | | |
| mkdir -p artifacts/uploads/commit artifacts/uploads/branch | |
| cp -r artifacts/brioche/* artifacts/uploads/commit/ | |
| cp -r artifacts/brioche/* artifacts/uploads/branch/ | |
| if command -v tree &> /dev/null; then | |
| tree --du -h artifacts/uploads/commit | |
| tree --du -h artifacts/uploads/branch | |
| fi | |
| aws s3 sync \ | |
| --endpoint "$S3_ENDPOINT" \ | |
| "$S3_URL/github.com/brioche-dev/brioche-runtime-utils/commits/$GITHUB_SHA/" \ | |
| artifacts/uploads/commit/ | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }} | |
| AWS_REQUEST_CHECKSUM_CALCULATION: WHEN_REQUIRED | |
| AWS_RESPONSE_CHECKSUM_CALCULATION: WHEN_REQUIRED | |
| S3_ENDPOINT: ${{ vars.AWS_ENDPOINT_URL_S3 }} | |
| S3_URL: ${{ vars.S3_URL }} | |
| - name: Upload to S3 | |
| run: | | |
| aws s3 sync \ | |
| --endpoint "$S3_ENDPOINT" \ | |
| --delete \ | |
| artifacts/uploads/branch/ \ | |
| "$S3_URL/github.com/brioche-dev/brioche-runtime-utils/branches/$GITHUB_REF_NAME/" | |
| aws s3 sync \ | |
| --endpoint "$S3_ENDPOINT" \ | |
| --delete \ | |
| artifacts/uploads/commit/ \ | |
| "$S3_URL/github.com/brioche-dev/brioche-runtime-utils/commits/$GITHUB_SHA/" | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }} | |
| AWS_REQUEST_CHECKSUM_CALCULATION: WHEN_REQUIRED | |
| AWS_RESPONSE_CHECKSUM_CALCULATION: WHEN_REQUIRED | |
| S3_ENDPOINT: ${{ vars.AWS_ENDPOINT_URL_S3 }} | |
| S3_URL: ${{ vars.S3_URL }} |