Skip to content

Commit 0635cb9

Browse files
committed
Take database URL as an environment variable
1 parent 358a723 commit 0635cb9

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ services:
3333
environment:
3434
HALIDE_BB_MASTER_ARTIFACTS_DIR: /artifacts
3535
HALIDE_BB_MASTER_SECRETS_DIR: /run/secrets
36+
HALIDE_BB_MASTER_DB_URL: "postgresql://buildbot:{DB_PASSWORD}@db/buildbot"
3637
logging:
3738
driver: local
3839
restart: unless-stopped

master.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,19 @@ fi
2828
# Check necessary files are present
2929

3030
secrets_dir="${HALIDE_BB_MASTER_SECRETS_DIR:-secrets}"
31-
for secret in buildbot_www_pass db_password github_token halide_bb_pass webhook_token; do
31+
for secret in buildbot_www_pass github_token halide_bb_pass webhook_token; do
3232
if [ ! -s "$secrets_dir/${secret}.txt" ]; then
3333
fail "Missing or empty $secrets_dir/${secret}.txt: cannot continue"
3434
fi
3535
done
3636

37+
db_url="${HALIDE_BB_MASTER_DB_URL:-sqlite:///state.sqlite}"
38+
if echo "$db_url" | grep -q '{DB_PASSWORD}'; then
39+
if [ ! -s "$secrets_dir/db_password.txt" ]; then
40+
fail "Missing or empty $secrets_dir/db_password.txt: required by HALIDE_BB_MASTER_DB_URL"
41+
fi
42+
fi
43+
3744
##
3845
# Resolve the buildbot command
3946

master/master.cfg

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ SECRETS_DIR = REPO_DIR / os.environ.get("HALIDE_BB_MASTER_SECRETS_DIR", "secrets
5252
# SECRETS
5353

5454
BUILDBOT_WWW_PASS = (SECRETS_DIR / "buildbot_www_pass.txt").read_text().strip()
55-
DB_PASSWORD = (SECRETS_DIR / "db_password.txt").read_text().strip()
5655
GITHUB_TOKEN = (SECRETS_DIR / "github_token.txt").read_text().strip()
5756
HALIDE_BB_PASS = (SECRETS_DIR / "halide_bb_pass.txt").read_text().strip()
5857
WEBHOOK_TOKEN = (SECRETS_DIR / "webhook_token.txt").read_text().strip()
5958

59+
DB_URL = os.environ.get("HALIDE_BB_MASTER_DB_URL", "sqlite:///state.sqlite")
60+
if "{DB_PASSWORD}" in DB_URL:
61+
DB_PASSWORD = (SECRETS_DIR / "db_password.txt").read_text().strip()
62+
DB_URL = DB_URL.replace("{DB_PASSWORD}", DB_PASSWORD)
63+
6064
# LLVM
6165

6266
# At any given time, we test (at least) 3 LLVM versions:
@@ -2323,7 +2327,7 @@ c["buildbotURL"] = "https://buildbot.halide-lang.org/master/"
23232327
# DB URL
23242328

23252329
c["db"] = {
2326-
"db_url": f"postgresql://buildbot:{DB_PASSWORD}@db/buildbot",
2330+
"db_url": DB_URL,
23272331
}
23282332

23292333
# GitHub Integration

0 commit comments

Comments
 (0)