Skip to content

Commit caa56fa

Browse files
committed
docs: replace custom GitHub Action with CI workflow guide
1 parent c29dfce commit caa56fa

4 files changed

Lines changed: 111 additions & 180 deletions

File tree

README.md

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -340,22 +340,9 @@ print(writer.write(header))
340340

341341
Full documentation, guides, and API reference: [axiomantic.github.io/headerkit](https://axiomantic.github.io/headerkit/)
342342

343-
## GitHub Action
343+
## CI Store Population
344344

345-
headerkit includes a GitHub Action for populating the cache in CI.
346-
Add it to a workflow that triggers on header changes:
347-
348-
```yaml
349-
- uses: axiomantic/headerkit@v0
350-
with:
351-
args: "include/mylib.h -w cffi --platform linux/amd64 --platform linux/arm64"
352-
commit: "true"
353-
```
354-
355-
This installs headerkit, runs `cache populate` with the specified
356-
arguments, and optionally commits the updated `.headerkit/` directory.
357-
358-
See the [GitHub Action Guide](https://axiomantic.github.io/headerkit/guides/github-action/) for full usage, cibuildwheel integration, and multi-platform examples.
345+
headerkit's build backend populates `.headerkit/` during wheel builds. To keep the store updated across platforms in CI, see the [CI Store Population guide](https://axiomantic.github.io/headerkit/guides/github-action/).
359346

360347
## Development
361348

action.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

docs/guides/github-action.md

Lines changed: 108 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,159 @@
1-
# GitHub Action
1+
# CI Store Population
22

3-
headerkit ships a composite GitHub Action that populates the
4-
`.headerkit/` cache in CI. Use it to keep cache entries up to date
5-
whenever headers change, so downstream builds never need libclang.
3+
headerkit's PEP 517 build backend populates `.headerkit/` during wheel
4+
builds. To keep the store up to date across platforms, use a CI workflow
5+
that builds wheels in a matrix, collects artifacts, and opens a PR if
6+
anything changed. No custom action needed -- just standard GitHub Actions
7+
building blocks.
68

7-
## What it does
8-
9-
The action runs three steps:
10-
11-
1. Sets up Python (via `actions/setup-python`).
12-
2. Installs headerkit from PyPI.
13-
3. Runs `headerkit cache populate` with the arguments you provide.
9+
## How it works
1410

15-
Optionally, it commits the updated `.headerkit/` directory back to the
16-
branch.
11+
The `.headerkit/` directory contains IR (parsed headers) and output
12+
(generated bindings) so that downstream builds work without libclang
13+
installed. This directory should be committed to your repository; it is
14+
not ephemeral cache.
1715

18-
## Inputs
16+
The CI pattern has two jobs:
1917

20-
| Input | Required | Default | Description |
21-
|-------|----------|---------|-------------|
22-
| `headerkit-version` | no | latest | Pin a specific headerkit version (e.g., `0.15.0`) |
23-
| `python-version` | no | `3.12` | Python version for the runner |
24-
| `args` | no | `""` | Arguments passed to `headerkit cache populate` |
25-
| `commit` | no | `false` | Commit populated cache files after generation |
18+
1. **build** -- runs in a matrix across platforms, builds wheels, and
19+
uploads the `.headerkit/` directory as an artifact.
20+
2. **update-store** -- downloads all artifacts into a single `.headerkit/`
21+
directory and opens a PR if anything changed.
2622

27-
## Basic usage
23+
## Example workflow
2824

2925
```yaml
30-
name: Populate headerkit cache
26+
name: Update headerkit store
3127
on:
3228
push:
29+
branches: [main]
3330
paths:
3431
- "include/**/*.h"
32+
- "pyproject.toml"
33+
schedule:
34+
- cron: "0 6 * * 1" # weekly on Monday
3535

3636
jobs:
37-
populate:
38-
runs-on: ubuntu-latest
37+
build:
38+
strategy:
39+
matrix:
40+
os: [ubuntu-latest, macos-latest, windows-latest]
41+
runs-on: ${{ matrix.os }}
3942
steps:
4043
- uses: actions/checkout@v4
4144

42-
- uses: axiomantic/headerkit@v0
45+
- uses: actions/setup-python@v5
4346
with:
44-
args: "include/mylib.h -w cffi --platform linux/amd64"
45-
commit: "true"
46-
```
47-
48-
This installs the latest headerkit, runs `cache populate` for the
49-
specified header and platform, and commits the result.
47+
python-version: "3.12"
5048

51-
## Pin a headerkit version
49+
- name: Build wheel
50+
run: pip install build && python -m build --wheel
5251

53-
Lock the version to avoid surprises from new releases:
54-
55-
```yaml
56-
- uses: axiomantic/headerkit@v0
57-
with:
58-
headerkit-version: "0.15.0"
59-
args: "include/mylib.h -w cffi --cibuildwheel"
60-
```
52+
- uses: actions/upload-artifact@v4
53+
with:
54+
name: headerkit-store-${{ matrix.os }}
55+
path: .headerkit/
6156

62-
## Usage with cibuildwheel
57+
update-store:
58+
needs: build
59+
runs-on: ubuntu-latest
60+
permissions:
61+
contents: write
62+
pull-requests: write
63+
steps:
64+
- uses: actions/checkout@v4
6365

64-
If your project uses cibuildwheel, pass `--cibuildwheel` to auto-detect
65-
target platforms and Python versions from `[tool.cibuildwheel]` in
66-
`pyproject.toml`:
66+
- uses: actions/download-artifact@v4
67+
with:
68+
pattern: headerkit-store-*
69+
path: .headerkit/
70+
merge-multiple: true
6771

68-
```yaml
69-
- uses: axiomantic/headerkit@v0
70-
with:
71-
args: "--cibuildwheel"
72-
commit: "true"
72+
- uses: peter-evans/create-pull-request@v8
73+
with:
74+
commit-message: "chore: update headerkit store"
75+
title: "chore: update headerkit store"
76+
branch: headerkit/update-store
77+
body: |
78+
Automated update of `.headerkit/` store from CI matrix build.
79+
labels: automated
7380
```
7481
75-
This reads the `build` and `skip` selectors to determine which CPython
76-
versions and Linux platforms to target.
77-
78-
## Usage with multiple platforms
82+
## Using cibuildwheel
7983
80-
Generate cache entries for specific platforms using `--platform`:
84+
If your project uses cibuildwheel, replace the build step:
8185
8286
```yaml
83-
- uses: axiomantic/headerkit@v0
84-
with:
85-
args: >-
86-
include/mylib.h -w cffi
87-
--platform linux/amd64
88-
--platform linux/arm64
89-
commit: "true"
90-
```
91-
92-
For macOS and Windows targets, run the action on the matching runner
93-
OS instead of relying on Docker emulation:
94-
95-
```yaml
96-
jobs:
97-
populate-linux:
98-
runs-on: ubuntu-latest
87+
build:
88+
strategy:
89+
matrix:
90+
os: [ubuntu-latest, macos-latest, windows-latest]
91+
runs-on: ${{ matrix.os }}
9992
steps:
10093
- uses: actions/checkout@v4
101-
- uses: axiomantic/headerkit@v0
94+
95+
- uses: actions/setup-python@v5
10296
with:
103-
args: "include/mylib.h -w cffi --platform linux/amd64 --platform linux/arm64"
104-
commit: "true"
97+
python-version: "3.12"
10598

106-
populate-macos:
107-
runs-on: macos-latest
108-
needs: populate-linux
109-
steps:
110-
- uses: actions/checkout@v4
111-
- uses: axiomantic/headerkit@v0
99+
- name: Build wheels
100+
run: pip install cibuildwheel && cibuildwheel --output-dir dist
101+
102+
- uses: actions/upload-artifact@v4
112103
with:
113-
args: "include/mylib.h -w cffi"
114-
commit: "true"
104+
name: headerkit-store-${{ matrix.os }}
105+
path: .headerkit/
115106
```
116107
117-
Note that when `commit: "true"` is used across multiple jobs, each job
118-
must pull the latest commit from the previous job to avoid conflicts.
119-
Use `needs:` to sequence them.
108+
The build backend populates `.headerkit/` as a side effect of each wheel
109+
build, so cibuildwheel produces store entries for every platform in the
110+
matrix automatically.
120111

121-
## How it works
112+
## Configuration options
122113

123-
The action is a [composite action](https://docs.github.com/en/actions/sharing-automations/creating-actions/creating-a-composite-action)
124-
defined in `action.yml` at the repository root. It:
114+
### Customizing platforms
125115

126-
1. Calls `actions/setup-python` with the requested Python version.
127-
2. Installs headerkit via pip. If `headerkit-version` is set, it pins
128-
that exact version; otherwise it installs the latest release.
129-
3. Runs `headerkit cache populate` with your `args` value. The args
130-
are passed through to the command as-is, so any flag that
131-
`cache populate` accepts works here.
132-
4. If `commit` is `"true"`, it configures a bot git identity, stages
133-
`.headerkit/`, and commits if there are changes. If the cache is
134-
already up to date, the commit step is a no-op.
116+
Add or remove entries from `matrix.os` to match your target platforms:
135117

136-
All input values are passed via environment variables (not shell
137-
interpolation) to prevent injection attacks.
118+
```yaml
119+
strategy:
120+
matrix:
121+
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]
122+
```
138123

139-
## Triggering on header changes
124+
### Configuring the PR
140125

141-
Use `paths` filters to run the action only when headers change:
126+
The `peter-evans/create-pull-request` action accepts many options for
127+
customizing the resulting pull request:
142128

143129
```yaml
144-
on:
145-
push:
146-
paths:
147-
- "include/**/*.h"
148-
- "vendor/**/*.h"
130+
- uses: peter-evans/create-pull-request@v8
131+
with:
132+
commit-message: "chore: update headerkit store"
133+
title: "chore: update headerkit store"
134+
branch: headerkit/update-store
135+
labels: automated, dependencies
136+
reviewers: your-username
137+
draft: false
149138
```
150139

151-
This avoids unnecessary cache populate runs on unrelated commits.
140+
See the [create-pull-request documentation](https://github.com/peter-evans/create-pull-request)
141+
for the full list of inputs.
142+
143+
### Running on schedule vs on push
144+
145+
The example workflow triggers both on push (when headers change) and on a
146+
weekly schedule. Adjust to fit your project:
147+
148+
- **On push with path filters** -- reacts to header changes immediately.
149+
- **On schedule** -- catches changes from dependency updates or toolchain
150+
upgrades that affect generated output.
151+
- **Manual dispatch** -- add `workflow_dispatch:` to the `on:` block
152+
to allow manual runs from the Actions tab.
152153

153154
## See also
154155

155156
- [Cache Strategy Guide](cache.md) for cache layout, bypass flags, and
156157
multi-platform population details.
157158
- [Build Backend Guide](build-backend.md) for using headerkit as a
158-
PEP 517 build backend with committed cache.
159+
PEP 517 build backend with committed store.

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ nav:
7979
- Target Triples: design/target-triples.md
8080
- Cache System: guides/cache.md
8181
- Build Backend: guides/build-backend.md
82-
- GitHub Action: guides/github-action.md
82+
- CI Store Population: guides/github-action.md
8383
- Using CFFI Writer: guides/cffi.md
8484
- Writing Custom Backends: guides/custom-backends.md
8585
- Writing Custom Writers: guides/custom-writers.md

0 commit comments

Comments
 (0)