Skip to content

initialize CI - #4

Open
MatthiasBSchaefer wants to merge 2 commits into
masterfrom
externalCICheck
Open

initialize CI#4
MatthiasBSchaefer wants to merge 2 commits into
masterfrom
externalCICheck

Conversation

@MatthiasBSchaefer

@MatthiasBSchaefer MatthiasBSchaefer commented Jun 29, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features
    • Added an externally triggered CI workflow that runs automated checks from repository dispatch events.
    • Executes two containerized validation paths and generates comparison/report artifacts using the dispatched commit SHAs.
    • Automatically posts a pull request review decision derived from whether both validations succeed, including links to the generated reports.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

A new GitHub Actions workflow responds to repository_dispatch events, runs Dymola and OpenModelica jobs in containers, generates overview reports, and posts an APPROVE or REQUEST_CHANGES review to a pull request in an external repository.

Changes

External CI Workflow

Layer / File(s) Summary
Workflow trigger and environment setup
.github/workflows/external_triggered_CI.yml
Registers repository_dispatch for CI_trigger_type and maps payload fields into workflow-level environment variables.
Dymola and OpenModelica execution jobs
.github/workflows/external_triggered_CI.yml
Defines run_dymola and run_openmodelica container jobs; each checks out the dispatched repo and runs shared prepare/run scripts with tool-specific identifiers.
Overview aggregation and PR review posting
.github/workflows/external_triggered_CI.yml
overview always runs to create and publish reports; review always runs after the jobs, derives the review decision from tool results, and posts the PR review through the GitHub REST API.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 Hop, hop—new CI lights the way,
Dymola and OpenModelica work all day.
Reports bloom bright, then review takes flight,
APPROVE or CHANGES—posted just right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is relevant, but it is too vague to clearly describe the new external-triggered CI workflow. Use a more specific title such as 'Add external-triggered CI workflow' or 'Initialize repository_dispatch CI automation'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch externalCICheck

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/external_triggered_CI.yml:
- Line 20: The CI workflow is using a mutable container tag, so update the image
references in the workflow to use immutable digests instead of latest. Replace
the ghcr.io/matthiasbschaefer/dymola_image:latest reference (and the other image
entries noted in the comment) with pinned digest-based values in the relevant
job definitions so the workflow always runs against the reviewed image versions.
- Around line 34-37: The shell invocations in the workflow are directly
interpolating client_payload-derived values, which can allow injected shell
syntax. Update the affected job steps around prepare_tool.sh and run_tool.sh to
pass EVENT_NUMBER, BASE_SHA, PR_SHA, and similar values via env, then reference
them inside the command with proper quoting rather than expanding template
expressions inline. Apply the same fix to the other matching steps mentioned in
this workflow so all script calls use the same safe pattern.
- Around line 1-15: The workflow triggered by repository_dispatch currently
inherits the repository default GITHUB_TOKEN scope, so add a workflow-level
permissions block to constrain it. Set the permissions needed for the jobs that
only checkout or read repository content, and disable unnecessary access
everywhere else since the external review posting already uses MODELICA_TOKEN.
Keep the change in the external_triggered_CI workflow so the permission model is
explicit at the top level and applies to all jobs.
- Around line 95-100: The approval gate currently only checks run_openmodelica
and run_dymola, so a failed overview step can still emit APPROVE even when
linked reports are missing. Update the gating logic in the workflow step that
sets GITHUB_OUTPUT to include the overview job result alongside the existing
tool jobs, and only set event=APPROVE when all required jobs succeed; otherwise
keep REQUEST_CHANGES. Use the existing needs.run_openmodelica, needs.run_dymola,
and overview job/result references in this workflow block to locate the fix.
- Around line 104-105: The external-triggered CI workflow is hardcoding the
wrong target repository in the review dispatch, so the review can be sent to the
wrong PR. Update the TARGET_REPO value in external_triggered_CI.yml to use the
dispatched PR repository instead of the fixed
matthiasbschaefer/ModelicaStandardLibrary value, keeping TARGET_PR tied to
github.event.client_payload.number. Use the workflow’s dispatch context or
payload fields to locate the correct repository dynamically in the
review-posting step.
- Around line 109-115: The review creation step in the workflow silently
succeeds on GitHub API 4xx/5xx responses because the current curl invocation
does not fail the job; update the review-posting command to surface API failures
and stop the job when the request is rejected. Adjust the curl usage in the
workflow step that builds the GitHub reviews API call so it returns a nonzero
exit status on HTTP errors and emits the error response for debugging, ensuring
failures from missing tokens, invalid repo/PR values, or validation issues are
not ignored.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a3ea1b6-6610-4183-937b-0920455e0ad4

📥 Commits

Reviewing files that changed from the base of the PR and between 75d7ae6 and 419f6f4.

📒 Files selected for processing (1)
  • .github/workflows/external_triggered_CI.yml

Comment thread .github/workflows/external_triggered_CI.yml
runs-on: ubuntu-latest

container:
image: ghcr.io/matthiasbschaefer/dymola_image:latest

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Pin CI containers by digest instead of latest.

These images contain the CI tools/scripts that decide and publish PR results. A mutable tag can change outcomes without a reviewed workflow change.

📌 Proposed pinning pattern
-      image: ghcr.io/matthiasbschaefer/dymola_image:latest
+      image: ghcr.io/matthiasbschaefer/dymola_image@sha256:<vetted-digest>
@@
-      image: ghcr.io/matthiasbschaefer/om_image:latest
+      image: ghcr.io/matthiasbschaefer/om_image@sha256:<vetted-digest>
@@
-      image: ghcr.io/matthiasbschaefer/om_image:latest
+      image: ghcr.io/matthiasbschaefer/om_image@sha256:<vetted-digest>

Also applies to: 45-45, 71-71

🧰 Tools
🪛 zizmor (1.26.1)

[error] 20-20: unpinned image references (unpinned-images): container image is pinned to latest

(unpinned-images)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/external_triggered_CI.yml at line 20, The CI workflow is
using a mutable container tag, so update the image references in the workflow to
use immutable digests instead of latest. Replace the
ghcr.io/matthiasbschaefer/dymola_image:latest reference (and the other image
entries noted in the comment) with pinned digest-based values in the relevant
job definitions so the workflow always runs against the reviewed image versions.

Source: Linters/SAST tools

Comment thread .github/workflows/external_triggered_CI.yml Outdated
Comment thread .github/workflows/external_triggered_CI.yml
Comment thread .github/workflows/external_triggered_CI.yml Outdated
Comment thread .github/workflows/external_triggered_CI.yml Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/external_triggered_CI.yml:
- Around line 107-115: The review dispatch flow in the workflow step that builds
the GitHub API request should validate TARGET_REPO and TARGET_PR before
MODELICA_TOKEN is used. Add an allowlist or strict pattern check in the same run
block (before constructing API and payload) so only the expected repository and
a valid PR number are accepted, and fail fast if the repository_dispatch payload
is unexpected. Refer to the TARGET_REPO, TARGET_PR, and API/payload setup in the
external_triggered_CI job when applying the guard.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 29bf9fe4-bffb-4b9a-93c4-fb5845147111

📥 Commits

Reviewing files that changed from the base of the PR and between 419f6f4 and 3e48417.

📒 Files selected for processing (1)
  • .github/workflows/external_triggered_CI.yml

Comment on lines +107 to +115
TARGET_REPO: ${{ env.REPO_NAME }}
TARGET_PR: ${{ env.EVENT_NUMBER }}
EVENT: ${{ steps.decide.outputs.event }}
BODY: "Please look here for details:${{ env.PR_SERVER }}/${{ env.EVENT_NUMBER }}/Modelica/PR_comparison_report.html and ${{ env.PR_SERVER }}/${{ env.EVENT_NUMBER }}/ModelicaTest/PR_comparison_report.html"

run: |
set -euo pipefail
API="https://api.github.com/repos/${TARGET_REPO}/pulls/${TARGET_PR}/reviews"
payload="$(jq -n --arg event "$EVENT" --arg body "$BODY" '{event: $event, body: $body}')"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Validate the dispatched review target before using MODELICA_TOKEN.

TARGET_REPO and TARGET_PR come from repository_dispatch payload and are used with a privileged secret. Add an allowlist/pattern check before building the API URL so this workflow cannot be used to post reviews to an unintended repository/PR if dispatch access or token scope is broader than expected.

🔒 Proposed validation guard
         run: |
            set -euo pipefail
+           case "$TARGET_REPO" in
+             ltx-simulation/ModelicaStandardLibrary) ;;
+             *) echo "Unexpected TARGET_REPO: $TARGET_REPO" >&2; exit 1 ;;
+           esac
+           [[ "$TARGET_PR" =~ ^[0-9]+$ ]] || { echo "Invalid TARGET_PR: $TARGET_PR" >&2; exit 1; }
            API="https://api.github.com/repos/${TARGET_REPO}/pulls/${TARGET_PR}/reviews"
            payload="$(jq -n --arg event "$EVENT" --arg body "$BODY" '{event: $event, body: $body}')"
📝 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
TARGET_REPO: ${{ env.REPO_NAME }}
TARGET_PR: ${{ env.EVENT_NUMBER }}
EVENT: ${{ steps.decide.outputs.event }}
BODY: "Please look here for details:${{ env.PR_SERVER }}/${{ env.EVENT_NUMBER }}/Modelica/PR_comparison_report.html and ${{ env.PR_SERVER }}/${{ env.EVENT_NUMBER }}/ModelicaTest/PR_comparison_report.html"
run: |
set -euo pipefail
API="https://api.github.com/repos/${TARGET_REPO}/pulls/${TARGET_PR}/reviews"
payload="$(jq -n --arg event "$EVENT" --arg body "$BODY" '{event: $event, body: $body}')"
TARGET_REPO: ${{ env.REPO_NAME }}
TARGET_PR: ${{ env.EVENT_NUMBER }}
EVENT: ${{ steps.decide.outputs.event }}
BODY: "Please look here for details:${{ env.PR_SERVER }}/${{ env.EVENT_NUMBER }}/Modelica/PR_comparison_report.html and ${{ env.PR_SERVER }}/${{ env.EVENT_NUMBER }}/ModelicaTest/PR_comparison_report.html"
run: |
set -euo pipefail
case "$TARGET_REPO" in
ltx-simulation/ModelicaStandardLibrary) ;;
*) echo "Unexpected TARGET_REPO: $TARGET_REPO" >&2; exit 1 ;;
esac
[[ "$TARGET_PR" =~ ^[0-9]+$ ]] || { echo "Invalid TARGET_PR: $TARGET_PR" >&2; exit 1; }
API="https://api.github.com/repos/${TARGET_REPO}/pulls/${TARGET_PR}/reviews"
payload="$(jq -n --arg event "$EVENT" --arg body "$BODY" '{event: $event, body: $body}')"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/external_triggered_CI.yml around lines 107 - 115, The
review dispatch flow in the workflow step that builds the GitHub API request
should validate TARGET_REPO and TARGET_PR before MODELICA_TOKEN is used. Add an
allowlist or strict pattern check in the same run block (before constructing API
and payload) so only the expected repository and a valid PR number are accepted,
and fail fast if the repository_dispatch payload is unexpected. Refer to the
TARGET_REPO, TARGET_PR, and API/payload setup in the external_triggered_CI job
when applying the guard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant