name: Rust CI on: push: branches: ["release"] env: CARGO_TERM_COLOR: always RUSTFLAGS: "-D warnings" jobs: setup: runs-on: ubuntu-latest outputs: cache-key: ${{ steps.cache-key.outputs.value }} steps: - uses: actions/checkout@v4 - name: Install Rust toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: stable targets: x86_64-unknown-linux-musl - name: Install musl development tools run: sudo apt-get update && sudo apt-get install -y musl-tools - name: Generate cache key id: cache-key run: echo "value=cargo-$(rustc -V | sed 's/.*(\(.*\))/\1/')-$(sha256sum Cargo.lock | cut -d' ' -f1)" >> $GITHUB_OUTPUT lint: runs-on: ubuntu-latest needs: setup steps: - uses: actions/checkout@v4 - name: Restore cache uses: actions/cache@v4 with: path: | ~/.cargo/registry ~/.cargo/git target key: ${{ needs.setup.outputs.cache-key }}-lint - name: Install Rust toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: stable components: clippy, rustfmt - name: Run clippy run: cargo clippy --workspace --all-targets -- -D warnings test: runs-on: ubuntu-latest needs: setup env: CARGO_BUILD_TARGET: x86_64-unknown-linux-musl steps: - uses: actions/checkout@v4 - name: Restore cache uses: actions/cache@v4 with: path: | ~/.cargo/registry ~/.cargo/git target key: ${{ needs.setup.outputs.cache-key }}-test - name: Install musl target and tools run: | rustup target add x86_64-unknown-linux-musl sudo apt-get update && sudo apt-get install -y musl-tools - name: Build run: cargo build --workspace --verbose - name: Run tests run: cargo test --workspace --verbose - name: Check binary compatibility run: | cargo build --workspace --release find target/x86_64-unknown-linux-musl/release -maxdepth 1 -executable -type f 2>/dev/null | head -5 | xargs -I {} sh -c 'file {} | grep -q "statically linked" && echo "✓ {} is statically linked" || echo "✗ {} is not statically linked"' release: runs-on: ubuntu-latest needs: [lint, test] if: github.event_name == 'push' && github.ref == 'refs/heads/main' env: CARGO_BUILD_TARGET: x86_64-unknown-linux-musl steps: - uses: actions/checkout@v4 - name: Restore cache uses: actions/cache@v4 with: path: | ~/.cargo/registry ~/.cargo/git target key: ${{ needs.setup.outputs.cache-key }}-release - name: Build release binaries run: cargo build --workspace --release - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: release-binaries path: target/x86_64-unknown-linux-musl/release/