# https://taskfile.dev version: "3" vars: EDITOR_DB_FILE: "/tmp/sqlo.sqlite" PG_DATABASE_URL: "postgres://postgres:password@localhost:5432/sqlo" MY_DATABASE_URL: "mysql://root:password@localhost:3306/sqlo" tasks: install_dependencies: cmds: - cargo install sqlx-cli migrate: cmds: - sqlx migrate run --source tests/migrations/{{.DB}} --database-url {{.DATABASE_URL}} run_test: env: DATABASE_URL: "{{.DATABASE_URL}}" cmds: - rm -rf .sqlo/ - cargo test --features={{.FEATURES}} {{.CLI_ARGS}} # trybuild: # vars: # .MORE_ARGS: "-- -- trybuild trybuild={{.CLI_ARGS}}" # cmds: # - task: sq-test # - task: pg-test # trybuild-overwrite: # env: # TRYBUILD: "overwrite" # cmds: # - task test -- -- trybuild trybuild={{.CLI_ARGS}} ######################### # Expand # ######################### expand_imp: env: DATABASE_URL: "{{ .DATABASE_URL }}" cmds: - cargo expand --features={{.FEATURES}} --test expand ######################### # Editor # ######################### remove_editor_db_file: cmds: - rm -f {{.EDITOR_DB_FILE}} create_editor_db_file: cmds: - touch {{.EDITOR_DB_FILE}} editor_imp: vars: DB_FILE: "/tmp/sqlo.sqlite" deps: [remove_editor_db_file] cmds: - task: create_editor_db_file - task: migrate vars: { DATABASE_URL: "sqlite://{{.DB_FILE}}", DB: "sqlite" } ######################### # Sqlite # ######################### sq-test: vars: SQLITE_DB: sh: mktemp /tmp/sqlo-{{.PROJECT}}-XXXX.sqlite DATABASE_URL: "sqlite://{{.SQLITE_DB}}" env: DATABASE_URL: "{{.DATABASE_URL}}" cmds: - task: migrate vars: { DATABASE_URL: "{{.DATABASE_URL}}", DB: "sqlite" } - task: run_test vars: { DATABASE_URL: "{{.DATABASE_URL}}", FEATURES: "sqlite" } sq-reset: cmds: - task: editor_imp sq-run: cmds: - task: sq-reset sq-expand: vars: SQLITE_DB: sh: mktemp /tmp/sqlo-{{.PROJECT}}-XXXX.sqlite DATABASE_URL: "sqlite://{{.SQLITE_DB}}" cmds: - task: migrate vars: { DATABASE_URL: "{{.DATABASE_URL}}", DB: "sqlite" } - task: expand_imp vars: { DATABASE_URL: "{{.DATABASE_URL}}", FEATURES: "sqlite" } ######################### # PostreSQl # ######################### pg-run: cmds: - docker run --rm -p 5432:5432 -e POSTGRES_PASSWORD=password -e POSTGRES_DB=sqlo --name sqlo_pg --rm -d postgres:14 -N 1000 pg-stop: cmds: - docker stop sqlo_pg pg-reset: cmds: - task: pg-stop - task: pg-run pg-test: cmds: - task: migrate vars: { DATABASE_URL: "{{.PG_DATABASE_URL}}", DB: "pg" } - task: run_test vars: DATABASE_URL: "{{ .PG_DATABASE_URL }}" FEATURES: "postgres" pg-expand: cmds: - task: migrate vars: { DATABASE_URL: "{{.PG_DATABASE_URL}}", DB: "pg" } - task: expand_imp vars: DATABASE_URL: "{{.PG_DATABASE_URL}}" FEATURES: "postgres" ######################### # MySQL # ######################### my-run: cmds: - docker run --rm -p 3306:3306 -e MARIADB_ROOT_PASSWORD=password -e MARIADB_DATABASE=sqlo --name sqlo_my -d mariadb:10 my-stop: cmds: - docker stop sqlo_my my-reset: cmds: - task: my-stop - task: my-run my-test: cmds: - task: migrate vars: { DATABASE_URL: "{{.MY_DATABASE_URL}}", DB: "my" } - task: run_test vars: DATABASE_URL: "{{ .MY_DATABASE_URL }}" FEATURES: "mysql" my-expand: cmds: - task: migrate vars: { DATABASE_URL: "{{.MY_DATABASE_URL}}", DB: "my" } - task: expand_imp vars: DATABASE_URL: "{{.MY_DATABASE_URL}}" FEATURES: "mysql" ######################### # All Together # ######################### test: - task: sq-test - task: pg-test - task: my-test reset: - task: sq-reset - task: pg-reset - task: my-reset run: - task: sq-run - task: pg-run - task: my-run stop: - task: pg-stop - task: my-stop check: - cargo check --features=sqlite - cargo check --features=postgres - cargo check --features=mysql clippy: - cargo clippy --features=sqlite - cargo clippy --features=postgres - cargo clippy --features=mysql