From 323e6544d9d2c821544d06b325cc9134cb2318cf Mon Sep 17 00:00:00 2001 From: Adrian Date: Mon, 24 Jul 2023 12:13:38 +0300 Subject: [PATCH] Update CI pipeline workflow --- .github/workflows/Tests.yml | 99 +++++++++++++++++++++++++++++++++++-- 1 file changed, 94 insertions(+), 5 deletions(-) diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index 466f53d..e4f7781 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -1,20 +1,54 @@ -name: Rust +name: Integration Tests on: pull_request: - branches: [ "master", "develop" ] + branches: + [ "master" ] env: CARGO_TERM_COLOR: always + SQLX_VERSION: 0.7.1 + SQLX_FEATURES: "rustls,postgres" jobs: test: name: Test runs-on: ubuntu-latest + services: + postgres: + image: postgres:14 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + POSTGRES_DB: postgres + ports: + - 5432:5432 steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Install the Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Rust Cache Action + uses: Swatinem/rust-cache@v2 + with: + key: sqlx-${{ env.SQLX_VERSION }} + + - name: Install sqlx-cli + run: + cargo install sqlx-cli + --version=${{ env.SQLX_VERSION }} + --features ${{ env.SQLX_FEATURES }} + --no-default-features + --locked + + - name: Install postgresql-client + run: sudo apt-get update && sudo apt-get install postgresql-client -y + + - name: Migrate database + run: SKIP_DOCKER=true ./scripts/init_db.sh + - name: Run tests run: cargo test @@ -32,11 +66,66 @@ jobs: clippy: name: Clippy runs-on: ubuntu-latest + services: + postgres: + image: postgres:14 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + POSTGRES_DB: postgres + ports: + - 5432:5432 steps: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@stable with: components: clippy - uses: Swatinem/rust-cache@v2 + with: + key: sqlx-${{ env.SQLX_VERSION }} + - name: Install sqlx-cli + run: + cargo install sqlx-cli + --version=${{ env.SQLX_VERSION }} + --features ${{ env.SQLX_FEATURES }} + --no-default-features + --locked + - name: Install postgresql-client + run: sudo apt-get update && sudo apt-get install postgresql-client -y + - name: Migrate database + run: SKIP_DOCKER=true ./scripts/init_db.sh - name: Linting run: cargo clippy -- -D warnings + + coverage: + name: Code coverage + runs-on: ubuntu-latest + services: + postgres: + image: postgres:14 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + POSTGRES_DB: postgres + ports: + - 5432:5432 + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + - name: Install postgresql-client + run: sudo apt-get update && sudo apt-get install postgresql-client -y + - uses: Swatinem/rust-cache@v2 + with: + key: sqlx-${{ env.SQLX_VERSION }} + - name: Install sqlx-cli + run: + cargo install sqlx-cli + --version=${{ env.SQLX_VERSION }} + --features ${{ env.SQLX_FEATURES }} + --no-default-features + --locked + - name: Migrate database + run: SKIP_DOCKER=true ./scripts/init_db.sh + - name: Generate code coverage + run: cargo install cargo-tarpaulin && cargo tarpaulin --verbose --workspace