Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
92 changes: 91 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,98 @@ jobs:
scripts/check_transport_imports.py

- name: Check for transport import violations (OMN-220)
id: transport-check
run: |
poetry run python scripts/check_transport_imports.py
set +e # Don't exit on first error, capture results

# Determine what checks to run
RUN_CHANGED_FILES="false"
RUN_FULL_SCAN="false"

if [[ "${{ github.event_name }}" == "pull_request" ]]; then
if [[ "${{ github.base_ref }}" == "main" || "${{ github.base_ref }}" == "develop" ]]; then
# PR to protected branch: full scan only (changed-files is redundant)
RUN_FULL_SCAN="true"
echo "=== Transport Import Check (Full Scan - PR to ${{ github.base_ref }}) ==="
else
# PR to non-protected branch: changed files only (fast feedback)
RUN_CHANGED_FILES="true"
echo "=== Transport Import Check (Changed Files - PR to ${{ github.base_ref }}) ==="
fi
elif [[ "${{ github.event_name }}" == "push" ]]; then
# Only full scan on pushes to protected branches
if [[ "${{ github.ref }}" == "refs/heads/main" || "${{ github.ref }}" == "refs/heads/develop" ]]; then
RUN_FULL_SCAN="true"
echo "=== Transport Import Check (Full Scan - Push to ${GITHUB_REF#refs/heads/}) ==="
else
# Push to non-protected branch: changed files only
RUN_CHANGED_FILES="true"
echo "=== Transport Import Check (Changed Files - Push to ${GITHUB_REF#refs/heads/}) ==="
fi
fi
Comment on lines +287 to +307

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Handle the workflow_dispatch event case.

The conditional logic only handles pull_request and push events, leaving both RUN_CHANGED_FILES and RUN_FULL_SCAN as "false" if triggered via workflow_dispatch. This causes the transport check to silently pass without running any validation, which defeats the safety mechanism.

Since the workflow is configured to accept workflow_dispatch triggers (line 8), this edge case must be handled.

Recommended fix: Default to full scan for unexpected event types (most defensive), or explicitly skip the step:

 if [[ "${{ github.event_name }}" == "pull_request" ]]; then
   if [[ "${{ github.base_ref }}" == "main" || "${{ github.base_ref }}" == "develop" ]]; then
     RUN_FULL_SCAN="true"
     echo "=== Transport Import Check (Full Scan - PR to ${{ github.base_ref }}) ==="
   else
     RUN_CHANGED_FILES="true"
     echo "=== Transport Import Check (Changed Files - PR to ${{ github.base_ref }}) ==="
   fi
 elif [[ "${{ github.event_name }}" == "push" ]]; then
   if [[ "${{ github.ref }}" == "refs/heads/main" || "${{ github.ref }}" == "refs/heads/develop" ]]; then
     RUN_FULL_SCAN="true"
     echo "=== Transport Import Check (Full Scan - Push to ${GITHUB_REF#refs/heads/}) ==="
   else
     RUN_CHANGED_FILES="true"
     echo "=== Transport Import Check (Changed Files - Push to ${GITHUB_REF#refs/heads/}) ==="
   fi
+else
+  # Default: full scan for workflow_dispatch or other event types (defensive default)
+  RUN_FULL_SCAN="true"
+  echo "=== Transport Import Check (Full Scan - Manual workflow dispatch) ==="
 fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
if [[ "${{ github.base_ref }}" == "main" || "${{ github.base_ref }}" == "develop" ]]; then
# PR to protected branch: full scan only (changed-files is redundant)
RUN_FULL_SCAN="true"
echo "=== Transport Import Check (Full Scan - PR to ${{ github.base_ref }}) ==="
else
# PR to non-protected branch: changed files only (fast feedback)
RUN_CHANGED_FILES="true"
echo "=== Transport Import Check (Changed Files - PR to ${{ github.base_ref }}) ==="
fi
elif [[ "${{ github.event_name }}" == "push" ]]; then
# Only full scan on pushes to protected branches
if [[ "${{ github.ref }}" == "refs/heads/main" || "${{ github.ref }}" == "refs/heads/develop" ]]; then
RUN_FULL_SCAN="true"
echo "=== Transport Import Check (Full Scan - Push to ${GITHUB_REF#refs/heads/}) ==="
else
# Push to non-protected branch: changed files only
RUN_CHANGED_FILES="true"
echo "=== Transport Import Check (Changed Files - Push to ${GITHUB_REF#refs/heads/}) ==="
fi
fi
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
if [[ "${{ github.base_ref }}" == "main" || "${{ github.base_ref }}" == "develop" ]]; then
# PR to protected branch: full scan only (changed-files is redundant)
RUN_FULL_SCAN="true"
echo "=== Transport Import Check (Full Scan - PR to ${{ github.base_ref }}) ==="
else
# PR to non-protected branch: changed files only (fast feedback)
RUN_CHANGED_FILES="true"
echo "=== Transport Import Check (Changed Files - PR to ${{ github.base_ref }}) ==="
fi
elif [[ "${{ github.event_name }}" == "push" ]]; then
# Only full scan on pushes to protected branches
if [[ "${{ github.ref }}" == "refs/heads/main" || "${{ github.ref }}" == "refs/heads/develop" ]]; then
RUN_FULL_SCAN="true"
echo "=== Transport Import Check (Full Scan - Push to ${GITHUB_REF#refs/heads/}) ==="
else
# Push to non-protected branch: changed files only
RUN_CHANGED_FILES="true"
echo "=== Transport Import Check (Changed Files - Push to ${GITHUB_REF#refs/heads/}) ==="
fi
else
# Default: full scan for workflow_dispatch or other event types (defensive default)
RUN_FULL_SCAN="true"
echo "=== Transport Import Check (Full Scan - Manual workflow dispatch) ==="
fi
🤖 Prompt for AI Agents
In .github/workflows/test.yml around lines 277 to 297 the logic only handles
pull_request and push events so a workflow_dispatch trigger leaves
RUN_CHANGED_FILES and RUN_FULL_SCAN false and the transport check is skipped;
update the conditional to handle workflow_dispatch (or a default fallback) by
setting RUN_FULL_SCAN="true" (or explicitly skipping) for unexpected event
types—either add an elif for "${{ github.event_name }}" == "workflow_dispatch"
that sets RUN_FULL_SCAN="true" and echoes the decision, or append a final else
block after the existing conditions that sets RUN_FULL_SCAN="true" and logs that
a full scan is being run for unknown event types.


CHANGED_FILES_EXIT=0
FULL_SCAN_EXIT=0

if [[ "$RUN_CHANGED_FILES" == "true" ]]; then
poetry run python scripts/check_transport_imports.py --changed-files --verbose
CHANGED_FILES_EXIT=$?
fi

if [[ "$RUN_FULL_SCAN" == "true" ]]; then
poetry run python scripts/check_transport_imports.py --verbose
FULL_SCAN_EXIT=$?
fi

# Output for summary step
echo "changed_files_exit=$CHANGED_FILES_EXIT" >> $GITHUB_OUTPUT
echo "full_scan_exit=$FULL_SCAN_EXIT" >> $GITHUB_OUTPUT
echo "run_changed_files=$RUN_CHANGED_FILES" >> $GITHUB_OUTPUT
echo "run_full_scan=$RUN_FULL_SCAN" >> $GITHUB_OUTPUT

# Restore strict mode
set -e

# Fail if any check found violations
if [[ $CHANGED_FILES_EXIT -ne 0 ]] || [[ $FULL_SCAN_EXIT -ne 0 ]]; then
echo ""
echo "Transport import violations detected!"
exit 1
fi

echo ""
echo "All transport import checks passed."

- name: Transport check summary
if: always()
run: |
echo "## Transport Import Validation (OMN-220)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

RUN_CHANGED="${{ steps.transport-check.outputs.run_changed_files }}"
RUN_FULL="${{ steps.transport-check.outputs.run_full_scan }}"
CHANGED_EXIT="${{ steps.transport-check.outputs.changed_files_exit }}"
FULL_EXIT="${{ steps.transport-check.outputs.full_scan_exit }}"

if [[ "$RUN_CHANGED" == "true" ]]; then
if [[ "$CHANGED_EXIT" == "0" ]]; then
echo "- Changed files check: Passed" >> $GITHUB_STEP_SUMMARY
else
echo "- Changed files check: **Failed** (exit code: $CHANGED_EXIT)" >> $GITHUB_STEP_SUMMARY
fi
else
echo "- Changed files check: Skipped (targeting protected branch)" >> $GITHUB_STEP_SUMMARY
fi

if [[ "$RUN_FULL" == "true" ]]; then
if [[ "$FULL_EXIT" == "0" ]]; then
echo "- Full scan: Passed" >> $GITHUB_STEP_SUMMARY
else
echo "- Full scan: **Failed** (exit code: $FULL_EXIT)" >> $GITHUB_STEP_SUMMARY
fi
else
echo "- Full scan: Skipped (not targeting protected branch)" >> $GITHUB_STEP_SUMMARY
fi

docs-validation:
name: Documentation Validation
Expand Down
Loading