Skip to content

refactor(ci): auto-run workflow for fork PRs#4287

Open
aicam wants to merge 18 commits intoapache:mainfrom
aicam:matthew
Open

refactor(ci): auto-run workflow for fork PRs#4287
aicam wants to merge 18 commits intoapache:mainfrom
aicam:matthew

Conversation

@aicam
Copy link
Contributor

@aicam aicam commented Mar 12, 2026

This PR is the fork of #4278

What changes were proposed in this PR?

The build workflow now enforces a stricter permission model for fork PRs that modify the workflow file. A check-permissions job is added as a required predecessor to all build jobs (frontend, scala, python). If a PR modifies .github/workflows/github-action-build.yml and the author is not a committer (i.e., does not have write, maintain, or admin permissions), the workflow fails with an error requiring a committer to review and manually re-run it. PRs that do not modify the workflow file continue to run automatically as before.

Any related issues, documentation, discussions?

Closes: #4279

How was this PR tested?

Verified that the check-permissions job correctly detects workflow file changes and checks the actor's repository permissions. Confirmed that PRs modifying the workflow are blocked for non-committers, and that all other PRs are unaffected.

Was this PR authored or co-authored using generative AI tooling?

Resolved comments with Claude Sonnet 4.6

@github-actions github-actions bot added ci changes related to CI build labels Mar 12, 2026
@aicam aicam changed the title Matthew refactor(ci): Matthew Mar 12, 2026
@aicam aicam changed the title refactor(ci): Matthew refactor(ci): auto-run workflow for fork PRs (fork) Mar 12, 2026
@Ma77Ball
Copy link
Contributor

Prior discussion of review process found at pr: #4278

@Ma77Ball
Copy link
Contributor

@Yicong-Huang, please review. I had to have a committer raise the PR, or else it ended up being a chicken-and-egg problem.

@Ma77Ball
Copy link
Contributor

Here is also an action I ran on my forked repo with the changes in the main working branch (/safe-to-test works and uses the same sha to have the PR update correctly when used). (https://github.com/Ma77Ball/texera/actions/runs/23016559887)

@Yicong-Huang Yicong-Huang changed the title refactor(ci): auto-run workflow for fork PRs (fork) refactor(ci): auto-run workflow for fork PRs Mar 12, 2026
@Yicong-Huang Yicong-Huang requested a review from Copilot March 12, 2026 21:26
# Override these to use a different registry or version
imageRegistry: ghcr.io/apache
imageTag: latest
imageTag: nightly
Copy link
Contributor

Choose a reason for hiding this comment

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

is this change related?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, that is related to a different pr. @aicam can remove it.

Comment on lines +30 to +31
issue_comment:
types: [created]
Copy link
Contributor

@Yicong-Huang Yicong-Huang Mar 12, 2026

Choose a reason for hiding this comment

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

this would trigger CI actions every time some one posts a comment right? I think it will be a waste of resources. github action is free with a cap.

Copy link
Contributor

@Ma77Ball Ma77Ball Mar 12, 2026

Choose a reason for hiding this comment

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

Yes, but this is the only plausible workaround I could think of for this comment (#4278 (comment)). The problem is that either:

  1. We have a label that allows runs to pass through editing workflows (causing potential security issues)
  2. We have committers run workflows manually from the actions tab to bypass security checks (not sure if this is even possible as forked prs I don't think show up on the github action page and there is no guarrantee the pr will pick up the run)
  3. We only allow committers to make changes to workflows
  4. We allow committers to run the workflow from a comment

Committers can't just rerun the failed workflow, as it will trigger a GitHub run with the pull request owners' credentials.

Copy link
Contributor

@Yicong-Huang Yicong-Huang Mar 12, 2026

Choose a reason for hiding this comment

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

how about this:

  • we can use labels to satisfy this need, only committers would be able to apply labels.
  • Currently, all labels are assigned automatically by CI (auto labeler). we could modify it to respect the labels manually added by committers.
  • label changes are less frequent than comments changes

Does that satisfy your need?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, I will add back the label method and update the corresponding issue with a diagram of the current GitHub action flow.

Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned, we might need to modify the auto labeler logic first. do you want to do it as well?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts default deployment and CI behavior by switching the Helm chart’s default Texera image tag to a nightly build and enhancing the GitHub Actions build workflow to support a /safe-to-test approval flow via PR comments.

Changes:

  • Update Helm values to use nightly as the default Texera image tag.
  • Add issue_comment triggering and a check-permissions gate to the build workflow, and wire all build jobs to use the resolved SHA.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 3 comments.

File Description
bin/k8s/values.yaml Switches the default Texera image tag from latest to nightly.
.github/workflows/github-action-build.yml Adds /safe-to-test comment-triggered runs and a permissions gate; ensures jobs checkout a resolved SHA.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 34 to 36
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

The concurrency group is based on github.ref. For issue_comment events, github.ref resolves to the default branch ref (typically refs/heads/main), so all /safe-to-test runs across different PRs will share the same concurrency group and end up serialized (and potentially blocking each other). Consider including the PR number and/or the resolved SHA in the concurrency.group when the event is issue_comment so independent PR test runs don't contend with each other.

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +60
SHA=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.issue.number }} --jq '.head.sha')
echo "sha=$SHA" >> $GITHUB_OUTPUT
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

For /safe-to-test runs you resolve and checkout the PR head SHA (.head.sha). This means the build/tests run on the unmerged PR tip, which can diverge from what will actually land (merge conflicts / base-branch interactions), unlike the normal pull_request workflow which runs on the merge commit. Consider resolving/checking out the PR merge ref/merge SHA (e.g., refs/pull/<num>/merge or the PR's merge SHA) so the /safe-to-test run matches the pull_request behavior.

Suggested change
SHA=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.issue.number }} --jq '.head.sha')
echo "sha=$SHA" >> $GITHUB_OUTPUT
REF="refs/pull/${{ github.event.issue.number }}/merge"
echo "sha=$REF" >> $GITHUB_OUTPUT

Copilot uses AI. Check for mistakes.
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
CHANGED=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -c "^\.github/workflows/github-action-build\.yml$" || true)
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

This git diff origin/${{ github.base_ref }}...HEAD can fail because origin/${{ github.base_ref }} may not exist in the checkout (even with fetch-depth: 0), and any git diff failure will abort the step (only grep is guarded with || true). Consider diffing by explicit SHAs from the event payload (e.g., PR base/head SHAs) and/or fetching the base ref before diffing, and ensure the git diff invocation itself can't hard-fail the workflow due to a missing ref.

Suggested change
CHANGED=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -c "^\.github/workflows/github-action-build\.yml$" || true)
CHANGED=$((git diff --name-only origin/${{ github.base_ref }}...HEAD 2>/dev/null || true) | grep -c "^\.github/workflows/github-action-build\.yml$" || true)

Copilot uses AI. Check for mistakes.

python:
needs: check-permissions
if: always() && needs.check-permissions.result == 'success'
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: shall we use needs.has_permission == true?

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

Labels

build ci changes related to CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: gate workflow changes from forks behind committer approval

5 participants