Repository navigation
Conversation
Parse bash-compatible GitHub Actions workflow and composite action run: steps in memory with tree-sitter-bash via extract_bash_source() and attach script-invocation/source edges directly to the workflow/action file node with exact YAML line provenance.
Key details and invariants:
- Resolves workflow run: scripts relative to the repository root (respecting defaults.run.working-directory and step working-directory) and pre-seeds GITHUB_WORKSPACE safely inside the scan/repo root ceiling.
- Recognizes extensionless shebang-backed bash scripts (e.g. ./scripts/lint) in bash script invocations alongside .sh/.bash scripts, and skips shell runner flags (-euo pipefail) while failing closed on -c or unknown flags.
- Neutralizes GitHub Actions ${{ ... }} expressions into a non-resolvable placeholder while preserving line numbers so expressions never split adjacent tokens across ERROR nodes or fall back to guessed paths.
- Fails closed on non-bash shells (pwsh, cmd, python, Windows runners with unset shell), out-of-tree/UNC paths, missing targets, and missing tree-sitter-bash.
- Bumps _AST_CACHE_SCHEMA 58 -> 59 so cached YAML/workflow and bash extractions refresh.
Fixes Graphify-Labs#5565
Co-Authored-By: Gemini <[email protected]>
|
Thanks for the pull request, @m3lonxd. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify review 
4 possible issues to check · High impact
GitHub Actions workflow and composite-action run: steps are parsed as Bash when their shell settings qualify.
4 possible issues we couldn't confirm
- Any result carrying a truthy
bash_sourcesvalue is treated as a shell script, even when its nodes are not bash ·graphify/extract.py:13743 - The traversal case in the fail-closed test never reaches the file it claims to test ·
tests/test_yaml_extraction.py:465 - The degraded-mode check passes for any node label and does not verify that workflow parsing still produced anything useful ·
tests/test_yaml_extraction.py:508 - +1 more in Graphify
They don't change the score.
What this review covered
- A changed file's diff was too long to show in full, so the review may not have seen every changed line in it.
- Part of a file with a line too long to show was not read.
- Some lookups asked for files or lines that do not exist; the review was told and carried on.
- 5 of 5 changed files inspected. This is scope, not a correctness guarantee.
Code graph · 5860 functions depend on this change
- 8 functions became more coupled. Largest:
extract()(1421 callers),build_from_json()(354 callers),detect()(158 callers). - 416 of 652 test files are affected by this change.
- Gate, test list and every flagged function: in the Graphify check.
Reviewed e1ae041
|
Thanks @m3lonxd — this GitHub-Actions-run-as-bash feature is well-built and overreach-verified (windows jobs / non-GHA YAML produce no edges). Holding it here because v0.9.123 just landed eight bash-extractor PRs (#5568/#5569/#5570/#5576/#5577/#5578/#5589/#5597) that heavily rewrote |
What does this PR do?
Closes #5565
GitHub Actions workflow
run:steps under.github/workflows/(and compositeaction.yml/action.yamlsteps) frequently invoke repository scripts (e.g.bash scripts/check.sh,./scripts/lint) that are never called anywhere else, leaving workflows disconnected and scripts appearing unused.This PR:
extract_bash_source()ingraphify/extractors/bash.pysoextract_yaml()can parse qualifyingrun:step bodies purely in memory withtree-sitter-bashand attach discovered script-invocation (calls/invokes) andsource(imports_from) edges directly to the workflow/action file node with accurate YAML line provenance../scripts/lintwith#!/usr/bin/env bash) and safe runner flags (e.g.bash -euo pipefail scripts/check.sh, while stopping on-c/ unknown flags).defaults.run.working-directoryand stepworking-directory, plus$GITHUB_WORKSPACE).${{ ... }}expressions into a non-resolvable placeholder while preserving line count so expressions never split adjacent tokens acrossERRORnodes or trigger guessed fallback paths._looks_like_bash()ingraphify/extract.pysosourcecalls inside workflow steps also participate inresolve_bash_source_edges._AST_CACHE_SCHEMAfrom58to59so cached YAML/workflow and bash extractions refresh.Type of change
Verification & Invariants
Deterministic & in-memory: No temp files, shell execution, or string interpolation into shell/Python; tested with monkeypatched
NamedTemporaryFile,mkstemp,subprocess.run,subprocess.Popen, andos.system.Fail-closed & security-bounded: Rejects non-bash shells (
pwsh,powershell,cmd,python, Windows runners without explicit bashshell, and composite steps withoutshell),${{ ... }}in script/working-directory paths, missing/non-script targets, and out-of-tree/UNC paths (via_resolve_safe/_safe_to_probebefore any stat). Missingtree-sitter-bashdegrades gracefully without failing YAML extraction.Limitations / unsupported cases: Non-bash workflow shells, dynamic runtime expressions (
${{ ... }}) inside script paths, reusable workflowuses:edges, and Windows-default PowerShell steps withoutshell: bashare intentionally left unlinked.Read the CONTRIBUTING.md guide.
Reproduced the issue and identified the invariant.
Made the smallest fix necessary.
Added a regression test (if bug fix) or isolated boundary test.
Kept the PR description synchronized with the final implementation.
Documented any limitations / unsupported cases explicitly.
How was this tested?
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (N/A — no skill fragments modified)