Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/scripts/parse-affected-targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,12 @@ def generate_matrix_json(targets: List[str]) -> str:

def main():
if len(sys.argv) < 3:
print(f"Usage: {sys.argv[0]} <btd_output.json> <output_dir>", file=sys.stderr)
print(f"Usage: {sys.argv[0]} <btd_output.json> <output_dir> [--fallback]", file=sys.stderr)
sys.exit(1)

btd_json = sys.argv[1]
output_dir = Path(sys.argv[2])
fallback = '--fallback' in sys.argv
output_dir.mkdir(parents=True, exist_ok=True)

# Get all targets from BXL/cquery
Expand All @@ -211,10 +212,15 @@ def main():
print("Parsing BTD output...", file=sys.stderr)
affected_targets = parse_btd_output(btd_json)

# If BTD returned no targets (fallback case), run everything
if len(affected_targets) == 0:
print("No affected targets from BTD (fallback mode) - running all targets", file=sys.stderr)
# Only fall back to running everything when BTD itself failed
# (indicated by --fallback); zero targets from a successful BTD
# run means nothing was affected.
if fallback:
print("BTD failed (--fallback) - running all targets", file=sys.stderr)
affected_by_category = all_targets
affected_targets = set()
for targets in all_targets.values():
affected_targets.update(targets)
else:
# Filter to affected only
affected_by_category = filter_affected(all_targets, affected_targets)
Expand Down
26 changes: 19 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ jobs:
- name: Get changed files and base commit
id: changed-files
run: |
# Always compare against origin/main to detect all changes in the branch
BASE_COMMIT="origin/main"
# On main (post-merge), compare against the previous commit;
# on branches, compare against origin/main to detect all changes.
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
BASE_COMMIT="HEAD~1"
else
BASE_COMMIT="origin/main"
fi

# Generate list of changed files in BTD format: "M path/to/file"
# BTD expects Mercurial-like format with status code (M/A/D) and space separator
Expand Down Expand Up @@ -95,6 +100,7 @@ jobs:
echo "Found $TARGETS affected targets"
echo "BTD output preview:"
head -20 /tmp/btd_output.json || true
echo "succeeded=true" >> "$GITHUB_OUTPUT"
else
EXIT_CODE=$?
echo "::error::BTD command failed with exit code $EXIT_CODE"
Expand All @@ -103,24 +109,30 @@ jobs:
echo "BTD stderr:"
cat /tmp/btd_stderr.txt || echo "No stderr file generated"
echo "::warning::BTD failed, will run all targets"
echo '{"targets": []}' > /tmp/btd_output.json
echo '[]' > /tmp/btd_output.json
echo "succeeded=false" >> "$GITHUB_OUTPUT"
fi
else
echo "::warning::supertd not installed, will run all targets"
echo "PATH: $PATH"
# Fallback: empty targets means run everything
echo '{"targets": []}' > /tmp/btd_output.json
echo '[]' > /tmp/btd_output.json
echo "succeeded=false" >> "$GITHUB_OUTPUT"
fi

- name: Parse affected targets
id: parse
run: |
mkdir -p /tmp/btd_results

# Run parser script
# Run parser script; --fallback means BTD failed so run everything
FALLBACK_FLAG=""
if [ "${{ steps.btd.outputs.succeeded }}" != "true" ]; then
FALLBACK_FLAG="--fallback"
fi

python3 .github/scripts/parse-affected-targets.py \
/tmp/btd_output.json \
/tmp/btd_results || {
/tmp/btd_results $FALLBACK_FLAG || {
echo "::warning::Parser failed, creating empty matrices"
# Create empty matrices on failure
for matrix in vunit_matrix bsv_test_matrix ice40_matrix ecp5_matrix vivado_matrix; do
Expand Down
26 changes: 19 additions & 7 deletions .github/workflows/simulation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ jobs:
- name: Get changed files and base commit
id: changed-files
run: |
# Always compare against origin/main to detect all changes in the branch
BASE_COMMIT="origin/main"
# On main (post-merge), compare against the previous commit;
# on branches, compare against origin/main to detect all changes.
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
BASE_COMMIT="HEAD~1"
else
BASE_COMMIT="origin/main"
fi

# Generate list of changed files in BTD format: "M path/to/file"
# BTD expects Mercurial-like format with status code (M/A/D) and space separator
Expand Down Expand Up @@ -92,6 +97,7 @@ jobs:
echo "Found $TARGETS affected targets"
echo "BTD output preview:"
head -20 /tmp/btd_output.json || true
echo "succeeded=true" >> "$GITHUB_OUTPUT"
else
EXIT_CODE=$?
echo "::error::BTD command failed with exit code $EXIT_CODE"
Expand All @@ -100,24 +106,30 @@ jobs:
echo "BTD stderr:"
cat /tmp/btd_stderr.txt || echo "No stderr file generated"
echo "::warning::BTD failed, will run all targets"
echo '{"targets": []}' > /tmp/btd_output.json
echo '[]' > /tmp/btd_output.json
echo "succeeded=false" >> "$GITHUB_OUTPUT"
fi
else
echo "::warning::supertd not installed, will run all targets"
echo "PATH: $PATH"
# Fallback: empty targets means run everything
echo '{"targets": []}' > /tmp/btd_output.json
echo '[]' > /tmp/btd_output.json
echo "succeeded=false" >> "$GITHUB_OUTPUT"
fi

- name: Parse affected targets
id: parse
run: |
mkdir -p /tmp/btd_results

# Run parser script
# Run parser script; --fallback means BTD failed so run everything
FALLBACK_FLAG=""
if [ "${{ steps.btd.outputs.succeeded }}" != "true" ]; then
FALLBACK_FLAG="--fallback"
fi

python3 .github/scripts/parse-affected-targets.py \
/tmp/btd_output.json \
/tmp/btd_results || {
/tmp/btd_results $FALLBACK_FLAG || {
echo "::warning::Parser failed, creating empty matrices"
# Create empty matrices on failure
for matrix in vunit_matrix bsv_test_matrix ice40_matrix ecp5_matrix vivado_matrix; do
Expand Down