Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

ci(test): keep test Postgres data in shared memory (#9807)

teo265be1e1461d
diff --git a/.github/workflows/code_check_cloud_storage.yml b/.github/workflows/code_check_cloud_storage.yml
index e9187d2b8c..5acbdfe98f 100644
--- a/.github/workflows/code_check_cloud_storage.yml
+++ b/.github/workflows/code_check_cloud_storage.yml
@@ -606,7 +606,7 @@ jobs:
POSTGRES_DB: macrodb
ports:
- '5432:5432'
- options: '--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 --shm-size 1g'
+ options: '--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 --shm-size 1g -v /dev/shm/pgdata:/var/lib/postgresql/data'
redis:
image: redis:7
ports:
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage.rs
index 6ed1d3200c..a148c04782 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage.rs
@@ -370,6 +370,11 @@ fn cargo_clippy() -> Step<Run> {
}
/// Match production's PostgreSQL major version so CI rejects incompatible migrations.
+///
+/// Its data lives in shared memory because `#[sqlx::test]` creates and drops a
+/// database per test, and those file operations are what limit the test run on
+/// the runner's disk. A bind mount, not `--tmpfs`: `configure_postgres` restarts
+/// the container, and a restart empties a `--tmpfs` mount.
fn postgres_service() -> Container {
Container::default()
.image("pgvector/pgvector:pg14")
@@ -381,7 +386,8 @@ fn postgres_service() -> Container {
.ports(vec![Port::Name("5432:5432".to_string())])
.options(
"--health-cmd pg_isready --health-interval 10s --health-timeout 5s \
- --health-retries 5 --shm-size 1g",
+ --health-retries 5 --shm-size 1g \
+ -v /dev/shm/pgdata:/var/lib/postgresql/data",
)
}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage/test.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage/test.rs
index c7d770c4ef..a15f676963 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage/test.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/code_check_cloud_storage/test.rs
@@ -283,3 +283,16 @@ fn schema_changes_run_the_compatibility_check() {
let job = job.to_string();
assert!(job.contains("graphql-schema-compat --base HEAD^1"), "{job}");
}
+
+/// Per-test database creation is the bulk of the test run's time, and the
+/// settings `configure_postgres` applies only survive its restart on a bind mount.
+#[test]
+fn test_postgres_keeps_its_data_in_shared_memory_across_a_restart() {
+ let service = serde_json::to_value(postgres_service()).unwrap();
+ let options = service["options"].as_str().unwrap();
+ assert!(
+ options.contains("-v /dev/shm/pgdata:/var/lib/postgresql/data"),
+ "{options}"
+ );
+ assert!(!options.contains("--tmpfs"), "{options}");
+}