Skip to content

fix(ci): replace yq TOML parsing with bash grep/sed#1325

Merged
garbas merged 2 commits intomainfrom
replace-yq-with-bash-discovery
Feb 26, 2026
Merged

fix(ci): replace yq TOML parsing with bash grep/sed#1325
garbas merged 2 commits intomainfrom
replace-yq-with-bash-discovery

Conversation

@garbas
Copy link
Contributor

@garbas garbas commented Feb 25, 2026

Summary

  • Replace inline yq-based TOML parsing with scripts/discover-envs.sh (grep/sed)
  • yq cannot parse TOML files with comments, breaking the "Find environments" CI job
  • CI calls bash script directly -- no extra tooling (no just, no flox, no yq)
  • Add Justfile for local convenience, just added to devShell

Test plan

  • bash scripts/discover-envs.sh --validate passes all manifests (including comment-heavy ones like postgres, rust, fooocus)
  • UPDATE_ALL=true bash scripts/discover-envs.sh produces valid JSON (verified with jq)
  • CI "Find environments" job passes
  • Downstream test/containerize/push jobs receive correct matrix

yq cannot parse TOML files with comments, breaking the
"Find environments" CI job. Replace the inline yq-based
logic with a standalone bash script that uses grep/sed
for TOML extraction.

- Add scripts/discover-envs.sh with three modes:
  discover (CI JSON), --list (table), --validate
- Add Justfile for local developer convenience
- Add just to flake.nix devShell
- CI calls bash script directly (no extra tooling)
@github-actions github-actions bot added the team-content Issues to be picked up by @flox/team-content label Feb 25, 2026
Comment on lines +25 to +46
# Check if manifest has real (uncommented) service commands.
has_services() {
local manifest="$1"
# Match lines like: name.command = "..." that are NOT comments
grep -qE '^[^#]*\.command[[:space:]]*=' "$manifest"
}

# Extract systems list from [options] section.
# Handles both single-line and multi-line arrays.
# Returns empty string if no systems found.
get_systems() {
local manifest="$1"
local raw
raw="$(sed -n '/^\[options\]/,/^\[/p' "$manifest")" || true
if [ -z "$raw" ]; then
return 0
fi
echo "$raw" \
| sed -n '/^systems[[:space:]]*=/,/\]/p' \
| { grep -oE '"[^"]+"' || true; } \
| tr -d '"'
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻 for restructuring the inline script so that it's easier to read

  • Replace inline yq-based TOML parsing with scripts/discover-envs.sh (grep/sed)
  • yq cannot parse TOML files with comments, breaking the "Find environments" CI job

I don't think we should replace yq with grep/sed for manifest heuristics though because it will be even more brittle to changes, particularly false-negatives that we won't notice.

In the short term, if you rebase #1323 and #1324 against main to pick up the change from #1317 then the jobs should pass again. Or just a re-run might be sufficient since it looks like the updated version of yq landed in a runner image literally minutes ago: actions/runner-images@04114b0#diff-cc12e5c5d005932feaacf280af949d83e2cb6020dff8203d9ead2e00c30e8b7fL99-R99

Longer term, it would be good to wrap those dependencies in a Flox environment so that we have more control over when they change. We might also have to consider schema versions in the future now that the manifest shape may change more freely and be auto-upgraded between versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call — switched to parsing manifest.lock (JSON) with jq instead. No more TOML heuristics at all. The lock file has the full parsed manifest under .manifest, so services and systems are just straightforward jq queries. Pushed in 25627ce.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM. We also benefit from getting the composed manifest and avoiding any stale changes on disk 👍🏻

Per Dan's review: grep/sed on TOML is even more brittle than
yq. The lock file is JSON with the full parsed manifest, so
jq handles everything cleanly -- services, systems, comments
are all non-issues.

Addresses: floxenvs#1325 (review feedback)
@garbas garbas requested a review from dcarley February 26, 2026 13:46
Copy link
Contributor

@dcarley dcarley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eyeballed the script changes a second time; look right and appears to produce the same list of events. Failing test is tailscale related.

@garbas garbas added this pull request to the merge queue Feb 26, 2026
Merged via the queue into main with commit 6655b05 Feb 26, 2026
270 of 272 checks passed
@garbas garbas deleted the replace-yq-with-bash-discovery branch February 26, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-content Issues to be picked up by @flox/team-content

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants