-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: setup ci for testing with docker compose (#29)
- Loading branch information
1 parent
90f6daa
commit 90fab8a
Showing
5 changed files
with
59 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,55 +11,65 @@ on: | |
- sepolia-db | ||
|
||
jobs: | ||
rust-ci: | ||
fmt: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Check code formatting | ||
run: cargo fmt -- --check | ||
|
||
clippy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the code | ||
uses: actions/checkout@v3 | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Cache Cargo registry | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cargo/registry | ||
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-cargo-registry- | ||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Cache Cargo index | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cargo/index | ||
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-cargo-index- | ||
- name: Run Clippy | ||
run: cargo clippy --all-targets --all-features -- -D warnings | ||
|
||
- name: Cache Cargo build | ||
uses: actions/cache@v3 | ||
with: | ||
path: target | ||
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-cargo-build- | ||
build: | ||
needs: [fmt, clippy] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
components: rustfmt, clippy | ||
override: true | ||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Install dependencies | ||
run: cargo fetch | ||
- name: Build | ||
run: cargo build | ||
|
||
- name: Check code formatting | ||
run: cargo fmt -- --check | ||
tests: | ||
needs: [build] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Run Clippy | ||
run: cargo clippy --all-targets --all-features -- -D warnings | ||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Build the project | ||
run: cargo build --verbose | ||
- name: Setup test env | ||
uses: hoverkraft-tech/[email protected] | ||
with: | ||
compose-file: "./docker-compose.test.yml" | ||
|
||
- name: Install required tools | ||
run: cargo install cargo-llvm-cov | ||
|
||
- run: chmod +x scripts/run-coverage.sh | ||
|
||
- name: Run tests | ||
run: cargo test --all --verbose | ||
run: scripts/run-coverage.sh | ||
|
||
- uses: hrishikesh-kadam/setup-lcov@v1 | ||
with: | ||
ref: v2.2 | ||
|
||
- name: Report code coverage | ||
uses: zgosalvez/github-actions-report-lcov@v4 | ||
with: | ||
coverage-files: lcov.info | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
update-comment: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export TEST_DB_CONNECTION_STRING="postgresql://postgres:postgres@localhost:5433/fossil_test" | ||
|
||
# Run tests with coverage using cargo-llvm-cov. | ||
# Note that you will have to install the tarpaulin binary via cargo install cargo-llvm-cov. | ||
cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export TEST_DB_CONNECTION_STRING="postgresql://postgres:postgres@localhost:5433/fossil_test" | ||
|
||
# Run tests | ||
cargo test |
File renamed without changes.