-
Notifications
You must be signed in to change notification settings - Fork 28.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-35048][INFRA] Distribute GitHub Actions workflows to fork repo…
…sitories to share the resources ### What changes were proposed in this pull request? This PR proposes to leverage the GitHub Actions resources from the forked repositories instead of using the resources in ASF organisation at GitHub. This is how it works: 1. "Build and test" (`build_and_test.yml`) triggers a build on any commit on any branch (except `branch-*.*`), which roughly means: - The original repository will trigger the build on any commits in `master` branch - The forked repository will trigger the build on any commit in any branch. 2. The build triggered in the forked repository will checkout the original repository's `master` branch locally, and merge the branch from the forked repository into the original repository's `master` branch locally. Therefore, the tests in the forked repository will run after being sync'ed with the original repository's `master` branch. 3. In the original repository, it triggers a workflow that detects the workflow triggered in the forked repository, and add a comment, to the PR, pointing out the workflow in forked repository. In short, please see this example HyukjinKwon#34 1. You create a PR and your repository triggers the workflow. Your PR uses the resources allocated to you for testing. 2. Apache Spark repository finds your workflow, and links it in a comment in your PR **NOTE** that we will still run the tests in the original repository for each commit pushed to `master` branch. This distributes the workflows only in PRs. ### Why are the changes needed? ASF shares the resources across all the ASF projects, which makes the development slow down. Please see also: - Discussion in the buildsa.o mailing list: https://lists.apache.org/x/thread.html/r48d079eeff292254db22705c8ef8618f87ff7adc68d56c4e5d0b4105%3Cbuilds.apache.org%3E - Infra ticket: https://issues.apache.org/jira/browse/INFRA-21646 By distributing the workflows to use author's resources, we can get around this issue. ### Does this PR introduce _any_ user-facing change? No, this is a dev-only change. ### How was this patch tested? Manually tested at HyukjinKwon#34 and HyukjinKwon#33. Closes #32092 from HyukjinKwon/poc-fork-resources. Lead-authored-by: HyukjinKwon <gurwls223@apache.org> Co-authored-by: Hyukjin Kwon <gurwls223@apache.org> Signed-off-by: HyukjinKwon <gurwls223@apache.org>
- Loading branch information
1 parent
cd1e8e8
commit 2974b70
Showing
3 changed files
with
78 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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 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,40 @@ | ||
name: Notify test workflow | ||
on: | ||
pull_request_target: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
notify: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: "Notify test workflow" | ||
uses: actions/github-script@v3 | ||
if: ${{ github.base_ref == 'master' }} | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const endpoint = "GET /repos/:owner/:repo/actions/workflows/:id/runs?&branch=:branch" | ||
const params = { | ||
owner: context.payload.pull_request.head.repo.owner.login, | ||
repo: context.payload.pull_request.head.repo.name, | ||
id: "build_and_test.yml", | ||
branch: context.payload.pull_request.head.ref, | ||
} | ||
const runs = await github.request(endpoint, params) | ||
var runID = runs.data.workflow_runs[0].id | ||
var msg = "**[Test build #" + runID + "]" | ||
+ "(https://github.com/" + context.payload.pull_request.head.repo.full_name | ||
+ "/actions/runs/" + runID + ")** " | ||
+ "for PR " + context.issue.number | ||
+ " at commit [`" + context.payload.pull_request.head.sha.substring(0, 7) + "`]" | ||
+ "(https://github.com/" + context.payload.pull_request.head.repo.full_name | ||
+ "/commit/" + context.payload.pull_request.head.sha + ")." | ||
github.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.payload.repository.owner.login, | ||
repo: context.payload.repository.name, | ||
body: msg | ||
}) |
This file contains 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