-
Notifications
You must be signed in to change notification settings - Fork 813
[v2][Feat] Add the check-generate workflow can work in local runner for the PR from fork repo (#6845) #7040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ac1890c
feat: add check generate local for the PR from fork repo
SZL741023 6fba6a5
feat: add the fork repo check condition in build-ci-image.yml
SZL741023 b70e36d
feat: separte the ci check generation for different type PR
SZL741023 59ca213
fix: fixed the v3 path of mockery
SZL741023 addbffc
fix: fixed the ci job name to match the branch protect
SZL741023 9e6a378
feat: Add build image locally for fork PR
SZL741023 0b2b525
fix: make buf test will occur error
SZL741023 8328737
fix: replace case-in-subshell with if/elif in gen.Dockerfile buf stage
SZL741023 5d8c35f
fix: regenreate buf files
SZL741023 bd3da09
fix: buf.lock permission denied
SZL741023 3742cbf
ci: switch check-generation trigger to pull_request_target to support…
SZL741023 9897bfd
ci: switch to pull_request_target to support fork PRs
SZL741023 9a50a94
fix: the ci job setup is not triggered.
SZL741023 e66d1e8
fix: the ci job build-ci-image can not be trigger
SZL741023 826ac9f
fix: fix the pr run can't be found
SZL741023 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| name: Check Generated in Container Files | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| pr_number: | ||
| required: true | ||
| type: string | ||
| base_ref: | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| # Check generation in CI image, when the PR is not from fork repo | ||
| check-generate-container: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| actions: read | ||
| packages: read | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Determine Docker image | ||
| id: docker-image | ||
| run: | | ||
| # Check if gen.Dockerfile or build workflow was modified | ||
| git fetch origin ${{ inputs.base_ref }} | ||
| if git diff --name-only origin/${{ inputs.base_ref }}...HEAD | grep -E '^(gen\.Dockerfile|Dockerfile\.ci|\.github/workflows/build-ci-image\.yml)$'; then | ||
| echo "modified=true" >> $GITHUB_OUTPUT | ||
| echo "image=ghcr.io/flyteorg/flyte/ci:pr-${{ inputs.pr_number}}" >> $GITHUB_OUTPUT | ||
| echo "📦 gen.Dockerfile modified - will use PR-specific image" | ||
| else | ||
| echo "modified=false" >> $GITHUB_OUTPUT | ||
| echo "image=ghcr.io/flyteorg/flyte/ci:v2" >> $GITHUB_OUTPUT | ||
| echo "📦 Using default v2 image" | ||
| fi | ||
|
|
||
| - name: Wait for Docker image build workflow | ||
| if: steps.docker-image.outputs.modified == 'true' | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const maxAttempts = 60; // 20 minutes max | ||
| const delaySeconds = 20; | ||
|
|
||
| console.log('⏳ Waiting for Docker image build workflow to complete...'); | ||
|
|
||
| for (let attempt = 0; attempt < maxAttempts; attempt++) { | ||
| // Get workflow runs for this PR | ||
| const { data: runs } = await github.rest.actions.listWorkflowRuns({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| workflow_id: 'build-ci-image.yml', | ||
| event: 'pull_request', | ||
| per_page: 10 | ||
| }); | ||
|
|
||
| // Find the run for this PR | ||
| const prRun = runs.workflow_runs.find(run => | ||
| run.head_sha === context.payload.pull_request.head.sha | ||
| ); | ||
|
|
||
| if (prRun) { | ||
| console.log(`Found workflow run: ${prRun.html_url}`); | ||
| console.log(`Status: ${prRun.status}, Conclusion: ${prRun.conclusion}`); | ||
|
|
||
| if (prRun.status === 'completed') { | ||
| if (prRun.conclusion === 'success') { | ||
| console.log('✅ Docker image build completed successfully!'); | ||
| return; | ||
| } else { | ||
| core.setFailed(`❌ Docker image build failed with conclusion: ${prRun.conclusion}`); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| console.log(`Attempt ${attempt + 1}/${maxAttempts}: Build still running, waiting ${delaySeconds} seconds...`); | ||
| } else { | ||
| console.log(`Attempt ${attempt + 1}/${maxAttempts}: Build not started yet, waiting ${delaySeconds} seconds...`); | ||
| } | ||
|
|
||
| await new Promise(resolve => setTimeout(resolve, delaySeconds * 1000)); | ||
| } | ||
|
|
||
| core.setFailed('❌ Timeout waiting for Docker image build to complete'); | ||
|
|
||
| - name: Login to GHCR | ||
| if: steps.docker-image.outputs.modified == 'true' | ||
| run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
|
||
| - name: Pull Docker image | ||
| if: steps.docker-image.outputs.modified == 'true' | ||
| run: | | ||
| IMAGE="${{ steps.docker-image.outputs.image }}" | ||
| echo "📦 Pulling image: $IMAGE" | ||
| docker pull "$IMAGE" | ||
|
|
||
| - name: Run checks in container | ||
| run: | | ||
| IMAGE="${{ steps.docker-image.outputs.image }}" | ||
| echo "Using image: $IMAGE" | ||
|
|
||
| docker run --rm \ | ||
| -v ${{ github.workspace }}:/workspace \ | ||
| -w /workspace \ | ||
| -e SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0 \ | ||
| -e UV_PROJECT_ENVIRONMENT=/tmp/flyte-venv \ | ||
| "$IMAGE" \ | ||
| bash -c " | ||
| git config --global --add safe.directory /workspace && | ||
| cd gen/python && uv sync --all-groups --frozen && cd ../.. && | ||
| make gen-local && | ||
| git diff --exit-code || (echo 'Generated files are out of date. Run \`make gen\` and commit changes.' && exit 1) && | ||
| make build-crate | ||
| " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| name: Check Generated Local Files | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| jobs: | ||
| # Check generation locally when the PR is from fork repo | ||
| check-generate-local: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| actions: read | ||
| packages: read | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| # for fork PR - get the version of tools from gen.Dockerfile | ||
| - name: Extract tool versions from gen.Dockerfile | ||
| id: versions | ||
| run: | | ||
| extract() { grep "^ARG ${1}=" gen.Dockerfile | cut -d'=' -f2; } | ||
| echo "go=$(extract GO_VERSION)" >> $GITHUB_OUTPUT | ||
| echo "python=$(extract PYTHON_VERSION)" >> $GITHUB_OUTPUT | ||
| echo "node=$(extract NODE_VERSION)" >> $GITHUB_OUTPUT | ||
| echo "rust=$(extract RUST_VERSION)" >> $GITHUB_OUTPUT | ||
| echo "uv=$(extract UV_VERSION)" >> $GITHUB_OUTPUT | ||
| echo "buf=$(extract BUF_VERSION)" >> $GITHUB_OUTPUT | ||
| echo "mockery=$(extract MOCKERY_VERSION)" >> $GITHUB_OUTPUT | ||
|
|
||
| # for fork PR - install tools in runner | ||
| - name: Setup Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: ${{ steps.versions.outputs.go }} | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ steps.versions.outputs.python }} | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ steps.versions.outputs.node }} | ||
|
|
||
| - name: Setup Rust | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| toolchain: ${{ steps.versions.outputs.rust }} | ||
|
|
||
| - name: Setup uv | ||
| uses: astral-sh/setup-uv@v4 | ||
| with: | ||
| version: ${{ steps.versions.outputs.uv }} | ||
|
|
||
| - name: Install Buf and Mockery | ||
| run: | | ||
| BUF_VERSION="${{ steps.versions.outputs.buf }}" | ||
| curl -fsSL "https://github.com/bufbuild/buf/releases/download/v${BUF_VERSION}/buf-Linux-x86_64.tar.gz" | tar -xzC /tmp | ||
| sudo mv /tmp/buf/bin/buf /usr/local/bin/buf | ||
| sudo mv /tmp/buf/bin/protoc-gen-buf-breaking /usr/local/bin/ | ||
| sudo mv /tmp/buf/bin/protoc-gen-buf-lint /usr/local/bin/ | ||
| npm install -g pnpm | ||
| go install "github.com/vektra/mockery/v2@v${{ steps.versions.outputs.mockery }}" | ||
|
|
||
| # for fork PR - Check make gen locally | ||
| - name: Run check locally (fork PR) | ||
| env: | ||
| SETUPTOOLS_SCM_PRETEND_VERSION: "0.0.0" | ||
| UV_PROJECT_ENVIRONMENT: /tmp/flyte-venv | ||
| run: | | ||
| cd gen/python && uv sync --all-groups --frozen && cd ../.. | ||
| make gen-local | ||
| git diff --exit-code || (echo 'Generated files are out of date. Run \`make gen\` and commit changes.' && exit 1) | ||
| make build-crate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.