v0.4.0 #7
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: Rust CI | |
| on: | |
| push: | |
| branches: [ "master", "main" ] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| SCCACHE_GHA_ENABLED: "true" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Install Rust toolchain | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| profile: minimal | |
| toolchain: stable | |
| override: true | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libclang-dev pkg-config | |
| - name: Install latest mold linker | |
| run: | | |
| MOLD_VERSION=$(curl -s https://api.github.com/repos/rui314/mold/releases/latest | grep '"tag_name"' | cut -d'"' -f4) | |
| curl -L "https://github.com/rui314/mold/releases/download/${MOLD_VERSION}/mold-${MOLD_VERSION#v}-x86_64-linux.tar.gz" | sudo tar -xz -C /usr/local --strip-components=1 | |
| mold --version | |
| - name: Setup sccache | |
| uses: mozilla-actions/sccache-action@v0.0.3 | |
| continue-on-error: true | |
| id: sccache | |
| - name: Test sccache availability | |
| id: test-sccache | |
| continue-on-error: true | |
| run: | | |
| if command -v sccache &> /dev/null; then | |
| # Try to start sccache and compile a simple test | |
| echo 'fn main() {}' > /tmp/test.rs | |
| if sccache rustc /tmp/test.rs -o /tmp/test 2>/dev/null; then | |
| echo "sccache_works=true" >> $GITHUB_OUTPUT | |
| echo "✅ sccache is working properly" | |
| else | |
| echo "sccache_works=false" >> $GITHUB_OUTPUT | |
| echo "⚠️ sccache is installed but not functioning properly" | |
| fi | |
| rm -f /tmp/test.rs /tmp/test | |
| else | |
| echo "sccache_works=false" >> $GITHUB_OUTPUT | |
| echo "⚠️ sccache is not installed" | |
| fi | |
| - name: Configure cargo for build | |
| run: | | |
| mkdir -p .cargo | |
| cp .cargo/config.toml .cargo/config.toml.bak || true | |
| echo '[build]' > .cargo/config.toml | |
| # Use sccache only if it's actually working | |
| if [ "${{ steps.test-sccache.outputs.sccache_works }}" == "true" ]; then | |
| echo 'rustc-wrapper = "sccache"' >> .cargo/config.toml | |
| echo "✅ Using sccache for compilation caching" | |
| else | |
| echo "⚠️ Building without sccache due to availability issues" | |
| fi | |
| echo '[target.x86_64-unknown-linux-gnu]' >> .cargo/config.toml | |
| echo 'rustflags = ["-C", "link-arg=-fuse-ld=mold", "-C", "target-cpu=native"]' >> .cargo/config.toml | |
| - name: Build | |
| run: cargo build --release --verbose | |
| - name: Show sccache stats | |
| if: steps.test-sccache.outputs.sccache_works == 'true' | |
| run: sccache --show-stats || true |