diff --git a/.github/workflows/general.yml b/.github/workflows/general.yml index 172df6b..5bc9ff8 100644 --- a/.github/workflows/general.yml +++ b/.github/workflows/general.yml @@ -21,6 +21,7 @@ jobs: test: name: Test runs-on: ubuntu-latest + # Service containers to run alongside the `test` container job services: postgres: # Docker Hub image @@ -47,6 +48,7 @@ jobs: # It also takes care of caching intermediate build artifacts. - name: Install the Rust toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Install sqlx-cli run: cargo install sqlx-cli @@ -57,16 +59,18 @@ jobs: # The --locked flag can be used to force Cargo to use the packaged Cargo.lock file if it is available. # This may be useful for ensuring reproducible builds, to use the exact same set of dependencies that were available when the package was published. # It may also be useful if a newer version of a dependency is published that no longer builds on your system, or has other problems + - name: Migrate database 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 --workspace --check + - name: Run tests run: cargo test + - name: Check that queries are fresh + run: cargo sqlx prepare --workspace --check -- --all-targets + + # `fmt` container job fmt: name: Rustfmt runs-on: ubuntu-latest @@ -82,31 +86,14 @@ jobs: 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 + env: + SQLX_OFFLINE: true steps: - uses: actions/checkout@v4 - name: Install the Rust toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 with: components: clippy - - 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 diff --git a/.sqlx/query-0029b925e31429d25d23538804511943e2ea1fddc5a2db9a4e219c9b5be53fce.json b/.sqlx/query-0029b925e31429d25d23538804511943e2ea1fddc5a2db9a4e219c9b5be53fce.json new file mode 100644 index 0000000..226aac8 --- /dev/null +++ b/.sqlx/query-0029b925e31429d25d23538804511943e2ea1fddc5a2db9a4e219c9b5be53fce.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO users (user_id, username, password_hash)\n VALUES ($1, $2, $3)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "0029b925e31429d25d23538804511943e2ea1fddc5a2db9a4e219c9b5be53fce" +} diff --git a/.sqlx/query-9ab6536d2bf619381573b3bf13507d53b2e9cf50051e51c803e916f25b51abd2.json b/.sqlx/query-9ab6536d2bf619381573b3bf13507d53b2e9cf50051e51c803e916f25b51abd2.json new file mode 100644 index 0000000..7723625 --- /dev/null +++ b/.sqlx/query-9ab6536d2bf619381573b3bf13507d53b2e9cf50051e51c803e916f25b51abd2.json @@ -0,0 +1,32 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT email, name, status FROM subscriptions", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "email", + "type_info": "Text" + }, + { + "ordinal": 1, + "name": "name", + "type_info": "Text" + }, + { + "ordinal": 2, + "name": "status", + "type_info": "Text" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false, + false, + false + ] + }, + "hash": "9ab6536d2bf619381573b3bf13507d53b2e9cf50051e51c803e916f25b51abd2" +} diff --git a/.sqlx/query-aa6ec2d18c8536eb8340bdf02a833440ff7954c503133ed99ebd6190822edf04.json b/.sqlx/query-aa6ec2d18c8536eb8340bdf02a833440ff7954c503133ed99ebd6190822edf04.json new file mode 100644 index 0000000..94d4b63 --- /dev/null +++ b/.sqlx/query-aa6ec2d18c8536eb8340bdf02a833440ff7954c503133ed99ebd6190822edf04.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "ALTER TABLE subscriptions DROP COLUMN email;", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "aa6ec2d18c8536eb8340bdf02a833440ff7954c503133ed99ebd6190822edf04" +}