Create a trunk release updated on each commit. #28
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: | |
| workflow_call: | |
| workflow_dispatch: | |
| pull_request: | |
| merge_group: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout co2 | |
| uses: actions/checkout@v4 | |
| - name: "node-cleanup" | |
| run: | | |
| sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL | |
| sudo docker image prune --all --force | |
| sudo docker builder prune -a | |
| - name: Setup Nushell | |
| uses: hustcer/setup-nu@v3 | |
| with: | |
| version: "0.110.0" | |
| - name: "copy nushell to /usr/bin" | |
| run: | | |
| sudo cp $(which nu) /usr/bin/ | |
| - name: Get co2-changes commit SHA | |
| id: rustc-sha | |
| run: | | |
| SHA=$(git ls-remote https://github.com/HKalbasi/rust refs/heads/co2-changes | cut -f1) | |
| echo "sha=$SHA" >> "$GITHUB_OUTPUT" | |
| echo "Rust fork SHA: $SHA" | |
| - name: Restore custom rustc toolchain cache | |
| id: cache-rustc | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: ~/co2-toolchain | |
| key: co2-toolchain-v2-ubuntu22-${{ steps.rustc-sha.outputs.sha }} | |
| - name: Install rustc build dependencies | |
| if: steps.cache-rustc.outputs.cache-hit != 'true' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| python3 cmake ninja-build \ | |
| libssl-dev pkg-config \ | |
| gcc g++ \ | |
| curl | |
| - name: Install test dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y bubblewrap gcc build-essential | |
| - name: Install bootstrap Rust (for building the fork) | |
| if: steps.cache-rustc.outputs.cache-hit != 'true' | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Clone rustc fork (co2-changes) | |
| if: steps.cache-rustc.outputs.cache-hit != 'true' | |
| run: | | |
| git clone -b co2-changes \ | |
| https://github.com/HKalbasi/rust /tmp/rust-fork | |
| - name: Configure rustc build | |
| if: steps.cache-rustc.outputs.cache-hit != 'true' | |
| run: | | |
| cat > /tmp/rust-fork/bootstrap.toml << 'EOF' | |
| profile = "compiler" | |
| [llvm] | |
| ninja = true | |
| download-ci-llvm = false | |
| [build] | |
| profiler = true | |
| [install] | |
| prefix = "/tmp/rust-install" | |
| sysconfdir = "/tmp/rust-install" | |
| EOF | |
| - name: Seed rust bootstrap doc directories | |
| if: steps.cache-rustc.outputs.cache-hit != 'true' | |
| run: | | |
| mkdir -p \ | |
| /tmp/rust-fork/build/x86_64-unknown-linux-gnu/doc \ | |
| /tmp/rust-fork/build/x86_64-unknown-linux-gnu/json-doc | |
| - name: Build and install custom rustc toolchain | |
| if: steps.cache-rustc.outputs.cache-hit != 'true' | |
| working-directory: /tmp/rust-fork | |
| run: python3 x.py install --stage 2 compiler library rustc-dev cargo miri src | |
| - name: Copy toolchain to cache location | |
| if: steps.cache-rustc.outputs.cache-hit != 'true' | |
| run: cp -a /tmp/rust-install ~/co2-toolchain | |
| - name: Save custom rustc toolchain cache | |
| if: steps.cache-rustc.outputs.cache-hit != 'true' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: ~/co2-toolchain | |
| key: co2-toolchain-v2-ubuntu22-${{ steps.rustc-sha.outputs.sha }} | |
| - name: Install rustup | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Link custom toolchain via rustup | |
| run: | | |
| rustup toolchain link co2 ~/co2-toolchain | |
| rustup override set co2 | |
| - run: df -h | |
| - name: Run test harness | |
| run: | | |
| source "$HOME/.cargo/env" | |
| cargo run --locked -p co2_test_harness | |
| - name: Run bundle test | |
| run: | | |
| source "$HOME/.cargo/env" | |
| nu ./bundler/test-bundle.nu | |
| - name: Build release bundle artifact | |
| if: github.event_name != 'pull_request' | |
| run: | | |
| source "$HOME/.cargo/env" | |
| cargo +co2 build -p co2-multicall --release | |
| nu ./bundler/build-bundle.nu | |
| - name: Upload bundle artifact | |
| if: github.event_name != 'pull_request' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: co2-multicall-linux-x86_64 | |
| path: target/co2-multicall.run | |
| if-no-files-found: error | |
| - name: Build CE bundle | |
| if: github.event_name != 'pull_request' | |
| run: | | |
| source "$HOME/.cargo/env" | |
| ln -sf co2-multicall target/release/co2cargo | |
| ln -sf co2-multicall target/release/co2miri | |
| nu ./bundler/build-ce-bundle.nu | |
| - name: Test CE bundle | |
| if: github.event_name != 'pull_request' | |
| run: | | |
| source "$HOME/.cargo/env" | |
| nu ./bundler/test-ce-bundle.nu | |
| - name: Upload CE bundle artifact | |
| if: github.event_name != 'pull_request' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: co2-ce-linux-x86_64 | |
| path: target/co2-ce.tar.zstd | |
| if-no-files-found: error | |
| - name: Upload to trunk release | |
| if: github.event_name != 'pull_request' | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: trunk | |
| name: trunk | |
| allowUpdates: true | |
| omitBodyDuringUpdate: true | |
| omitPrereleaseDuringUpdate: true | |
| replacesArtifacts: true | |
| artifacts: "target/co2-multicall.run,target/co2-ce.tar.zstd" | |
| token: ${{ secrets.GITHUB_TOKEN }} |