Skip to content

Commit

Permalink
Refactor actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ftassi committed Sep 15, 2023
1 parent 47bbdb9 commit f7b174a
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions .github/workflows/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on: [push, pull_request]

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

jobs:
test:
Expand All @@ -12,12 +14,24 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run tests
- name: Rust Cache Action
uses: Swatinem/rust-cache@v2
with:
# An additional cache key that is added alongside the automatic `job`-based cache key and can be used to further differentiate jobs. default: empty
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: |
cargo install sqlx-cli --no-default-features --features rustls,postgres
sqlx database create
sqlx migrate run
- name: Run tests
run: |
cargo test
services:
db:
Expand All @@ -28,8 +42,6 @@ jobs:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_PORT: 5432
POSTGRES_HOST: localhost
options: >-
--health-cmd pg_isready
--health-interval 10s
Expand All @@ -49,22 +61,6 @@ jobs:
sqlx database create
sqlx migrate run
cargo fmt --check
services:
db:
image: postgres:15.4
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_PORT: 5432
POSTGRES_HOST: localhost
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
clippy:
name: Clippy
Expand All @@ -74,7 +70,11 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Rust Cache Action
uses: Swatinem/rust-cache@v2
with:
# An additional cache key that is added alongside the automatic `job`-based cache key and can be used to further differentiate jobs. default: empty
key: sqlx-${{ env.SQLX_VERSION }}
- name: Linting
run: |
cargo install sqlx-cli --no-default-features --features rustls,postgres
Expand All @@ -90,8 +90,6 @@ jobs:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_PORT: 5432
POSTGRES_HOST: localhost
options: >-
--health-cmd pg_isready
--health-interval 10s
Expand Down Expand Up @@ -122,8 +120,6 @@ jobs:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_PORT: 5432
POSTGRES_HOST: localhost
options: >-
--health-cmd pg_isready
--health-interval 10s
Expand Down

0 comments on commit f7b174a

Please sign in to comment.