From 1834f988033bcaee1538172fd0ad0e9f868ef3b0 Mon Sep 17 00:00:00 2001 From: Brad Edwards Date: Thu, 2 Jan 2025 07:36:13 +0000 Subject: [PATCH] Add CI/CD workflow for unit tests and coverage check --- .github/workflows/ci.yml | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..20212de --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ + +name: CI/CD + +on: + push: + branches: + - chore/basic-ci-cd + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Install dependencies + run: sudo apt-get install lcov + - name: Run tests + run: | + cargo test --manifest-path crates/cs/Cargo.toml + - name: Generate coverage report + run: | + cargo install cargo-tarpaulin + cargo tarpaulin --out Xml --manifest-path crates/cs/Cargo.toml + - name: Check coverage + run: | + bash <(curl -s https://codecov.io/bash) -f lcov.info + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - name: Fail if coverage is below 90% + run: | + bash <(curl -s https://codecov.io/bash) -f lcov.info + if [ $(lcov --summary lcov.info | grep -Eo '[0-9]+\.[0-9]+' | head -1) -lt 90 ]; then + echo "Coverage is below 90%"; + exit 1; + fi