From f74eed6338894f684fdb2140fbde63f65676d15d Mon Sep 17 00:00:00 2001 From: Ivan Leo Date: Mon, 8 Jul 2024 16:09:55 +0800 Subject: [PATCH] Speed up CI (#20) CI was indeed sped up --- .github/workflows/test.yml | 44 +++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 657a392..a073a99 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,41 +1,55 @@ name: Cargo Build & Test on: - push: pull_request: env: CARGO_TERM_COLOR: always jobs: - build_and_test: - name: Rust project - latest + build: + name: Build Rust project - latest runs-on: ubuntu-latest strategy: matrix: toolchain: - stable - - beta + # - beta + # - nightly + crate: + # - instruct-macros + - instructor + steps: + - uses: actions/checkout@v4 + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + path: ${{ matrix.crate }} + - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} + - run: cd ${{ matrix.crate }} && cargo build --verbose + + test: + name: Test Rust project - latest + runs-on: ubuntu-latest + needs: build + strategy: + matrix: + toolchain: + # - stable + # - beta - nightly crate: - - instruct-macros + # - instruct-macros - instructor steps: - uses: actions/checkout@v4 - - name: Cache cargo-nextest - id: cargo-nextest-cache - uses: actions/cache@v3 + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 with: - path: ~/.cargo/bin/cargo-nextest - key: ${{ runner.os }}-cargo-nextest-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-nextest-${{ matrix.toolchain }}- - ${{ runner.os }}-cargo-nextest- + path: ${{ matrix.crate }} - name: Install cargo-nextest - if: steps.cargo-nextest-cache.outputs.cache-hit != 'true' run: cargo install cargo-nextest --locked - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} - - run: cd ${{ matrix.crate }} && cargo build --verbose - run: cd ${{ matrix.crate }} && cargo nextest run --verbose --retries 3 env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}