diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 41469dc2..bbc1723a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -27,9 +27,37 @@ env: CARGO_TERM_COLOR: always jobs: - build_and_test: + build: + name: Rust build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Cache dependencies installed with cargo + uses: actions/cache@v4 + with: + path: | + ./target/deps + ~/.cargo + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo- + - name: Build binary + run: | + # the binary will be used by the cargo test + cargo build + cargo test --no-run --all-targets --all-features + - name: Compress before uploading artifact to preserve permissions # https://github.com/actions/upload-artifact/tree/v4.4.3#permission-loss + run: tar -cvzf target.tgz target/ + - uses: actions/upload-artifact@v4 + with: + include-hidden-files: true + name: target + path: target.tgz + retention-days: 1 + test: name: Rust tests runs-on: ubuntu-latest + needs: build strategy: fail-fast: false matrix: @@ -68,9 +96,11 @@ jobs: ~/.cargo key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-cargo- - - name: Build binary - # the binary will be used by the next cargo test step - run: cargo build + - uses: actions/download-artifact@v4 + with: + name: target + path: artifact + - run: tar -xvzf artifact/target.tgz && rm artifact/target.tgz - name: Run cargo tests env: AMBER_TEST_STRATEGY: docker