Skip to content

Commit 645b541

Browse files
sharder996tobe2098
authored andcommitted
[ci] dynamic ci (#4135)
This PR revamps how our GitHub workflows are invoked so that only the necessary workflows are run and we avoid situations where a change to the `README.md` gets blocked on an Apple runner failing to compile Multipass due to a spurious seg fault. This setup works by having a single orchestration workflow which filters the changed files with [dorny/paths-filter](https://github.com/dorny/paths-filter), defines relevant outputs, and then spawns the relevant workflows. A "Finalize" job in the orchestration workflow then checks the return statuses of the spawned workflows and sets it own return status accordingly. Regarding branch protection rules, the idea is that we would protect on `Dynamic-CI \ Filter changed files` and `Dynamic-CI \ Finalize` to make sure that the PR is properly analyzed and and errors from spawned workflows are propagated up, effectively gating the PR from being merged. Below are some example draft PRs demonstrating various scenarios and how the new CI setup reacts to them. 1. Documentation changes (#4136) - https://github.com/canonical/multipass/actions/runs/15478104252/job/43578947769?pr=4136 demonstrates a run that has been cancelled. 2. Documentation changes that fail to build (#4143) 3. Source code changes (#4137) 4. Changes that are neither documentation or source code (#4142) 5. Changing both documentation and code, but having one fail (#4144) Merge queues aren't officially supported in the `dorny/paths-filter` action, but there are several user submitted examples of people using the action in this manner. Because of repository permissions this has yet to have been tested. Another GitHub action; [tj-actions/changed-files](https://github.com/tj-actions/changed-files) was considered for added functionality of being able to spawn workflows. However, I chose not to go with it due to it's increased complexity and granularity of control that isn't strictly needed in our setup. One other thing, `docs/readthedocs.com:canonical-multipass` will continue to be built for every PR regardless of changed files. The trigger for this workflow is managed by [ReadtheDocs](https://app.readthedocs.com/dashboard/canonical-multipass/pull-requests/) which does not offer the granularity or control of being able to selectively control when the workflow is run. One slight improvement that can be made to further optimize CI would be to bisect `windows-macos.yml` and further filter on files that only affect Windows or macOS builds. However, care would need to be taken in order to ensure that there is no unnoticed cross-platform dependencies in these filtered files. Closes #4136 Closes #4143 Closes #4137 Closes #4142 Closes #4144 --- MULTI-1932 ---
1 parent 9b97ef7 commit 645b541

6 files changed

Lines changed: 7 additions & 56 deletions

File tree

.github/actions/check-lint/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ runs:
2020
id: wait-lint
2121
with:
2222
token: ${{ github.token }}
23-
checkName: Lint
23+
checkName: Lint / Lint
2424
ref: ${{ inputs.sha }}
2525
timeoutSeconds: 120
2626
intervalSeconds: 5

.github/workflows/automatic-doc-checks.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,7 @@
22
name: Automatic doc checks
33

44
on:
5-
push:
6-
branches: [ main ]
7-
pull_request:
8-
paths:
9-
- "docs/**"
10-
- ".github/workflows/automatic-doc-checks.yml"
11-
merge_group:
12-
types: [checks_requested]
13-
paths:
14-
- "docs/**"
15-
- ".github/workflows/automatic-doc-checks.yml"
5+
workflow_call:
166
workflow_dispatch:
177
# Manual trigger
188

.github/workflows/dynamic-ci.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
2525
outputs:
2626
docs: ${{ steps.filter.outputs.docs }}
2727
code: ${{ steps.filter.outputs.code }}
28-
hooks: ${{ steps.filter.outputs.hooks }}
2928
steps:
3029
- name: Checkout code
3130
uses: actions/checkout@v6
@@ -57,12 +56,11 @@ jobs:
5756
- "snap-wrappers/**"
5857
- "src/**"
5958
- "tests/**"
59+
- "tools/**"
6060
- ".gitmodules"
6161
- "CMakeLists.txt"
6262
- "vcpkg-configuration.json"
6363
- "vcpkg.json"
64-
hooks:
65-
- "git-hooks/**"
6664
6765
6866
docs:
@@ -90,17 +88,11 @@ jobs:
9088
uses: "./.github/workflows/windows-macos.yml"
9189
secrets: inherit
9290

93-
hooks:
94-
name: Hooks
95-
needs: filter
96-
if: needs.filter.outputs.hooks == 'true'
97-
uses: "./.github/workflows/test-hooks.yml"
98-
9991
finalize:
10092
name: Finalize
10193
runs-on: ubuntu-latest
10294
if: ${{ always() }}
103-
needs: [docs, lint, linux, windows-macos, hooks]
95+
needs: [docs, lint, linux, windows-macos]
10496
steps:
10597
- name: Docs failure check
10698
if: ${{
@@ -115,7 +107,3 @@ jobs:
115107
needs.windows-macos.result == 'failure' || needs.windows-macos.result == 'cancelled'
116108
}}
117109
run: exit 1
118-
119-
- name: Hooks failure check
120-
if: ${{ needs.hooks.result == 'failure' || needs.hooks.result == 'cancelled' }}
121-
run: exit 1

.github/workflows/lint.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
name: Lint
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
- release/[0-9]+.[0-9]+
8-
tags:
9-
- v[0-9]+.[0-9]+.[0-9]+
10-
pull_request:
11-
types: [opened, synchronize, reopened, ready_for_review]
12-
merge_group:
13-
types: [checks_requested]
4+
workflow_call:
145

156
jobs:
167
Lint:

.github/workflows/linux.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
name: Linux
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
- release/[0-9]+.[0-9]+
8-
tags:
9-
- v[0-9]+.[0-9]+.[0-9]+
10-
pull_request:
11-
types: [opened, synchronize, reopened, ready_for_review]
12-
merge_group:
13-
types: [checks_requested]
4+
workflow_call:
145

156
concurrency:
167
group: linux-${{ github.workflow }}-${{ github.head_ref || github.run_id }}

.github/workflows/windows-macos.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
name: WindowsMacOS
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
- release/[0-9]+.[0-9]+
8-
tags:
9-
- v[0-9]+.[0-9]+.[0-9]+
10-
pull_request:
11-
types: [opened, synchronize, reopened, ready_for_review]
12-
merge_group:
13-
types: [checks_requested]
4+
workflow_call:
145

156
concurrency:
167
group: windows-macos-${{ github.workflow }}-${{ github.event.number && format('pr{0}', github.event.number) || github.run_id }}

0 commit comments

Comments
 (0)