ci: Fix per commit CI #21
Workflow file for this run
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
# 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-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~ 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: | | |
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 | |
- name: Run CI in container | |
run: ./.ci/run-container-ci ${{github.workspace}} ${{ github.base_ref }} |