From 8c68352604eaf2dd03b872e79dc1a2631515ac40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20C=C3=A1rdenas?= Date: Fri, 4 Oct 2024 11:44:33 -0600 Subject: [PATCH] ci: separate tests into component suites (#650) Optimizes GH action times by running component tests in parallel --- .github/workflows/ci.yaml | 21 +++++++++++++++++---- .gitignore | 1 + 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fee0c0a02..0392847a4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,6 +17,13 @@ concurrency: jobs: test: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + suite: [cli, sdk] + defaults: + run: + working-directory: ./components/chainhook-${{ matrix.suite }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -29,7 +36,10 @@ jobs: echo "RUST_VERSION_HASH=$(rustc --version | sha256sum | awk '{print $1}')" >> $GITHUB_ENV - name: Install redis - run: sudo apt-get install -y redis-server + if: matrix.suite == 'cli' + run: | + sudo apt-get install -y redis-server + echo "TARPAULIN_FLAGS=--features redis_tests" >> $GITHUB_ENV - name: Cache cargo uses: actions/cache@v4 @@ -43,12 +53,15 @@ jobs: ~/.cargo/.crates.toml ~/.cargo/.crates2.json target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-rust-${{ env.RUST_VERSION_HASH }}-${{ matrix.suite }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Install and run cargo-tarpaulin + - name: Install cargo-tarpaulin run: | cargo install cargo-tarpaulin - cargo tarpaulin --skip-clean --out lcov --features redis_tests -- --test-threads=1 + + - name: Run tests + run: | + cargo tarpaulin --skip-clean --out lcov ${{ env.TARPAULIN_FLAGS }} -- --test-threads=1 - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 diff --git a/.gitignore b/.gitignore index d63cbe1d0..5fa09387d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ components/chainhook-types-js/dist *.rdb *.redb cache/ +Chainhook.toml components/chainhook-cli/src/service/tests/fixtures/tmp components/chainhook-cli/src/archive/tests/fixtures/tmp \ No newline at end of file