Skip to content

Commit c7052eb

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 590151b commit c7052eb

File tree

4 files changed

+173
-0
lines changed

4 files changed

+173
-0
lines changed

.github/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Misc Docs
2+
3+
## Configuration Files
4+
5+
### `plugins.json`
6+
7+
```json
8+
{
9+
"plugins": {
10+
"<plugin-name>": {
11+
"dir": "<path-to-plugin>",
12+
"target": "<cmake-target-for-plugin>",
13+
"test": "<cmake-target-for-test>",
14+
"options": "<cmake-options>",
15+
"platforms": [
16+
{
17+
"key": "<platform-key>"
18+
},
19+
{
20+
"key": "<platform-key>",
21+
"options": <extra-cmake-options>"
22+
},
23+
{
24+
"key": "<platform-key>",
25+
"options": <extra-cmake-options>",
26+
"plugin_tag": "<extra-tag-for-plugin>"
27+
}
28+
}
29+
}
30+
},
31+
"platforms": {
32+
"<platform-key>": {
33+
"runner": "<github-runner>",
34+
"docker_tag": "<docker-tag>",
35+
"asset_tag": "<asset-tag>"
36+
}
37+
}
38+
}
39+
```

.github/plugins.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"plugins": {
3+
"wasi_crypto": {
4+
"dir": "wasi_crypto",
5+
"target": "wasmedgePluginWasiCrypto",
6+
"test": "wasiCryptoTests",
7+
"options": "-DWASMEDGE_PLUGIN_WASI_CRYPTO=ON",
8+
"platforms": [
9+
{"key":"manylinux_2_28_x86_64"},
10+
{"key":"ubuntu2004_x86_64"}
11+
]
12+
},
13+
"wasi_nn-openvino": {
14+
"dir": "wasi_nn",
15+
"target": "wasmedgePluginWasiNN",
16+
"test": "wasiNNTests",
17+
"options": "-DWASMEDGE_PLUGIN_WASI_NN_BACKEND=OpenVINO",
18+
"platforms": [
19+
{"key":"ubuntu2004_x86_64"}
20+
]
21+
},
22+
"wasmedge_stablediffusion": {
23+
"dir": "wasmedge_stablediffusion",
24+
"target": "wasmedgePluginWasmEdgeStableDiffusion",
25+
"test": "wasmedgeStableDiffusionTests",
26+
"options": "-DWASMEDGE_PLUGIN_STABLEDIFFUSION=ON",
27+
"platforms": [
28+
{"key":"manylinux_2_28_x86_64"},
29+
{"key":"ubuntu2004_x86_64"},
30+
{
31+
"key":"ubuntu2004_cuda11",
32+
"options": "-DWASMEDGE_PLUGIN_STABLEDIFFUSION_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES='60;61;70' -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc",
33+
"plugin_tag": "cuda-11"
34+
}
35+
]
36+
}
37+
},
38+
"platforms": {
39+
"manylinux_2_28_x86_64": {
40+
"runner": "ubuntu-latest",
41+
"docker_tag": "manylinux_2_28_x86_64-plugins-deps",
42+
"asset_tag": "manylinux_2_28_x86_64"
43+
},
44+
"ubuntu2004_x86_64": {
45+
"runner": "ubuntu-latest",
46+
"docker_tag": "ubuntu-20.04-plugin-deps",
47+
"asset_tag": "ubuntu20.04_x86_64"
48+
},
49+
"ubuntu2004_cuda11": {
50+
"runner": "ubuntu-latest",
51+
"docker_tag": "ubuntu-20.04-cuda11",
52+
"asset_tag": "ubuntu20.04_x86_64"
53+
}
54+
}
55+
}

.github/scripts/parse-plugins.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module.exports.parse = (config) => {
2+
let map = new Map();
3+
for (const platform_key of Object.keys(config.platforms)) {
4+
map.set(platform_key, []);
5+
}
6+
for (const [plugin_key, plugin] of Object.entries(config.plugins)) {
7+
for (const platform of plugin.platforms) {
8+
if (!(platform.key in config.platforms))
9+
continue;
10+
let copy = { ...plugin, ...config.platforms[platform.key] };
11+
delete copy.platforms;
12+
copy.plugin = plugin_key;
13+
copy.plugin_tag = platform.plugin_tag;
14+
copy.options = [plugin.options, platform.options].join(" ");
15+
map.get(platform.key).push(copy);
16+
}
17+
}
18+
return Object.fromEntries(map);
19+
};
20+
21+
if (require.main === module) {
22+
const { parse } = module.exports;
23+
const fs = require("fs");
24+
const s = fs.readFileSync("plugins.json");
25+
const o = JSON.parse(s);
26+
console.log(JSON.stringify(parse(o)));
27+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
name: Parse
3+
4+
on:
5+
pull_request:
6+
branches: [main]
7+
paths:
8+
- '.github/plugins.json'
9+
- '.github/scripts/parse-plugins.js'
10+
- '.github/workflows/parse-plugins.yml'
11+
12+
workflow_call:
13+
inputs:
14+
workflow_call: # workaround to distinguish ${{ github.event }}
15+
type: boolean
16+
default: true
17+
outputs:
18+
plugins:
19+
value: ${{ jobs.parse.outputs.plugins }}
20+
21+
jobs:
22+
parse:
23+
name: Parse configuration file
24+
runs-on: ubuntu-latest
25+
outputs:
26+
plugins: ${{ steps.readfile.outputs.plugins }}
27+
steps:
28+
- uses: actions/checkout@v4
29+
- id: readfile
30+
uses: actions/github-script@v7
31+
with:
32+
result-encoding: string
33+
script: |
34+
const { parse } = require(".github/scripts/parse-plugins.js");
35+
const fs = require("fs");
36+
const s = fs.readFileSync(".github/plugins.json");
37+
const config = parse(JSON.parse(s));
38+
core.setOutput("plugins", config);
39+
40+
test:
41+
if: ${{ !inputs.workflow_call }}
42+
needs: parse
43+
name: Self-testing
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Get the first target from ubuntu2004_cuda11
47+
run: |
48+
echo "target=${{ fromJSON(needs.parse.outputs.plugins).ubuntu2004_cuda11[0].target }}" >> "${GITHUB_ENV}"
49+
- name: Check target
50+
run: |
51+
echo "${target}"
52+
test "${target}" = 'wasmedgePluginWasmEdgeStableDiffusion'

0 commit comments

Comments
 (0)