fix(CI): sqlx offline mode
continuous-integration/drone/push Build is failing Details

main
flavien 2022-11-20 17:42:34 +00:00
parent e9d5761ca6
commit 175fa084d1
5 changed files with 44 additions and 6 deletions

View File

@ -26,15 +26,13 @@ steps:
- name: build
image: docker:dind
environment:
DATABASE_URL: postgres://postgres:password@localhost:5432/newsletter
SKIP_DOCKER: "true"
DOCKER_USER:
from_secret: docker_username
DOCKER_PASSWORD:
from_secret: docker_password
commands:
- echo $DOCKER_PASSWORD | docker login --username $DOCKER_USER --password-stdin registry.coincoingit.fr
- DOCKER_BUILDKIT=1 docker build --tag zero2prod:latest --network=host --file docker/build/Dockerfile .
- DOCKER_BUILDKIT=1 docker build --tag zero2prod:latest --file docker/build/Dockerfile .
- docker push registry.coincoingit.fr/zero2prod:latest
volumes:
- name: docker-sock
@ -61,6 +59,20 @@ steps:
branch:
- main
- name: migration
image: registry.coincoingit.fr/zero2prod-tests:latest
environment:
POSTGRES_HOST: zero2prod_postgres
POSTGRES_USER:
from_secret: postgres_user
POSTGRES_PASSWORD:
from_secret: postgres_password
POSTGRES_DB:
from_secret: postgres_db
SKIP_DOCKER: "true"
commands:
- ./scripts/init_db.sh
image_pull_secrets:
- dockerconfig

View File

@ -4,4 +4,11 @@ repos:
hooks:
- id: fmt
- id: cargo-check
- id: clippy
- id: clippy
- repo: local
hooks:
- id: sqlx-offline
name: sqlx-offline json
entry: cargo sqlx prepare -- --lib
language: system
pass_filenames: false

View File

@ -41,7 +41,8 @@ features = [
"postgres",
"uuid",
"chrono",
"migrate"
"migrate",
"offline"
]
[dev-dependencies]

View File

@ -3,7 +3,7 @@ FROM --platform=linux/amd64 rust:1.65 AS builder
WORKDIR /app
COPY . .
ENV SQLX_OFFLINE true
RUN cargo build --release
FROM --platform=linux/amd64 debian:bullseye-slim AS runtime

18
sqlx-data.json Normal file
View File

@ -0,0 +1,18 @@
{
"db": "PostgreSQL",
"304de8963dc48aea581a2f654649b374940ff7de644af89aa33d8a93b90cae5f": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Left": [
"Uuid",
"Text",
"Text",
"Timestamptz"
]
}
},
"query": "\n\t\tINSERT INTO subscriptions (id, email, name, subscribed_at) VALUES ($1, $2, $3, $4)\n\t\t"
}
}