name: Rust CI (Native Install + Cache) on: [push, pull_request] env: CARGO_TERM_COLOR: always jobs: build_and_check: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Install Rust run: | if ! command -v rustc &> /dev/null; then curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal echo "$HOME/.cargo/bin" >> $GITHUB_PATH fi - name: Cache Cargo uses: actions/cache@v3 with: path: | ~/.cargo/registry ~/.cargo/git target key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo- - name: Cargo Check & Build run: | cargo check --verbose cargo build --verbose test: needs: build_and_check runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Install Rust run: | if ! command -v rustc &> /dev/null; then curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal echo "$HOME/.cargo/bin" >> $GITHUB_PATH fi - name: Cache Cargo uses: actions/cache@v3 with: path: | ~/.cargo/registry ~/.cargo/git target key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Run Tests run: cargo test --verbose docs: needs: build_and_check runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Install Rust run: | if ! command -v rustc &> /dev/null; then curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal echo "$HOME/.cargo/bin" >> $GITHUB_PATH fi - name: Cache Cargo uses: actions/cache@v3 with: path: | ~/.cargo/registry ~/.cargo/git target key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Build docs run: | cargo doc --no-deps --document-private-items mkdir -p ./docs-output && cp -r target/doc/* ./docs-output/ - name: Upload Artifact uses: actions/upload-artifact@v3 with: name: rust-documentation path: ./docs-output/ retention-days: 7