Skip to content

Commit

Permalink
Refactor: remove audit ci
Browse files Browse the repository at this point in the history
  • Loading branch information
runningwater committed Aug 28, 2024
1 parent f8d6ee3 commit 04eb497
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DATABASE_URL="postgres://postgres:password@localhost:5432/newsletter"
DATABASE_URL="postgres://postgres:ynwd1985@localhost:5432/newsletter"
File renamed without changes.
80 changes: 6 additions & 74 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,55 +37,15 @@ jobs:
uses: actions/checkout@v3
- name: Install the Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Rust cache cleanup
uses: Swatinem/rust-cache@v2
with:
key: sqlx-${{ env.SQLX_VERSION }}
- name: Install slqx-client
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

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Enforce formatting
run: cargo fmt --check

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-client
- name: Install slqx-client
run: cargo install sqlx-cli
--version=${{ env.SQLX_VERSION }}
--features ${{ env.SQLX_FEATURES }}
Expand All @@ -95,37 +55,9 @@ jobs:
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
- name: Clippy 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
- name: Run tests
run: cargo test
20 changes: 18 additions & 2 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ path = "src/lib.rs"

[dependencies]
actix-web = "4.8.0"
chrono = "0.4.38"
config = { version = "0.14.0", features = ["yaml"] }
serde = { version = "1.0.204", features = ["derive"] }
tokio = { version = "1.39.3", features = ["rt", "rt-multi-thread", "macros"] }
uuid = { version = "1.10.0", features = ["v4"] }

[dependencies.sqlx]
Expand Down
2 changes: 1 addition & 1 deletion configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ database:
host: "127.0.0.1"
port: 5432
username: "postgres"
password: "password"
password: "ynwd1985"
database_name: "newsletter"
2 changes: 1 addition & 1 deletion scripts/init_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ DB_PASSWORD="${POSTGRES_PASSWORD:=password}"
# Check if a custom database name has been set, otherwise default to 'newsletter'
DB_NAME="${POSTGRES_DB:=newsletter}"
# Check if a custom port has been set, otherwise default to '5432'
DB_PORT="${POSTGRES_PORT:=5432}"
DB_PORT="${POSTGRES_PORT:=5433}"

# Launch postgres using Docker
docker run \
Expand Down

0 comments on commit 04eb497

Please sign in to comment.