Skip to content

Commit 3d089b7

Browse files
committed
ci: define plugins.json
- add a script to parse `plugins.json` - add workflows to to use and test the script Signed-off-by: Yi Huang <[email protected]>
1 parent 4216eb7 commit 3d089b7

File tree

4 files changed

+142
-0
lines changed

4 files changed

+142
-0
lines changed

.github/README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
### `plugins.json`
2+
3+
```json
4+
{
5+
"plugins": [
6+
{
7+
"plugin": "plugin-name",
8+
"dir": "path-to-plugin",
9+
"target": "cmake-target",
10+
"test": "cmake-target-to-test",
11+
"options": "required-cmake-options",
12+
"platforms": {
13+
"some-os_arch": {},
14+
"another-os_arch": {
15+
"options": "platform-specific-cmake-options"
16+
}
17+
}
18+
],
19+
"platforms": [
20+
"os_arch": {
21+
"runner": "github-runner",
22+
"docker_tag": "wasmedge/wasmedge:tag-here",
23+
"asset_tag": "os-arch"
24+
}
25+
]
26+
}
27+
```

.github/plugins.json

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"plugins": [
3+
{
4+
"plugin": "wasi_crypto",
5+
"dir": "wasi_crypto",
6+
"target": "wasmedgePluginWasiCrypto",
7+
"test": "wasiCryptoTests",
8+
"options": "-DWASMEDGE_PLUGIN_WASI_CRYPTO=ON",
9+
"platforms": {
10+
"manylinux_2_28_x86_64": {},
11+
"ubuntu_2004_x86_64": {}
12+
}
13+
},
14+
{
15+
"plugin": "wasi_nn-openvino",
16+
"dir": "wasi_nn",
17+
"target": "wasmedgePluginWasiNN",
18+
"test": "wasiNNTests",
19+
"options": "-DWASMEDGE_PLUGIN_WASI_NN_BACKEND=OpenVINO",
20+
"platforms": {
21+
"ubuntu_2004_x86_64": {}
22+
}
23+
},
24+
{
25+
"plugin": "wasmedge_stablediffusion",
26+
"dir": "wasmedge_stablediffusion",
27+
"target": "wasmedgePluginWasmEdgeStableDiffusion",
28+
"test": "wasmedgeStableDiffusionTests",
29+
"options": "-DWASMEDGE_PLUGIN_STABLEDIFFUSION=ON",
30+
"platforms": {
31+
"macos_arm64": {
32+
"options": "-DWASMEDGE_PLUGIN_STABLEDIFFUSION_METAL=ON"
33+
},
34+
"manylinux_2_28_x86_64": {}
35+
}
36+
}
37+
],
38+
"platforms": {
39+
"macos_arm64": {
40+
"runner": "macos-14",
41+
"asset_tag": "darwin_23-arm64"
42+
},
43+
"manylinux_2_28_x86_64": {
44+
"runner": "ubuntu-latest",
45+
"docker_tag": "manylinux_2_28_x86_64-plugins-deps",
46+
"asset_tag": "manylinux_2_28_x86_64"
47+
}
48+
}
49+
}

.github/scripts/parse-plugins.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports.parse = (config) => {
2+
let map = new Map();
3+
for (const [key, platform] of Object.entries(config.platforms)) {
4+
map.set(key, config.plugins
5+
.map((plugin) => {
6+
let specific = plugin.platforms[key];
7+
if (undefined == specific)
8+
return undefined;
9+
let copy = { ...plugin, ...platform };
10+
delete copy.platforms;
11+
copy.options = [plugin.options, specific.options].join(" ");
12+
return copy;
13+
})
14+
.filter((plugin) => undefined != plugin));
15+
}
16+
return Object.fromEntries(map);
17+
};
18+
19+
if (require.main === module) {
20+
const { parse } = module.exports;
21+
const fs = require("fs");
22+
const s = fs.readFileSync("plugins.json");
23+
const o = JSON.parse(s);
24+
let config = parse(o);
25+
console.log(JSON.stringify(config));
26+
}

.github/workflows/parse-plugins.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: Parse plugins
3+
4+
on:
5+
pull_request:
6+
branches: [main]
7+
paths:
8+
- '.github/workflows/parse-plugins.yml'
9+
10+
workflow_call:
11+
outputs:
12+
plugins:
13+
value: ${{ jobs.parse.outputs.plugins }}
14+
15+
jobs:
16+
parse:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
plugins: ${{ steps.readfile.outputs.plugins }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
- id: readfile
23+
uses: actions/github-script@v7
24+
with:
25+
result-encoding: string
26+
script: |
27+
const { parse } = require(".github/scripts/parse-plugins.js");
28+
const fs = require("fs");
29+
const s = fs.readFileSync(".github/plugins.json");
30+
const config = parse(JSON.parse(s));
31+
core.setOutput("plugins", config);
32+
33+
test:
34+
if: ${{ github.event_name == 'pull_request' }}
35+
needs: parse
36+
name: Self-testing
37+
runs-on: ubuntu-latest
38+
steps:
39+
- run: |
40+
test $(echo '${{ needs.parse.outputs.plugins }}' | jq '.manylinux_2_28_x86_64[] | select(.plugin == "wasi_crypto") | .test') = "wasiCryptoTests"

0 commit comments

Comments
 (0)