Skip to content

Commit 70c27f5

Browse files
Sunrisepeakclaude
andcommitted
add multi-platform CI with reusable toolchain setup
- Extract xlings + toolchain install into composite action - Single build job per OS, toolchain installed once and shared - Per-package change detection skips unaffected builds - Build from tests/ directory for correct add_repositories path - Remove llmapi C API (capi) - not implemented in upstream yet - Fix macOS/Linux: use gh CLI for authenticated xlings download - Fix xlings install: extract to ~/.xlings with --strip-components=1 - Fix macOS C++23 modules: specify --toolchain=llvm in configure Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1048fde commit 70c27f5

File tree

7 files changed

+264
-36
lines changed

7 files changed

+264
-36
lines changed

.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: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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 (linux)
8+
if: runner.os == 'Linux'
9+
shell: bash
10+
run: |
11+
LATEST_VERSION=$(gh release view --repo d2learn/xlings --json tagName -q '.tagName')
12+
VERSION_NUM=${LATEST_VERSION#v}
13+
TARBALL="xlings-${VERSION_NUM}-linux-x86_64.tar.gz"
14+
gh release download "$LATEST_VERSION" --repo d2learn/xlings --pattern "$TARBALL" --dir /tmp
15+
mkdir -p "$HOME/.xlings"
16+
tar -xzf "/tmp/$TARBALL" -C "$HOME/.xlings" --strip-components=1
17+
"$HOME/.xlings/bin/xlings" self install
18+
env:
19+
GH_TOKEN: ${{ github.token }}
20+
21+
- name: Setup (macos)
22+
if: runner.os == 'macOS'
23+
shell: bash
24+
run: |
25+
LATEST_VERSION=$(gh release view --repo d2learn/xlings --json tagName -q '.tagName')
26+
VERSION_NUM=${LATEST_VERSION#v}
27+
ARCH=$(uname -m)
28+
TARBALL="xlings-${VERSION_NUM}-macosx-${ARCH}.tar.gz"
29+
gh release download "$LATEST_VERSION" --repo d2learn/xlings --pattern "$TARBALL" --dir /tmp
30+
mkdir -p "$HOME/.xlings"
31+
tar -xzf "/tmp/$TARBALL" -C "$HOME/.xlings" --strip-components=1
32+
xattr -dr com.apple.quarantine "$HOME/.xlings" 2>/dev/null || true
33+
"$HOME/.xlings/bin/xlings" self install
34+
env:
35+
GH_TOKEN: ${{ github.token }}
36+
37+
- name: Setup (windows)
38+
if: runner.os == 'Windows'
39+
shell: pwsh
40+
run: irm https://raw.githubusercontent.com/d2learn/xlings/refs/heads/main/tools/other/quick_install.ps1 | iex
41+
42+
- name: Install toolchain (linux)
43+
if: runner.os == 'Linux'
44+
shell: bash
45+
run: |
46+
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
47+
xlings install gcc@15 -y
48+
49+
- name: Install toolchain (macos)
50+
if: runner.os == 'macOS'
51+
shell: bash
52+
run: |
53+
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
54+
xlings install llvm@20 -y

.github/workflows/ci.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
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+
build:
52+
needs: detect-changes
53+
if: >-
54+
needs.detect-changes.outputs.templates == 'true' ||
55+
needs.detect-changes.outputs.cmdline == 'true' ||
56+
needs.detect-changes.outputs.llmapi == 'true' ||
57+
needs.detect-changes.outputs.lua == 'true'
58+
strategy:
59+
fail-fast: false
60+
matrix:
61+
include:
62+
- { os: ubuntu-24.04, shell: bash }
63+
- { os: macos-15, shell: bash }
64+
- { os: windows-latest, shell: pwsh }
65+
runs-on: ${{ matrix.os }}
66+
name: build (${{ matrix.os }})
67+
steps:
68+
- uses: actions/checkout@v4
69+
- uses: ./.github/actions/setup-toolchain
70+
71+
- name: Configure (linux)
72+
if: runner.os == 'Linux'
73+
working-directory: tests
74+
run: |
75+
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
76+
xmake f -P . -y
77+
78+
- name: Configure (macos)
79+
if: runner.os == 'macOS'
80+
working-directory: tests
81+
run: |
82+
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
83+
xmake f -P . -y --toolchain=llvm
84+
85+
- name: Configure (windows)
86+
if: runner.os == 'Windows'
87+
working-directory: tests
88+
run: |
89+
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
90+
xmake f -P . -y
91+
92+
# templates
93+
- name: templates (unix)
94+
if: runner.os != 'Windows' && needs.detect-changes.outputs.templates == 'true'
95+
working-directory: tests
96+
run: |
97+
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
98+
xmake build -P . -y templates_test
99+
xmake run -P . templates_test
100+
- name: templates (windows)
101+
if: runner.os == 'Windows' && needs.detect-changes.outputs.templates == 'true'
102+
working-directory: tests
103+
run: |
104+
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
105+
xmake build -P . -y templates_test
106+
xmake run -P . templates_test
107+
108+
# cmdline
109+
- name: cmdline (unix)
110+
if: runner.os != 'Windows' && needs.detect-changes.outputs.cmdline == 'true'
111+
working-directory: tests
112+
run: |
113+
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
114+
xmake build -P . -y cmdline_test
115+
xmake run -P . cmdline_test test_input
116+
- name: cmdline (windows)
117+
if: runner.os == 'Windows' && needs.detect-changes.outputs.cmdline == 'true'
118+
working-directory: tests
119+
run: |
120+
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
121+
xmake build -P . -y cmdline_test
122+
xmake run -P . cmdline_test test_input
123+
124+
# llmapi (build only, needs API key to run)
125+
- name: llmapi (unix)
126+
if: runner.os != 'Windows' && needs.detect-changes.outputs.llmapi == 'true'
127+
working-directory: tests
128+
run: |
129+
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
130+
xmake build -P . -y llmapi_test
131+
- name: llmapi (windows)
132+
if: runner.os == 'Windows' && needs.detect-changes.outputs.llmapi == 'true'
133+
working-directory: tests
134+
run: |
135+
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
136+
xmake build -P . -y llmapi_test
137+
138+
# lua
139+
- name: lua (unix)
140+
if: runner.os != 'Windows' && needs.detect-changes.outputs.lua == 'true'
141+
working-directory: tests
142+
run: |
143+
export PATH="$HOME/.xlings/subos/current/bin:$PATH"
144+
xmake build -P . -y lua_test
145+
xmake run -P . lua_test
146+
- name: lua (windows)
147+
if: runner.os == 'Windows' && needs.detect-changes.outputs.lua == 'true'
148+
working-directory: tests
149+
run: |
150+
$env:PATH = "$env:USERPROFILE\.xlings\subos\current\bin;$env:PATH"
151+
xmake build -P . -y lua_test
152+
xmake run -P . lua_test

packages/l/llmapi/xmake.lua

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,10 @@ package("llmapi")
1414

1515
add_versions("0.0.1", "174f86d3afdf48a57ad1cc9688718d1f1100a78a7e56686c823c573c3ccf99f4")
1616

17-
add_configs("capi", {description = "Link with llmapi_c (C API) by default", default = false, type = "boolean"})
18-
1917
add_includedirs("include")
2018
add_deps("libcurl 8.11.0")
2119

2220
on_load(function (package)
23-
if package:config("capi") then
24-
package:add("links", "llmapi_c")
25-
end
2621
package:add("links", "llmapi")
2722
end)
2823

tests/l/llmapi/capi/main.c

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

tests/l/llmapi/capi/xmake.lua

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

tests/xmake.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
add_repositories("mcpplibs-index ../")
22

33
includes("l/llmapi")
4-
includes("l/llmapi/capi")
54
includes("l/lua")
65
includes("c/cmdline")
76
includes("t/templates")

0 commit comments

Comments
 (0)