-
Notifications
You must be signed in to change notification settings - Fork 0
194 lines (169 loc) · 5.71 KB
/
Copy pathci.yml
File metadata and controls
194 lines (169 loc) · 5.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# Multi-OS dogfood: mb_pre_commit_setup() must configure + install the Git hook everywhere we care about.
name: CI
on:
push:
branches: [main, master]
pull_request:
workflow_dispatch:
inputs:
cmake_preset:
description: Configure / build preset (see CMakePresets.json)
type: choice
options:
- ci
- default
- release
- dev-verbose
default: ci
run_workflow_preset:
description: Also run cmake --workflow (dev | ship | ci)
type: boolean
default: false
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PYTHONUTF8: "1"
PYTHONIOENCODING: utf-8
jobs:
cmake:
name: cmake · ${{ matrix.os }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, windows-latest, macos-14]
env:
CMAKE_PRESET: >-
${{
github.event_name == 'workflow_dispatch'
&& github.event.inputs.cmake_preset
|| 'ci'
}}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Shipped example config matches repo root
run: cmp -s configs/v4/.pre-commit-config.yaml .pre-commit-config.yaml
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
# Preset schema v10 requires CMake ≥ 4.0 (see CMakePresets.json). mb-pre-commit.cmake needs ≥ 3.21.
- name: Install CMake and Ninja
run: |
python -m pip install --upgrade pip
python -m pip install "cmake>=4.0,<5" "ninja>=1.11"
- name: Tool versions
id: versions
run: |
cmake --version
ninja --version
python --version
{
echo "cmake<<EOF"
cmake --version | head -n1
echo EOF
echo "ninja<<EOF"
ninja --version
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Configure + build (preset)
run: |
cmake --preset "$CMAKE_PRESET"
cmake --build --preset "$CMAKE_PRESET"
- name: Sweep (pre-commit all files via CMake target)
run: cmake --build --preset "$CMAKE_PRESET" --target mb-pre-commit-sweep
- name: Optional workflow preset
if: >-
github.event_name == 'workflow_dispatch'
&& github.event.inputs.run_workflow_preset == 'true'
run: |
case "${{ github.event.inputs.cmake_preset }}" in
ci) cmake --workflow --preset ci ;;
default) cmake --workflow --preset dev ;;
dev-verbose) cmake --workflow --preset dev ;;
release) cmake --workflow --preset ship ;;
*) cmake --workflow --preset ci ;;
esac
- name: Verify Git hook was installed
run: |
test -f .git/hooks/pre-commit
if [[ "${{ runner.os }}" != "Windows" ]]; then
test -x .git/hooks/pre-commit
fi
- name: Job summary
if: success()
run: |
{
echo "## CMake CI"
echo ""
echo "| | |"
echo "|---|---|"
echo "| **Runner** | \`${{ matrix.os }}\` |"
echo "| **Preset** | \`$CMAKE_PRESET\` |"
echo "| **CMake** | ${{ steps.versions.outputs.cmake }} |"
echo "| **Ninja** | ${{ steps.versions.outputs.ninja }} |"
echo ""
echo "Hook present at \`.git/hooks/pre-commit\`."
} >> "$GITHUB_STEP_SUMMARY"
unix-makefiles-smoke:
name: CMake (Ubuntu · Unix Makefiles)
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v6
- name: Shipped example config matches repo root
run: cmp -s configs/v4/.pre-commit-config.yaml .pre-commit-config.yaml
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install CMake (no Ninja — exercise Makefiles preset)
run: |
python -m pip install --upgrade pip
python -m pip install "cmake>=4.0,<5"
sudo apt-get update
sudo apt-get install -y --no-install-recommends make
- name: Configure + build
run: |
cmake --preset unix-makefiles
cmake --build --preset unix-makefiles
- name: Sweep (pre-commit all files)
run: cmake --build --preset unix-makefiles --target mb-pre-commit-sweep
dependabot-automerge:
name: Dependabot auto-merge
needs: [cmake, unix-makefiles-smoke]
runs-on: ubuntu-latest
if: >
github.event_name == 'pull_request' &&
github.event.pull_request.user.login == 'dependabot[bot]' &&
!github.event.pull_request.draft
permissions:
contents: write
pull-requests: write
steps:
- name: Fetch Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2.5.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Merge patch, minor, and pre-commit updates
if: >
steps.metadata.outputs.update-type == 'version-update:semver-patch' ||
steps.metadata.outputs.update-type == 'version-update:semver-minor' ||
steps.metadata.outputs.update-type == 'security-update:semver-patch' ||
steps.metadata.outputs.update-type == 'security-update:semver-minor' ||
steps.metadata.outputs.package-ecosystem == 'pre_commit'
run: gh pr merge --auto --squash "$PR_URL"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}