diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index 0c38d57..0000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,3 +0,0 @@ -[target.x86_64-unknown-linux-gnu] -linker = "clang" -rustflags = ["-C", "link-arg=-fuse-ld=/usr/bin/mold"] diff --git a/.dockerignore b/.dockerignore index 8b2ecb7..878418f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -6,7 +6,6 @@ Dockerfile /migrations /node_modules /assets/css/main.css -/.cargo /.github README.md /tests diff --git a/.github/workflows/general.yml b/.github/workflows/general.yml index e3058c6..6d53fc0 100644 --- a/.github/workflows/general.yml +++ b/.github/workflows/general.yml @@ -13,11 +13,9 @@ env: CARGO_TERM_COLOR: always SQLX_VERSION: 0.8.6 SQLX_FEATURES: "rustls,postgres" - APP_USER: app - APP_USER_PWD: secret - APP_DB_NAME: newsletter - APP_DATABASE__PORT: 15432 - APP_REDIS_URI: redis://127.0.0.1:16379 + DATABASE_URL: postgres://postgres:password@postgres:5432/newsletter + APP_DATABASE__HOST: postgres + APP_REDIS_URI: redis://redis:6379 jobs: test: @@ -29,7 +27,7 @@ jobs: env: POSTGRES_USER: postgres POSTGRES_PASSWORD: password - POSTGRES_DB: postgres + POSTGRES_DB: newsletter ports: - 15432:5432 redis: @@ -49,19 +47,10 @@ jobs: --features ${{ env.SQLX_FEATURES }} --no-default-features --locked - - name: Create app user in Postgres - run: | - sudo apt-get update && sudo apt-get install postgresql-client - - CREATE_QUERY="CREATE USER ${APP_USER} WITH PASSWORD '${APP_USER_PWD}';" - PGPASSWORD="password" psql -U postgres -h localhost -p 15432 -c "${CREATE_QUERY}" - - GRANT_QUERY="ALTER USER ${APP_USER} CREATEDB;" - PGPASSWORD="password" psql -U postgres -h localhost -p 15432 -c "${GRANT_QUERY}" - name: Migrate database - run: SKIP_DOCKER=true ./scripts/init_db.sh + run: cargo sqlx migrate run - name: Run tests - run: cargo test + run: TEST_LOG=true cargo test - name: Check that queries are fresh run: cargo sqlx prepare --check --workspace @@ -102,7 +91,7 @@ jobs: env: POSTGRES_USER: postgres POSTGRES_PASSWORD: password - POSTGRES_DB: postgres + POSTGRES_DB: newsletter ports: - 15432:5432 redis: @@ -122,17 +111,8 @@ jobs: --features ${{ env.SQLX_FEATURES }} --no-default-features --locked - - name: Create app user in Postgres - run: | - sudo apt-get update && sudo apt-get install postgresql-client - - CREATE_QUERY="CREATE USER ${APP_USER} WITH PASSWORD '${APP_USER_PWD}';" - PGPASSWORD="password" psql -U postgres -h localhost -p 15432 -c "${CREATE_QUERY}" - - GRANT_QUERY="ALTER USER ${APP_USER} CREATEDB;" - PGPASSWORD="password" psql -U postgres -h localhost -p 15432 -c "${GRANT_QUERY}" - name: Migrate database - run: SKIP_DOCKER=true ./scripts/init_db.sh + run: cargo sqlx migrate run - name: Install cargo-llvm-cov uses: taiki-e/install-action@cargo-llvm-cov - name: Generate code coverage diff --git a/tests/api/unsubscribe.rs b/tests/api/unsubscribe.rs index 1d2c52b..23227b3 100644 --- a/tests/api/unsubscribe.rs +++ b/tests/api/unsubscribe.rs @@ -48,7 +48,9 @@ async fn subscriber_can_unsubscribe(connection_pool: PgPool) { } #[sqlx::test] -async fn a_valid_unsubscribe_link_is_present_in_new_post_email_notifications(connection_pool: PgPool) { +async fn a_valid_unsubscribe_link_is_present_in_new_post_email_notifications( + connection_pool: PgPool, +) { let app = TestApp::spawn(connection_pool).await; app.create_confirmed_subscriber().await; app.admin_login().await;