Skip to content

Commit

Permalink
Use redis (#1)
Browse files Browse the repository at this point in the history
* Use redis

* Fix workflow configuration
  • Loading branch information
UMR1352 authored Aug 4, 2023
1 parent 53d4987 commit dd6f126
Show file tree
Hide file tree
Showing 18 changed files with 378 additions and 795 deletions.
74 changes: 16 additions & 58 deletions .github/workflows/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,28 @@ on:

env:
CARGO_TERM_COLOR: always
SQLX_VERSION: 0.6.3
SQLX_FEATURES: "rustls,postgres"

jobs:
test:
name: Test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
redis:
image: redis/redis-stack-server:7.0.6-RC9
env:
POSTGRES_USER: emarconi
POSTGRES_PASSWORD: supa_password
POSTGRES_DB: todo
REDIS_ARGS: "--requirepass ${{ secrets.REDIS_PASSWORD }} --user ${{ secrets.REDIS_USER }} on >${{ secrets.REDIS_PASSWORD}} allkeys allcommands --user default off nopass nocommands"
ports:
- 5432:5432
- 6379:6379
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- 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
- name: Install redis-cli
run: sudo apt-get install -y redis-tools
- name: Feed redis scripts
run: |
sudo apt-get install libpq-dev -y
SKIP_DOCKER=true ./scripts/init_db.sh
- name: Check sqlx-data.json is up-to-date
run: |
cargo sqlx prepare --database-url postgres://emarconi:supa_password@localhost/todo --check -- --all-targets
SKIP_DOCKER=true ./scripts/run_redis.sh
- name: Run tests
run: cargo test

Expand All @@ -65,67 +51,39 @@ jobs:
name: Clippy
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
redis:
image: redis/redis-stack-server:7.0.6-RC9
env:
POSTGRES_USER: emarconi
POSTGRES_PASSWORD: supa_password
POSTGRES_DB: todo
REDIS_ARGS: "--requirepass ${{ secrets.REDIS_PASSWORD }} --user ${{ secrets.REDIS_USER }} on >${{ secrets.REDIS_PASSWORD}} allkeys allcommands --user default off nopass nocommands"
ports:
- 5432:5432
- 6379:6379
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: Migrate database
run: |
sudo apt-get install libpq-dev -y
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:15
redis:
image: redis/redis-stack-server:7.0.6-RC9
env:
POSTGRES_USER: emarconi
POSTGRES_PASSWORD: supa_password
POSTGRES_DB: todo
REDIS_ARGS: "--requirepass ${{ secrets.REDIS_PASSWORD }} --user ${{ secrets.REDIS_USER }} on >${{ secrets.REDIS_PASSWORD}} allkeys allcommands --user default off nopass nocommands"
ports:
- 5432:5432
- 6379:6379
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: Install libpq
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 tarpaulin
run: cargo install cargo-tarpaulin
- 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 tarpaulin --verbose --workspace
Loading

0 comments on commit dd6f126

Please sign in to comment.