Skip to content

Commit 26fcb68

Browse files
Sunrisepeakclaude
andcommitted
add multi-platform CI with reusable toolchain setup
- Extract xlings + toolchain install into composite action - Per-package jobs with path-based change detection - Build from tests/ directory for correct add_repositories path Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1048fde commit 26fcb68

3 files changed

Lines changed: 261 additions & 3 deletions

File tree

.agents/skills/mcpplibs-index-add.md

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This skill adds a new library from `https://github.com/mcpplibs/<name>` to the m
1414
- xmake package docs: https://xmake.io/mirror/manual/package_dependencies.html
1515
- mcpplibs org: https://github.com/mcpplibs
1616
- index repo: https://github.com/mcpplibs/mcpplibs-index
17+
- xlings CI reference (cross-platform C++23 toolchain): https://github.com/d2learn/xlings/tree/main/.github/workflows
1718

1819
## Step 1: Gather Library Info
1920

@@ -110,7 +111,11 @@ Add an `includes()` line to `tests/xmake.lua`:
110111
includes("<first-letter>/<package-name>")
111112
```
112113

113-
## Step 6: Verify Build
114+
## Step 6: Update CI
115+
116+
Add a new job to `.github/workflows/ci.yml` for the package. Each package has its own job with path-based triggering. Add path filter in `detect-changes` job and a new job block (see existing jobs as template). Also add the package paths to the top-level `on.push.paths` and `on.pull_request.paths`.
117+
118+
## Step 7: Verify Build
114119

115120
```bash
116121
# Clean any cached package
@@ -129,20 +134,69 @@ xmake run <package-name>_test
129134

130135
All three commands must succeed before proceeding.
131136

132-
## Step 7: Create Branch, Commit & Push
137+
## Step 8: Create Branch, Commit & Push
133138

134139
```bash
135140
git checkout -b add-<repo-name>-library
136141
git add packages/<first-letter>/<package-name>/xmake.lua \
137142
tests/<first-letter>/<package-name>/xmake.lua \
138143
tests/<first-letter>/<package-name>/main.cpp \
139-
tests/xmake.lua
144+
tests/xmake.lua \
145+
.github/workflows/ci.yml
140146
git commit -m "add <package-name> library"
141147
git push -u upstream add-<repo-name>-library
142148
```
143149

144150
Use `upstream` (SSH remote) for push, not `origin` (HTTPS, no auth).
145151

152+
## C++23 Toolchain Reference
153+
154+
All mcpplibs packages require C++23 with modules support. Below are the toolchain configurations for each platform, referenced from [xlings CI](https://github.com/d2learn/xlings/tree/main/.github/workflows).
155+
156+
All toolchains are installed via [xlings](https://github.com/d2learn/xlings). xlings bundles xmake, no separate install needed.
157+
158+
### Install xlings
159+
160+
```bash
161+
# Linux / macOS
162+
curl -fsSL https://raw.githubusercontent.com/d2learn/xlings/main/tools/other/quick_install.sh | bash
163+
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
164+
165+
# Windows (PowerShell)
166+
irm https://raw.githubusercontent.com/d2learn/xlings/refs/heads/main/tools/other/quick_install.ps1 | iex
167+
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
168+
```
169+
170+
### Linux — GCC 15 (Ubuntu 24.04)
171+
172+
```bash
173+
xlings install gcc@15 -y
174+
xmake f -y
175+
```
176+
177+
### macOS — LLVM 20 (macOS 15)
178+
179+
```bash
180+
xlings install llvm@20 -y
181+
xmake f -y
182+
```
183+
184+
### Windows — MSVC (windows-latest)
185+
186+
```bash
187+
xmake f -y # auto-selects MSVC
188+
```
189+
190+
No special configuration needed. MSVC from Visual Studio supports C++23.
191+
192+
### Toolchain Version Summary
193+
194+
| Platform | Compiler | Version | Install |
195+
|----------|----------|---------|---------|
196+
| Linux | GCC | 15.1.0 | `xlings install gcc@15 -y` |
197+
| macOS | LLVM/Clang | 20 | `xlings install llvm@20 -y` |
198+
| Windows | MSVC | latest | auto-detected |
199+
146200
## Checklist
147201

148202
- [ ] Package directory name == `package("xxx")` name
@@ -151,6 +205,7 @@ Use `upstream` (SSH remote) for push, not `origin` (HTTPS, no auth).
151205
- [ ] Extra headers copied in `on_install` if needed by cppm
152206
- [ ] Test does NOT have `add_repositories()` (top-level handles it)
153207
- [ ] Test registered in `tests/xmake.lua` via `includes()`
208+
- [ ] CI matrix updated with new test entry
154209
- [ ] `xmake build` succeeds
155210
- [ ] `xmake run` produces expected output
156211
- [ ] Committed and pushed to upstream
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Setup C++23 Toolchain
2+
description: Install xlings and C++23 toolchain for the current platform
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Setup (unix)
8+
if: runner.os != 'Windows'
9+
shell: bash
10+
run: curl -fsSL https://raw.githubusercontent.com/d2learn/xlings/main/tools/other/quick_install.sh | bash
11+
- name: Setup (windows)
12+
if: runner.os == 'Windows'
13+
shell: pwsh
14+
run: irm https://raw.githubusercontent.com/d2learn/xlings/refs/heads/main/tools/other/quick_install.ps1 | iex
15+
- name: Install toolchain (linux)
16+
if: runner.os == 'Linux'
17+
shell: bash
18+
run: |
19+
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
20+
xlings install gcc@15 -y
21+
- name: Install toolchain (macos)
22+
if: runner.os == 'macOS'
23+
shell: bash
24+
run: |
25+
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
26+
xlings install llvm@20 -y

.github/workflows/ci.yml

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'packages/**'
8+
- 'tests/**'
9+
- '.github/workflows/ci.yml'
10+
pull_request:
11+
branches: [main]
12+
paths:
13+
- 'packages/**'
14+
- 'tests/**'
15+
- '.github/workflows/ci.yml'
16+
17+
env:
18+
XLINGS_NON_INTERACTIVE: 1
19+
20+
jobs:
21+
detect-changes:
22+
runs-on: ubuntu-24.04
23+
outputs:
24+
templates: ${{ steps.filter.outputs.templates }}
25+
cmdline: ${{ steps.filter.outputs.cmdline }}
26+
llmapi: ${{ steps.filter.outputs.llmapi }}
27+
lua: ${{ steps.filter.outputs.lua }}
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: dorny/paths-filter@v3
31+
id: filter
32+
with:
33+
filters: |
34+
templates:
35+
- 'packages/t/templates/**'
36+
- 'tests/t/templates/**'
37+
- '.github/workflows/ci.yml'
38+
cmdline:
39+
- 'packages/c/cmdline/**'
40+
- 'tests/c/cmdline/**'
41+
- '.github/workflows/ci.yml'
42+
llmapi:
43+
- 'packages/l/llmapi/**'
44+
- 'tests/l/llmapi/**'
45+
- '.github/workflows/ci.yml'
46+
lua:
47+
- 'packages/m/mcpplibs-capi-lua/**'
48+
- 'tests/l/lua/**'
49+
- '.github/workflows/ci.yml'
50+
51+
templates:
52+
needs: detect-changes
53+
if: needs.detect-changes.outputs.templates == 'true'
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
include:
58+
- { os: ubuntu-24.04, shell: bash }
59+
- { os: macos-15, shell: bash }
60+
- { os: windows-latest, shell: pwsh }
61+
runs-on: ${{ matrix.os }}
62+
name: templates (${{ matrix.os }})
63+
steps:
64+
- uses: actions/checkout@v4
65+
- uses: ./.github/actions/setup-toolchain
66+
- name: Build & Run (unix)
67+
if: runner.os != 'Windows'
68+
working-directory: tests
69+
run: |
70+
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
71+
xmake f -P . -y
72+
xmake build -P . -y templates_test
73+
xmake run -P . templates_test
74+
- name: Build & Run (windows)
75+
if: runner.os == 'Windows'
76+
working-directory: tests
77+
run: |
78+
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
79+
xmake f -P . -y
80+
xmake build -P . -y templates_test
81+
xmake run -P . templates_test
82+
83+
cmdline:
84+
needs: detect-changes
85+
if: needs.detect-changes.outputs.cmdline == 'true'
86+
strategy:
87+
fail-fast: false
88+
matrix:
89+
include:
90+
- { os: ubuntu-24.04, shell: bash }
91+
- { os: macos-15, shell: bash }
92+
- { os: windows-latest, shell: pwsh }
93+
runs-on: ${{ matrix.os }}
94+
name: cmdline (${{ matrix.os }})
95+
steps:
96+
- uses: actions/checkout@v4
97+
- uses: ./.github/actions/setup-toolchain
98+
- name: Build & Run (unix)
99+
if: runner.os != 'Windows'
100+
working-directory: tests
101+
run: |
102+
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
103+
xmake f -P . -y
104+
xmake build -P . -y cmdline_test
105+
xmake run -P . cmdline_test test_input
106+
- name: Build & Run (windows)
107+
if: runner.os == 'Windows'
108+
working-directory: tests
109+
run: |
110+
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
111+
xmake f -P . -y
112+
xmake build -P . -y cmdline_test
113+
xmake run -P . cmdline_test test_input
114+
115+
llmapi:
116+
needs: detect-changes
117+
if: needs.detect-changes.outputs.llmapi == 'true'
118+
strategy:
119+
fail-fast: false
120+
matrix:
121+
include:
122+
- { os: ubuntu-24.04, shell: bash }
123+
- { os: macos-15, shell: bash }
124+
- { os: windows-latest, shell: pwsh }
125+
runs-on: ${{ matrix.os }}
126+
name: llmapi (${{ matrix.os }})
127+
steps:
128+
- uses: actions/checkout@v4
129+
- uses: ./.github/actions/setup-toolchain
130+
- name: Build (unix)
131+
if: runner.os != 'Windows'
132+
working-directory: tests
133+
run: |
134+
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
135+
xmake f -P . -y
136+
xmake build -P . -y llmapi_test
137+
xmake build -P . -y llmapi_test_c
138+
- name: Build (windows)
139+
if: runner.os == 'Windows'
140+
working-directory: tests
141+
run: |
142+
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
143+
xmake f -P . -y
144+
xmake build -P . -y llmapi_test
145+
xmake build -P . -y llmapi_test_c
146+
147+
lua:
148+
needs: detect-changes
149+
if: needs.detect-changes.outputs.lua == 'true'
150+
strategy:
151+
fail-fast: false
152+
matrix:
153+
include:
154+
- { os: ubuntu-24.04, shell: bash }
155+
- { os: macos-15, shell: bash }
156+
- { os: windows-latest, shell: pwsh }
157+
runs-on: ${{ matrix.os }}
158+
name: lua (${{ matrix.os }})
159+
steps:
160+
- uses: actions/checkout@v4
161+
- uses: ./.github/actions/setup-toolchain
162+
- name: Build & Run (unix)
163+
if: runner.os != 'Windows'
164+
working-directory: tests
165+
run: |
166+
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
167+
xmake f -P . -y
168+
xmake build -P . -y lua_test
169+
xmake run -P . lua_test
170+
- name: Build & Run (windows)
171+
if: runner.os == 'Windows'
172+
working-directory: tests
173+
run: |
174+
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
175+
xmake f -P . -y
176+
xmake build -P . -y lua_test
177+
xmake run -P . lua_test

0 commit comments

Comments
 (0)