Skip to content

Commit 07ca723

Browse files
committed
ci/cd: prod/dev labels fix
1 parent c476c03 commit 07ca723

6 files changed

Lines changed: 18 additions & 6 deletions

File tree

.github/scripts/build_plan.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from runner import (
88
PRODUCTION_RUNNER,
99
ValidationError,
10+
build_runner_labels,
1011
fail,
1112
load_coin_context,
1213
log,
@@ -44,6 +45,7 @@ def main() -> None:
4445
"runner": runner,
4546
"coins": coins,
4647
"coins_csv": ",".join(coins),
48+
"labels_json": json.dumps(build_runner_labels(runner, build_env), separators=(",", ":")),
4749
}
4850
)
4951

@@ -60,7 +62,10 @@ def main() -> None:
6062
log("Skipped prod-only coins for env=dev: " + ", ".join(selection.skipped_prod_only))
6163
log("Selected coins: " + ", ".join(selection.coins))
6264
for item in runner_matrix:
63-
log(f"Runner {item['runner']}: {', '.join(item['coins'])}")
65+
log(
66+
f"Runner {item['runner']} labels={item['labels_json']}: "
67+
+ ", ".join(item["coins"])
68+
)
6469

6570

6671
if __name__ == "__main__":

.github/scripts/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def create_parser() -> tuple[argparse.ArgumentParser, dict[str, argparse.Argumen
322322
description=(
323323
"Build Debian packages only.\n"
324324
"- env=dev uses BB_RUNNER_* mapping and ALL skips prod-only coins\n"
325-
"- env=prod builds selected coins on production_builder"
325+
"- env=prod builds selected coins on the production-builder runner"
326326
),
327327
)
328328
add_common_workflow_args(build_parser)

.github/scripts/runner.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pathlib import Path
88

99
PRODUCTION_RUNNER = "production_builder"
10+
PRODUCTION_RUNNER_LABEL = "production-builder"
1011
LOG_PREFIX = "CI/CD Pipeline:"
1112

1213

@@ -136,6 +137,12 @@ def is_production_only_runner(runner: str) -> bool:
136137
return runner == PRODUCTION_RUNNER
137138

138139

140+
def build_runner_labels(runner: str, build_env: str) -> list[str]:
141+
if build_env == "prod":
142+
return ["self-hosted", PRODUCTION_RUNNER_LABEL]
143+
return ["self-hosted", "bb-dev-selfhosted", runner]
144+
145+
139146
def coin_config_path(workspace: Path, coin: str) -> Path:
140147
return workspace / "configs" / "coins" / f"{coin}.json"
141148

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
fail-fast: false
106106
matrix:
107107
include: ${{ fromJSON(needs.prepare_build.outputs.runner_matrix || '[]') }}
108-
runs-on: [self-hosted, bb-dev-selfhosted, "${{ matrix.runner }}"]
108+
runs-on: ${{ fromJSON(matrix.labels_json) }}
109109
steps:
110110
- name: Checkout code
111111
uses: actions/checkout@v4

docs/ci_cd.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Inputs:
4747
4. run post-deploy e2e tests
4848
- `env`:
4949
- `dev` keeps the current per-coin dev runner mapping
50-
- `prod` builds selected coins on `production_builder` regardless of `BB_RUNNER_*`
50+
- `prod` builds selected coins on the `production-builder` runner regardless of `BB_RUNNER_*`
5151
- default is `dev`
5252
- ignored when `mode=deploy`
5353
- `always_build_backend`:
@@ -77,7 +77,7 @@ See also [CI/CD workflow variables](env.md#cicd-workflow-variables).
7777
Special cases:
7878

7979
- `mode=build` + `env=dev` skips prod-only coins when `coins=ALL`
80-
- `mode=build` + `env=prod` + `coins=ALL` builds all configured coins with `BB_RUNNER_*` mappings on `production_builder`
80+
- `mode=build` + `env=prod` + `coins=ALL` builds all configured coins with `BB_RUNNER_*` mappings on the `production-builder` runner
8181
- `mode=build` + `env=dev` fails if you explicitly request a coin whose `BB_RUNNER_*` is `production_builder`
8282
- `mode=deploy` is dev-only and fails fast if any selected coin is mapped to `production_builder`
8383

docs/env.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Some behavior of Blockbook can be modified by environment variables. The variabl
3333
## CI/CD workflow variables
3434

3535
- `BB_RUNNER_<coin>` - Maps a workflow/config coin name from `configs/coins/<coin>.json` to the self-hosted runner label
36-
used by the `Build / Deploy` workflow. `production_builder` marks coins that are buildable only in `env=prod`.
36+
used by the `Build / Deploy` workflow. `production_builder` marks coins that are buildable only in `env=prod`; those builds run on the `production-builder` self-hosted runner label.
3737

3838
- `BB_PACKAGE_ROOT` - Absolute filesystem path where workflow build jobs stage copied `.deb` packages after build.
3939
Defaults to `/opt/blockbook-builds` in the workflow.

0 commit comments

Comments
 (0)