Skip to content

Commit

Permalink
Merge pull request #55 from oiwn/dev
Browse files Browse the repository at this point in the history
CI pipeline
  • Loading branch information
oiwn authored Dec 26, 2024
2 parents 5ab5b22 + 7bdc405 commit 8ef6742
Show file tree
Hide file tree
Showing 14 changed files with 426 additions and 8 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/additional-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# .github/workflows/additional-checks.yml
name: additional checks

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
security-audit:
name: security audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install cargo-audit
run: cargo install cargo-audit
- name: run security audit
run: cargo audit --ignore RUSTSEC-2023-0071

docs:
name: documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: check documentation
env:
rustdocflags: "-d warnings"
run: cargo doc --no-deps --all-features --workspace
40 changes: 37 additions & 3 deletions .github/workflows/ci.yml → .github/workflows/ci.yml.disabled
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ name: Continuous Integration

on:
push:
branches: [ main, master ]
branches: [ main ]
pull_request:
branches: [ main, master ]
branches: [ main ]
workflow_dispatch: # Manual trigger

env:
CARGO_TERM_COLOR: always
REDIS_URI: redis://localhost:6379
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/testdb

jobs:
check:
Expand Down Expand Up @@ -46,7 +47,6 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
mongodb:
image: mongo:6
ports:
Expand All @@ -56,8 +56,22 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: testdb
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
MONGODB_URI: mongodb://localhost:27017/testdb
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/testdb

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -179,6 +193,19 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: testdb
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4

Expand All @@ -195,6 +222,12 @@ jobs:
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install SQLx CLI
run: cargo install sqlx-cli --no-default-features --features postgres

- name: Run SQLx Migrations
run: sqlx migrate run

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
Expand All @@ -211,3 +244,4 @@ jobs:
verbose: true
env:
MONGODB_URI: mongodb://localhost:27017/testdb
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/testdb
44 changes: 44 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# .github/workflows/code-quality.yml
name: Code Quality

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
fmt:
name: Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Clippy check
run: cargo clippy --all-features --workspace -- -D warnings
111 changes: 111 additions & 0 deletions .github/workflows/platform-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Platform & Coverage

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
MONGODB_URI: mongodb://localhost:27017/testdb
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/testdb

jobs:
cross-platform:
name: Cross-platform tests
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Run unit tests only
env:
SQLX_OFFLINE: true
run: cargo test --lib --workspace --no-default-features

coverage:
name: Code coverage
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
mongodb:
image: mongo:6
ports:
- 27017:27017
options: >-
--health-cmd "mongosh --eval 'db.runCommand(\"ping\").ok'"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: testdb
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
REDIS_URI: redis://localhost:6379
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/testdb
MONGODB_URI: mongodb://localhost:27017/testdb

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install sqlx-cli
run: cargo install sqlx-cli --no-default-features --features postgres

- name: Run database migrations
run: cargo sqlx migrate run

- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Generate code coverage
run: cargo llvm-cov --workspace --lcov --output-path lcov.info

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: true
verbose: true
80 changes: 80 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# .github/workflows/test.yml
name: Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
REDIS_URI: redis://localhost:6379
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/testdb
MONGODB_URI: mongodb://localhost:27017/testdb

jobs:
test:
name: Test Suite
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
mongodb:
image: mongo:6
ports:
- 27017:27017
options: >-
--health-cmd "mongosh --eval 'db.runCommand(\"ping\").ok'"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: testdb
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install sqlx-cli
run: cargo install sqlx-cli --no-default-features --features postgres

- name: Run database migrations
run: cargo sqlx migrate run

- name: Cargo check
run: cargo check --all-features --workspace

- name: Run unit tests
run: cargo test --lib --all-features --workspace

- name: Run integration tests
run: cargo test --test '*' --all-features --workspace

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8ef6742

Please sign in to comment.