-
Notifications
You must be signed in to change notification settings - Fork 13
ci: validate docker config templates against toml examples #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
plebhash
merged 4 commits into
stratum-mining:main
from
lucasbalieiro:add-docker-config-check
Jan 9, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a5bd62a
ci: validate docker config templates against toml examples
lucasbalieiro 736206d
ci: publish docker images when pushes are made to main and tag them a…
lucasbalieiro fd0eec8
docker: make `docker-compose.yml` point to the `main` images
lucasbalieiro cc23006
update `docker/README.md` to reflect the changes in the tag name
lucasbalieiro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| name: Validate Docker Config Drift | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| validate-config: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Validate config vs Docker templates | ||
| run: | | ||
| bash scripts/validate-docker-config.sh | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
|
|
||
| CONFIG_FILES=( | ||
| "pool-apps/pool/config-examples/mainnet/pool-config-bitcoin-core-ipc-example.toml" | ||
| "pool-apps/jd-server/config-examples/mainnet/jds-config-local-example.toml" | ||
| "miner-apps/jd-client/config-examples/mainnet/jdc-config-bitcoin-core-ipc-hosted-infra-example.toml" | ||
| "miner-apps/translator/config-examples/mainnet/tproxy-config-local-jdc-example.toml" | ||
| ) | ||
|
|
||
| get_template_for_config() { | ||
| case "$1" in | ||
| pool-apps/pool/config-examples/mainnet/pool-config-bitcoin-core-ipc-example.toml) | ||
| echo "docker/config/pool-config.toml.template" | ||
| ;; | ||
| pool-apps/jd-server/config-examples/mainnet/jds-config-local-example.toml) | ||
| echo "docker/config/jds-config.toml.template" | ||
| ;; | ||
| miner-apps/jd-client/config-examples/mainnet/jdc-config-bitcoin-core-ipc-hosted-infra-example.toml) | ||
| echo "docker/config/jdc-config.toml.template" | ||
| ;; | ||
| miner-apps/translator/config-examples/mainnet/tproxy-config-local-jdc-example.toml) | ||
| echo "docker/config/translator-proxy-config.toml.template" | ||
| ;; | ||
| *) | ||
| echo "" | ||
| ;; | ||
| esac | ||
| } | ||
|
|
||
| # WARNING: Implemented with GPT-5 | ||
| # | ||
| # Extracts key names from a TOML-like file. | ||
| # | ||
| # Behavior: | ||
| # - Ignores comments and blank lines | ||
| # - Tracks the current [section] | ||
| # - For lines containing '=', treats the left-hand side as a key | ||
| # - Outputs keys as "section.key" or "key" if no section is active | ||
| # - Sorts and removes duplicates | ||
| # | ||
| # Limitations: | ||
| # - Not a full TOML parser | ||
| # - Does not handle quoted keys, inline tables, arrays, multiline strings, | ||
| # escapes, or nested sections | ||
| extract_keys() { | ||
| local file="$1" | ||
|
|
||
| awk ' | ||
| /^[[:space:]]*#/ { next } | ||
| /^[[:space:]]*$/ { next } | ||
|
|
||
| /^\[.*\]$/ { | ||
| section=$0 | ||
| gsub(/[\[\]]/, "", section) | ||
| next | ||
| } | ||
|
|
||
| /=/ { | ||
| split($0, a, "=") | ||
| key=a[1] | ||
| gsub(/[[:space:]]+$/, "", key) | ||
|
|
||
| if (section != "") | ||
| print section "." key | ||
| else | ||
| print key | ||
| } | ||
| ' "$file" | sort -u | ||
| } | ||
plebhash marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| echo "Validating TOML structure against Docker templates" | ||
| echo | ||
|
|
||
| FAILED=0 | ||
|
|
||
| for CONFIG_FILE in "${CONFIG_FILES[@]}"; do | ||
| TEMPLATE_FILE="$(get_template_for_config "$CONFIG_FILE")" | ||
|
|
||
| if [[ -z "$TEMPLATE_FILE" ]]; then | ||
| echo "❌ No Docker template mapped for $CONFIG_FILE" | ||
| FAILED=1 | ||
| continue | ||
| fi | ||
|
|
||
| if [[ ! -f "$CONFIG_FILE" ]]; then | ||
| echo "⚠️ Missing config file: $CONFIG_FILE" | ||
| FAILED=1 | ||
| continue | ||
| fi | ||
|
|
||
| if [[ ! -f "$TEMPLATE_FILE" ]]; then | ||
| echo "❌ Missing Docker template: $TEMPLATE_FILE" | ||
| FAILED=1 | ||
| continue | ||
| fi | ||
|
|
||
| echo "▶ Comparing" | ||
| echo " Config: $CONFIG_FILE" | ||
| echo " Template: $TEMPLATE_FILE" | ||
|
|
||
| CONFIG_KEYS=$(extract_keys "$CONFIG_FILE") | ||
| TEMPLATE_KEYS=$(extract_keys "$TEMPLATE_FILE") | ||
|
|
||
| DIFF=$(diff -u -U0 <(echo "$TEMPLATE_KEYS") <(echo "$CONFIG_KEYS") \ | ||
| | grep -E '^[+-]' || true) | ||
|
|
||
| if [[ -n "$DIFF" ]]; then | ||
| echo | ||
| echo "❌ Config / Docker drift detected" | ||
| echo | ||
| echo "$DIFF" | ||
| echo | ||
| FAILED=1 | ||
| else | ||
| echo "✅ In sync" | ||
| echo | ||
| fi | ||
| done | ||
|
|
||
| if [[ "$FAILED" -ne 0 ]]; then | ||
| echo "🚨 Docker templates are out of sync with config examples." | ||
| echo "👉 Update the Docker templates to reflect all config keys." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "All Docker templates match their configs." | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.