Small CI flakiness fix and performance tweak (#3780)

* perf(ci): use Turbo to schedule both `lint` and `test` tasks at once

* fix(ci): wait until service containers are initialized for tests

This is achieved by adding a health check to the containers, and
instructing the CI workflow to wait until the containers are healthy.
Not doing this wait risks spurious CI failures due to DB migrations
being applied before the DB even starts.

* chore(turbo): use locally installed schema in new Turbo override file

On the latest versions of Turbo, this ensures that the used schema is
always in sync with what's available in the installed Turbo version,
which is something that has already caused confusion to me before.
This commit is contained in:
Alejandro González 2025-06-13 23:34:40 +02:00 committed by GitHub
parent ab8e474339
commit c9b98a6154
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 41 additions and 22 deletions

View File

@ -25,12 +25,6 @@ jobs:
with: with:
fetch-depth: 2 fetch-depth: 2
# This is required because Tauri depends on the frontend build directory to
# exist, but it is not created until the frontend is built, which may happen
# after the backend is built
- name: 📁 Create Tauri frontend build directories
run: mkdir -p apps/app-frontend/dist
- name: 🧰 Install build dependencies - name: 🧰 Install build dependencies
run: | run: |
sudo apt-get update sudo apt-get update
@ -71,17 +65,14 @@ jobs:
- name: 🧰 Install dependencies - name: 🧰 Install dependencies
run: pnpm install run: pnpm install
- name: 🔍 Lint
run: pnpm lint
- name: ⚙️ Start services - name: ⚙️ Start services
run: docker compose up -d run: docker compose up --wait
- name: ⚙️ Setup Labrinth environment and database - name: ⚙️ Setup Labrinth environment and database
working-directory: apps/labrinth working-directory: apps/labrinth
run: | run: |
mv .env.local .env cp .env.local .env
sqlx database setup sqlx database setup
- name: ✔️ Test - name: 🔍 Lint and test
run: pnpm test run: pnpm run ci

14
apps/app/turbo.jsonc Normal file
View File

@ -0,0 +1,14 @@
{
"$schema": "../../node_modules/turbo/schema.json",
"extends": ["//"],
"tasks": {
// Running Clippy and tests on a Tauri application requires
// the frontend to be built at least once first
"lint": {
"dependsOn": ["@modrinth/app-frontend#build"]
},
"test": {
"dependsOn": ["@modrinth/app-frontend#build"]
}
}
}

View File

@ -9,6 +9,11 @@ services:
POSTGRES_USER: labrinth POSTGRES_USER: labrinth
POSTGRES_PASSWORD: labrinth POSTGRES_PASSWORD: labrinth
POSTGRES_HOST_AUTH_METHOD: trust POSTGRES_HOST_AUTH_METHOD: trust
healthcheck:
test: ['CMD', 'pg_isready']
interval: 3s
timeout: 5s
retries: 3
meilisearch: meilisearch:
image: getmeili/meilisearch:v1.12.0 image: getmeili/meilisearch:v1.12.0
restart: on-failure restart: on-failure
@ -19,6 +24,11 @@ services:
environment: environment:
MEILI_MASTER_KEY: modrinth MEILI_MASTER_KEY: modrinth
MEILI_HTTP_PAYLOAD_SIZE_LIMIT: 107374182400 MEILI_HTTP_PAYLOAD_SIZE_LIMIT: 107374182400
healthcheck:
test: ['CMD', 'curl', '--fail', 'http://localhost:7700/health']
interval: 3s
timeout: 5s
retries: 3
redis: redis:
image: redis:alpine image: redis:alpine
restart: on-failure restart: on-failure
@ -26,6 +36,11 @@ services:
- '6379:6379' - '6379:6379'
volumes: volumes:
- redis-data:/data - redis-data:/data
healthcheck:
test: ['CMD', 'redis-cli', 'PING']
interval: 3s
timeout: 5s
retries: 3
clickhouse: clickhouse:
image: clickhouse/clickhouse-server image: clickhouse/clickhouse-server
ports: ports:
@ -33,6 +48,11 @@ services:
environment: environment:
CLICKHOUSE_USER: default CLICKHOUSE_USER: default
CLICKHOUSE_PASSWORD: default CLICKHOUSE_PASSWORD: default
healthcheck:
test: ['CMD', 'clickhouse-client', '--query', 'SELECT 1']
interval: 3s
timeout: 5s
retries: 3
volumes: volumes:
meilisearch-data: meilisearch-data:
db-data: db-data:

View File

@ -18,6 +18,7 @@
"lint": "turbo run lint --continue", "lint": "turbo run lint --continue",
"test": "turbo run test --continue", "test": "turbo run test --continue",
"fix": "turbo run fix --continue", "fix": "turbo run fix --continue",
"ci": "turbo run lint test --continue",
"intl:extract": "pnpm ui:intl:extract && pnpm web:intl:extract && pnpm app:intl:extract" "intl:extract": "pnpm ui:intl:extract && pnpm web:intl:extract && pnpm app:intl:extract"
}, },
"devDependencies": { "devDependencies": {

View File

@ -45,15 +45,8 @@
"cache": false, "cache": false,
"persistent": true, "persistent": true,
"inputs": ["$TURBO_DEFAULT$", ".env*"], "inputs": ["$TURBO_DEFAULT$", ".env*"],
"env": [ "env": ["CARGO_*", "RUST_*", "RUSTFLAGS", "FORCE_COLOR", "NEXTEST_*"],
"DISPLAY", "passThroughEnv": ["DISPLAY", "WEBKIT_DISABLE_DMABUF_RENDERER"]
"WEBKIT_DISABLE_DMABUF_RENDERER",
"CARGO_*",
"RUST_*",
"RUSTFLAGS",
"FORCE_COLOR",
"NEXTEST_*"
]
}, },
"test": { "test": {
"env": [ "env": [