From 275423b0505ce9fdebb0cb1879089f2db2330ab7 Mon Sep 17 00:00:00 2001 From: Guilherme Pereira Date: Sun, 17 Mar 2024 17:27:09 +0000 Subject: [PATCH] Add github actions --- .github/workflows/check-and-lint.yml | 48 +++++++++++++++++++ .github/workflows/tests.yml | 70 ++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 .github/workflows/check-and-lint.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/check-and-lint.yml b/.github/workflows/check-and-lint.yml new file mode 100644 index 0000000..68650d2 --- /dev/null +++ b/.github/workflows/check-and-lint.yml @@ -0,0 +1,48 @@ +name: Check and Lint + +on: + push: + pull_request: + branches: + - main + +jobs: + check: + name: Check + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - stable + steps: + # Checkout repository + - name: Checkout repository + uses: actions/checkout@v2 + + # Setup Rust + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + + # Cargo check + - name: Run cargo check + run: cargo check --all-targets + + clippy: + name: Clippy + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - stable + + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + - run: rustup component add clippy + - run: cargo clippy --all-targets -- -D warnings \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..24952b1 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,70 @@ +name: Tests + +on: + push: + pull_request: + branches: + - main + +jobs: + tests: + name: Run Tests + env: + PROJECT_NAME_UNDERSCORE: murray-rs + CARGO_INCREMENTAL: 0 + RUSTFLAGS: -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort + RUSTDOCFLAGS: -Cpanic=abort + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - nightly + + steps: + # Checkout repository + - name: Checkout repository + uses: actions/checkout@v2 + + # Setup Toolchain + - name: Setup Toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.rust }} + override: true + + # Build + - name: Build + run: cargo build $CARGO_OPTIONS + + # Cache + - name: Configure cache + uses: actions/cache@v2 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: test-${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} + + # Coverage + ##! CARGO_INCREMENTAL, RUSTFLAGS, RUSTDOCFLAGS - added to CARGO_OPTIONS in cargo test needed for code coverage + - name: Generate test result and coverage report + run: | + find . -name '*.gcda' -delete + cargo install grcov --force; + rm -rf lcov.info; + sudo apt install make -y + make run-all-tests $CARGO_OPTIONS; + zip -0 ccov.zip `find . \( -name "$PROJECT_NAME_UNDERSCORE*.gc*" \) -print`; + grcov ccov.zip -s . -t lcov --llvm --branch --ignore-not-existing --ignore "/*" -o lcov.info; + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + slug: Guilospanck/murray-rs + files: ./lcov.info + fail_ci_if_error: true \ No newline at end of file