Skip to content

Commit 6e0b0b6

Browse files
committed
Update workflow to be used in merge queue.
Signed-off-by: Mirjam Aulbach <[email protected]>
1 parent aba4327 commit 6e0b0b6

File tree

4 files changed

+23
-53
lines changed

4 files changed

+23
-53
lines changed

.github/workflows.md

+8-22
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,21 @@ We have two types of files in the `/workflows` directory:
1616
- they shouldn't (and can't) be used in isolation, as they don't take care of the code being checked out
1717
- 📄 starting with `workflow_` indicate a collection of jobs that are automatically triggered by certain events or actions
1818

19-
## Pipelines
19+
## Pipelines and workflows
2020

21-
We have two types of workflows triggered by Pull Requests:
21+
We have one workflow triggered by Pull Requests. When a Pull Request is opened, we run selected jobs based on the location and changes made in the code. We have two sets of jobs:
2222

23-
1. When a Pull Request is opened, we run selected jobs based on the location and changes made in the code. We have two sets of jobs:
24-
- if changes are made inside the `/coral` directory, we run all [coral jobs](./workflows/jobs-coral.yaml)
25-
- if are made outside in `/core` or `/cluster-api` directories or `pom.xml`, we run all [maven jobs](./workflows/jobs-maven.yaml). This jobs are only run when the Pull Request is ready for review, excluding "Draft" PRs.
26-
2. When a Pull Request is approved, the [`workflow-merge-to-main`](./workflows/workflow-merge-to-main.yaml) is triggered.
23+
- if changes are made inside the `/coral` directory, we run all [coral jobs](./workflows/jobs-coral.yaml)
24+
- if are made outside in `/core` or `/cluster-api` directories or `pom.xml`, we run all [maven jobs](./workflows/jobs-maven.yaml).
2725

28-
- This workflow runs all [coral jobs](./workflows/jobs-coral.yaml) and [maven jobs](./workflows/jobs-maven.yaml)
29-
- After they are successful, it runs a job called `merge-to-main`. This job is defined in the [Branch protection rule](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule) for `main` and is and is necessary to enable merging on our default branch.
26+
These jobs are only run when the Pull Request is ready for review, excluding "Draft" PRs.
3027

31-
**Note**: This workflow is also triggered when a Pull Request targeting main is synchronized. This way we make sure that the checks are always automatically run on the latest code.
28+
We have one workflow [`workflow-merge-to-main`](./workflows/workflow-merge-to-main.yaml) that we run in a merge queue before merging an approved PR branch to `main`.
3229

33-
In addition, we have a workflow that is triggered when changes are made to the `openapi.yaml file`. We check whether the changes affect the TypeScript file in `/coral`. If the changes do affect the TypeScript file, the `api.d.ts` file is automatically generated, and the TypeScript compiler is run. If the TypeScript compiler finds no errors, the file is committed. Otherwise the job fails.
34-
35-
## Drawbacks
36-
37-
We have identified two potential drawbacks with this strategy:
30+
- This workflow runs all [coral jobs](./workflows/jobs-coral.yaml) and [maven jobs](./workflows/jobs-maven.yaml)
3831

39-
1. There will be a delay between approving a Pull Request and merging it because of the required job on approval. We can mitigate this in the future:
40-
41-
- by adding automatic notification about a PR being ready to merge.
42-
- consider auto-merging it in the future. Currently, we prefer manual merges to maintain more control over the process.
43-
44-
2. Depending on the workflow, some job runs may be redundant and increase the time between giving a Pull Request for review and merging it.
32+
In addition, we have a workflow that is triggered when changes are made to the `openapi.yaml file`. We check whether the changes affect the TypeScript file in `/coral`. If the changes do affect the TypeScript file, the `api.d.ts` file is automatically generated, and the TypeScript compiler is run. If the TypeScript compiler finds no errors, the file is committed. Otherwise the job fails.
4533

46-
- We plan to iterate over our workflows to reduce redundancy and improve efficiency and will pay attention if this slows us down,
47-
- We are using the `merge-to-main` workflow as a temporary solution until we move to GitHub merge queues, when they become mores stable.
4834

4935
## Background of this strategy
5036

.github/workflows/codeql.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
name: "CodeQL"
1313

1414
on:
15-
push:
16-
branches: [ "main" ]
15+
merge_group:
1716
pull_request:
1817
# The branches below must be a subset of the branches above
1918
branches: [ "main" ]
+14-28
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
1-
# This workflow is called when a pull request is approved
2-
# that targets the protected branch `main`.
3-
# The job `merge-to-main` ("Status check for enabling merging to main")
4-
# is a required status check.
5-
# (https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28)
6-
# We can only merge to main when this job has run and is green.
7-
# The workflow can be triggered manually, too.
8-
name: Checks enabling merge to main
1+
# This workflow is used in a merge queue
2+
# when a branch targets the protected branch `main`.
3+
4+
name: Enabling merge to main in merge queue
95

106
on:
11-
pull_request_review:
12-
types:
13-
- submitted
14-
branches:
15-
- main
167
pull_request:
17-
types:
18-
- synchronize
19-
branches:
20-
- main
8+
merge_group:
219
workflow_dispatch:
2210

2311
jobs:
2412
checkout-code:
25-
if: (github.event_name == 'pull_request' && github.event.action == 'synchronize') || (github.event_name == 'pull_request_review' && github.event.review.state == 'approved')
13+
if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || github.event_name == 'merge_group'
2614
runs-on: ubuntu-latest
2715
steps:
2816
- name: Checkout code
@@ -32,33 +20,31 @@ jobs:
3220
fetch-depth: 0
3321

3422
run-coral-jobs:
35-
if: (github.event_name == 'pull_request' && github.event.action == 'synchronize') || (github.event_name == 'pull_request_review' && github.event.review.state == 'approved')
36-
name: Run coral workflow before enabling merge to main
23+
if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || github.event_name == 'merge_group'
24+
name: Coral workflow
3725
needs: checkout-code
3826
uses: ./.github/workflows/jobs-coral.yaml
3927

40-
4128
run-maven-jobs:
42-
if: (github.event_name == 'pull_request' && github.event.action == 'synchronize') || (github.event_name == 'pull_request_review' && github.event.review.state == 'approved')
43-
name: Run maven workflow before enabling merge to main
29+
if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || github.event_name == 'merge_group'
30+
name: Maven workflow
4431
needs: checkout-code
4532
uses: ./.github/workflows/jobs-maven.yaml
4633

4734
run-e2e-tests:
48-
if: (github.event_name == 'pull_request' && github.event.action == 'synchronize') || (github.event_name == 'pull_request_review' && github.event.review.state == 'approved')
49-
name: Run Playwright e2e test before enabling merge to main
35+
if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || github.event_name == 'merge_group'
36+
name: Playwright e2e test
5037
needs: checkout-code
5138
permissions:
5239
actions: write
5340
uses: ./.github/workflows/end-to-end-tests.yaml
5441

5542
merge-to-main:
5643
name: Status check for enabling merging to main
57-
if: (github.event_name == 'pull_request' && github.event.action == 'synchronize') || (github.event_name == 'pull_request_review' && github.event.review.state == 'approved')
44+
if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || github.event_name == 'merge_group'
5845
runs-on: ubuntu-latest
5946
needs: [ run-maven-jobs, run-coral-jobs, run-e2e-tests ]
6047

6148
steps:
6249
- name: Confirm check
63-
run: echo "🎉 this was successful"
64-
50+
run: echo "🎉 this was successful"

.github/workflows/workflow-pull-requests.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ jobs:
4343
echo "changes-maven=true" >> $GITHUB_OUTPUT
4444
fi
4545
46-
4746
run-maven-jobs:
4847
needs: check-changes
4948
# the condition makes sure that changes on a draft PR do not trigger the job, except it's a "ready_for_review" event

0 commit comments

Comments
 (0)