Skip to content

Comments

ci: add workflow to trigger specific builds on PRs by comments#152

Merged
patrick-stephens merged 1 commit intomainfrom
add_per_build_workflow
Dec 11, 2025
Merged

ci: add workflow to trigger specific builds on PRs by comments#152
patrick-stephens merged 1 commit intomainfrom
add_per_build_workflow

Conversation

@patrick-stephens
Copy link
Contributor

@patrick-stephens patrick-stephens commented Dec 11, 2025

Workflow that lets us add a comment to a PR to build a specific target rather than having to label to build all. Means we can say to just build a specific Linux target rather than all of them for example.

These will not be status checks so we separately add a response comment with the results. It does mean you can trigger a single build after review or other builds are complete as well.


Summary by cubic

Add a PR comment-triggered CI workflow to run specific platform builds by writing “/build” on a PR. Builds don’t create status checks; the workflow replies with a results comment and job links.

  • New Features
    • Parse “/build” comments to select windows, macos, and optional linux targets.
    • Use the PR’s merge ref and set the version from Dockerfile.ubi.
    • Invoke platform build workflows; Linux uses a target matrix.
    • Reply on the PR with status emojis and job log links.

Written for commit 4e7cfa5. Summary will update automatically on new commits.

Signed-off-by: Patrick Stephens <pat@fluent.do>
@patrick-stephens patrick-stephens marked this pull request as ready for review December 11, 2025 13:59
@patrick-stephens patrick-stephens requested a review from a team December 11, 2025 13:59
@patrick-stephens patrick-stephens merged commit 2a2734c into main Dec 11, 2025
53 of 59 checks passed
@patrick-stephens patrick-stephens deleted the add_per_build_workflow branch December 11, 2025 14:07
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

5 issues found across 1 file

Prompt for AI agents (all 5 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name=".github/workflows/pr-comment-build.yaml">

<violation number="1" location=".github/workflows/pr-comment-build.yaml:101">
P1: Missing `always()` in condition. This job depends on conditional build jobs that will be skipped when not requested. Without `always()`, this job won&#39;t run when dependencies are skipped, so the results comment will never be posted.</violation>

<violation number="2" location=".github/workflows/pr-comment-build.yaml:117">
P1: Rule violated: **Require Safe Shell Scripts (set -euo pipefail or explicit env checks)**

Shell script lacks `set -euo pipefail` and contains unguarded variable usage. If `grep` fails to find the pattern, `VERSION` will be empty and the script continues silently, propagating an empty version to downstream builds. Add strict shell options or use guarded parameter expansion.</violation>

<violation number="3" location=".github/workflows/pr-comment-build.yaml:149">
P1: Inconsistent condition for Linux build check. The output is set to `&#39;true&#39;` or `&#39;false&#39;` (strings), but this condition checks `!= &#39;&#39;`. Since `&#39;false&#39; != &#39;&#39;` evaluates to true, Linux builds will be triggered even when not requested. Use `== &#39;true&#39;` for consistency with Windows and macOS checks.</violation>

<violation number="4" location=".github/workflows/pr-comment-build.yaml:187">
P2: Incorrect iteration over paginated results. `github.paginate()` returns a flattened array of jobs directly, not response objects with `jobs` arrays. The inner loop `for (const j of job.jobs || [])` will never execute since `job.jobs` will be undefined.</violation>

<violation number="5" location=".github/workflows/pr-comment-build.yaml:249">
P1: `ISSUE_NUMBER` is used but not defined in the `env` block. This will be `undefined`, causing the comment body to show &#39;undefined&#39; and `Number(undefined)` to return `NaN`, breaking the API call.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

});
const byName = {};
for (const job of pages) {
for (const j of job.jobs || []) {
Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 11, 2025

Choose a reason for hiding this comment

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

P2: Incorrect iteration over paginated results. github.paginate() returns a flattened array of jobs directly, not response objects with jobs arrays. The inner loop for (const j of job.jobs || []) will never execute since job.jobs will be undefined.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/pr-comment-build.yaml, line 187:

<comment>Incorrect iteration over paginated results. `github.paginate()` returns a flattened array of jobs directly, not response objects with `jobs` arrays. The inner loop `for (const j of job.jobs || [])` will never execute since `job.jobs` will be undefined.</comment>

<file context>
@@ -0,0 +1,251 @@
+                    });
+                    const byName = {};
+                    for (const job of pages) {
+                        for (const j of job.jobs || []) {
+                            // Keep the first occurrence
+                            if (!byName[j.name]) {
</file context>
Fix with Cubic

needs:
- pr-build-comment
- pr-build-get-metadata
if: needs.pr-build-comment.outputs.should-run == 'true' && needs.pr-build-comment.outputs.build-linux != ''
Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 11, 2025

Choose a reason for hiding this comment

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

P1: Inconsistent condition for Linux build check. The output is set to 'true' or 'false' (strings), but this condition checks != ''. Since 'false' != '' evaluates to true, Linux builds will be triggered even when not requested. Use == 'true' for consistency with Windows and macOS checks.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/pr-comment-build.yaml, line 149:

<comment>Inconsistent condition for Linux build check. The output is set to `&#39;true&#39;` or `&#39;false&#39;` (strings), but this condition checks `!= &#39;&#39;`. Since `&#39;false&#39; != &#39;&#39;` evaluates to true, Linux builds will be triggered even when not requested. Use `== &#39;true&#39;` for consistency with Windows and macOS checks.</comment>

<file context>
@@ -0,0 +1,251 @@
+        needs:
+            - pr-build-comment
+            - pr-build-get-metadata
+        if: needs.pr-build-comment.outputs.should-run == &#39;true&#39; &amp;&amp; needs.pr-build-comment.outputs.build-linux != &#39;&#39;
+        uses: ./.github/workflows/call-build-linux-packages.yaml
+        with:
</file context>
Fix with Cubic

await github.rest.issues.createComment({
owner,
repo,
issue_number: Number(process.env.ISSUE_NUMBER),
Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 11, 2025

Choose a reason for hiding this comment

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

P1: ISSUE_NUMBER is used but not defined in the env block. This will be undefined, causing the comment body to show 'undefined' and Number(undefined) to return NaN, breaking the API call.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/pr-comment-build.yaml, line 249:

<comment>`ISSUE_NUMBER` is used but not defined in the `env` block. This will be `undefined`, causing the comment body to show &#39;undefined&#39; and `Number(undefined)` to return `NaN`, breaking the API call.</comment>

<file context>
@@ -0,0 +1,251 @@
+                    await github.rest.issues.createComment({
+                        owner,
+                        repo,
+                        issue_number: Number(process.env.ISSUE_NUMBER),
+                        body
+                    });
</file context>
Fix with Cubic

pr-build-get-metadata:
name: Get build metadata
needs: pr-build-comment
if: needs.pr-build-comment.outputs.should-run == 'true'
Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 11, 2025

Choose a reason for hiding this comment

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

P1: Missing always() in condition. This job depends on conditional build jobs that will be skipped when not requested. Without always(), this job won't run when dependencies are skipped, so the results comment will never be posted.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/pr-comment-build.yaml, line 101:

<comment>Missing `always()` in condition. This job depends on conditional build jobs that will be skipped when not requested. Without `always()`, this job won&#39;t run when dependencies are skipped, so the results comment will never be posted.</comment>

<file context>
@@ -0,0 +1,251 @@
+    pr-build-get-metadata:
+        name: Get build metadata
+        needs: pr-build-comment
+        if: needs.pr-build-comment.outputs.should-run == &#39;true&#39;
+        runs-on: ubuntu-latest
+        permissions:
</file context>
Fix with Cubic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cubic-dev-ai this should only run if we decide to run the builds, the condition it has should detect that?

Copy link

Choose a reason for hiding this comment

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

@patrick-stephens You're right that the if: needs.pr-build-comment.outputs.should-run == 'true' condition correctly gates whether builds should trigger overall—that part works fine to detect if a valid /build command was parsed.

The issue I flagged is separate: even when builds are triggered (or partially skipped), the response job (which posts the results comment) depends on the build jobs via needs. When a build job like pr-build-windows isn't requested, it gets skipped entirely. GitHub Actions then skips the response job too, because skipped dependencies block the whole chain. That's why you need always() added to the response job's if condition, like this:

pr-build-comment-response:
    name: Respond to PR comment
    if: always() && needs.pr-build-comment.outputs.should-run == 'true'
    # ... rest unchanged

This ensures the response always runs to report what happened (success, skip, etc.), regardless of which builds fired. Without it, you'd never get that summary comment back on the PR.

# Look for the default line in the Dockerfile
id: set-version
run: |
VERSION=$(grep "ARG FLUENTDO_AGENT_VERSION=" Dockerfile.ubi | cut -d '=' -s -f 2 -)
Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 11, 2025

Choose a reason for hiding this comment

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

P1: Rule violated: Require Safe Shell Scripts (set -euo pipefail or explicit env checks)

Shell script lacks set -euo pipefail and contains unguarded variable usage. If grep fails to find the pattern, VERSION will be empty and the script continues silently, propagating an empty version to downstream builds. Add strict shell options or use guarded parameter expansion.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/pr-comment-build.yaml, line 117:

<comment>Shell script lacks `set -euo pipefail` and contains unguarded variable usage. If `grep` fails to find the pattern, `VERSION` will be empty and the script continues silently, propagating an empty version to downstream builds. Add strict shell options or use guarded parameter expansion.</comment>

<file context>
@@ -0,0 +1,251 @@
+              # Look for the default line in the Dockerfile
+              id: set-version
+              run: |
+                  VERSION=$(grep &quot;ARG FLUENTDO_AGENT_VERSION=&quot; Dockerfile.ubi | cut -d &#39;=&#39; -s -f 2 -)
+                  echo &quot;Using version: $VERSION&quot;
+                  echo &quot;version=$VERSION&quot; &gt;&gt; $GITHUB_OUTPUT
</file context>
Fix with Cubic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cubic-dev-ai is this just meaning for pipefail? Github Actions should automatically handle set -eu

Copy link

Choose a reason for hiding this comment

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

@patrick-stephens No, it's not just about pipefail—the full set -euo pipefail combo is important for different reasons, and GitHub Actions doesn't fully handle this automatically.

GitHub does set set -e by default in shell steps (exits on command failure), but it skips -u (treat unset vars as errors) and -o pipefail (fail if any part of a pipeline fails, like your grep | cut chain). Without -u, if $GITHUB_OUTPUT were somehow unset (unlikely but possible), it'd silently fail. More critically, without -o pipefail, if grep finds nothing but cut runs anyway, the pipeline succeeds and VERSION stays empty—your script keeps going, echoing an empty version and passing it downstream, which could trigger broken builds.

Adding set -euo pipefail at the top of that step ensures the whole thing fails fast if the grep/cut doesn't produce a valid version. You could also guard it like this:

- name: Get the versions to use
  id: set-version
  run: |
    set -euo pipefail
    VERSION=$(grep "ARG FLUENTDO_AGENT_VERSION=" Dockerfile.ubi | cut -d '=' -s -f 2 -)
    if [[ -z "$VERSION" ]]; then
      echo "Error: Version not found in Dockerfile.ubi"
      exit 1
    fi
    echo "Using version: $VERSION"
    echo "version=$VERSION" >> "$GITHUB_OUTPUT"
  shell: bash

That way, if the file's missing or the ARG isn't there, the job fails early with a clear message instead of propagating junk.

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