-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The pull request event does not have write access to the repo, so it cannot dispatch jobs.
- Loading branch information
Showing
3 changed files
with
64 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/python | ||
|
||
import subprocess | ||
import sys | ||
import json | ||
|
||
range = sys.argv[1] | ||
|
||
commits = subprocess.run(f'git log --format="%H" {range}', shell=True, text=True, capture_output=True) | ||
commits = commits.stdout.strip().split() | ||
|
||
if len(commits) > 0: | ||
print(json.dumps({'commit': commits})) |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,31 +1,69 @@ | ||
# See reference docs at | ||
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions | ||
|
||
name: Pull request CI | ||
on: pull_request | ||
|
||
jobs: | ||
pr-ci: | ||
pr-head-ci: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Clone the repo | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Pull container image | ||
run: ./.ci/run-container-ci pull | ||
|
||
- name: Run CI in container | ||
run: ./.ci/run-container-ci ${{github.workspace}} ${{ github.base_ref }} | ||
|
||
# Generate a list of commits to run CI on | ||
generate-matrix: | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
- name: Clone the repo | ||
uses: actions/checkout@v4 | ||
with: | ||
#repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
ref: ${{ github.event.pull_request.base.sha }} | ||
fetch-depth: 0 | ||
|
||
# HEAD^2~ because PR branch is second parent and we want to skip the last commit | ||
- name: Dispatch jobs for commits in PR history | ||
# HEAD~ because we want to skip the last commit (which is built in job above) | ||
- name: Create jobs for commits in PR history | ||
id: set-matrix | ||
run: | | ||
echo matrix=$(.ci/matrix-from-commit-log origin/${{github.base_ref}}..${{ github.event.pull_request.head.sha}}~) >> $GITHUB_OUTPUT | ||
# Run this job for every commit in the PR except HEAD. | ||
pr-commit-ci: | ||
runs-on: ubuntu-22.04 | ||
needs: [ generate-matrix ] | ||
strategy: | ||
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }} | ||
if: needs.generate-matrix.outputs.matrix != '' | ||
steps: | ||
- name: Clone the repo | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
#repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
ref: ${{ github.event.pull_request.base.sha }} | ||
|
||
- name: Create merge commit | ||
env: | ||
GIT_AUTHOR_NAME: Bot | ||
GIT_AUTHOR_EMAIL: [email protected] | ||
GIT_COMMITTER_NAME: Bot | ||
GIT_COMMITTER_EMAIL: [email protected] | ||
run: | | ||
for commit in $(git log --format="%H" origin/${{github.base_ref}}..HEAD^2~); do | ||
echo ::notice::Dispatching job for $commit | ||
curl -L -s \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
${{ github.api_url }}/repos/${{ github.repository }}/actions/workflows/commit-ci.yml/dispatches \ | ||
-d "{\"ref\":\"${{ github.event.pull_request.head.ref }}\",\"inputs\":{\"sha\":\"$commit\",\"base_ref\":\"${{ github.base_ref}}\"}}" | ||
done | ||
git fetch origin ${{ matrix.commit }} | ||
git merge --no-ff --no-edit ${{ matrix.commit }} | ||
echo "merge commit parents:" | ||
git log -1 --format="Head %H, Parents %P" | ||
- name: Pull container image | ||
run: ./.ci/run-container-ci pull | ||
|