Skip to content

Commit e98d67b

Browse files
committed
ci(wip): build plugins
Signed-off-by: Yi Huang <[email protected]>
1 parent 4216eb7 commit e98d67b

File tree

5 files changed

+150
-0
lines changed

5 files changed

+150
-0
lines changed

.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": {
9+
"base": "-DWASMEDGE_PLUGIN_WASI_CRYPTO=ON",
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": {
20+
"base": "-DWASMEDGE_PLUGIN_WASI_NN_BACKEND=OpenVINO",
21+
"ubuntu_2004_x86_64": {}
22+
}
23+
},
24+
{
25+
"plugin": "wasmedge_stablediffusion",
26+
"dir": "wasmedge_stablediffusion",
27+
"target": "wasmedgePluginWasmEdgeStableDiffusion",
28+
"test": "wasmedgeStableDiffusionTests",
29+
"options": {
30+
"base": "-DWASMEDGE_PLUGIN_STABLEDIFFUSION=ON",
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.options[key];
7+
if (undefined == specific)
8+
return undefined;
9+
let copy = { ...plugin, ...platform };
10+
delete copy.platforms;
11+
copy.options = [plugin.options.base, 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/build-on-linux.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Build on Linux
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
plugin:
8+
type: string
9+
required: true
10+
11+
permissions: {}
12+
13+
jobs:
14+
echo:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- run: |
18+
echo "${{ inputs.plugin }}"

.github/workflows/build.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: Build
3+
4+
on:
5+
pull_request:
6+
branches: [main]
7+
8+
permissions: {}
9+
10+
jobs:
11+
parse:
12+
uses: ./.github/workflows/parse-plugins.yml
13+
14+
echo:
15+
needs: parse
16+
runs-on: ubuntu-latest
17+
steps:
18+
- run: |
19+
echo "${{ needs.parse.outputs.plugins }}"
20+
21+
manylinux_2_28:
22+
needs: parse
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include: ${{ fromJSON(needs.parse.outputs.plugins).manylinux_2_28_x86_64 }}
27+
uses: ./.github/workflows/build-on-linux.yml
28+
with:
29+
plugin: ${{ matrix.plugin }}
30+
secrets: inherit

.github/workflows/parse-plugins.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: Parse plugins
3+
4+
on:
5+
workflow_call:
6+
outputs:
7+
plugins:
8+
value: ${{ jobs.parse.outputs.plugins }}
9+
10+
jobs:
11+
parse:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
plugins: ${{ steps.readfile.outputs.plugins }}
15+
steps:
16+
- uses: actions/checkout@v4
17+
- id: readfile
18+
uses: actions/github-script@v7
19+
with:
20+
result-encoding: string
21+
script: |
22+
const { parse } = require(".github/scripts/parse-plugins.js");
23+
const fs = require("fs");
24+
const s = fs.readFileSync(".github/plugins.json");
25+
const config = parse(JSON.parse(s));
26+
console.log(JSON.stringify(config));
27+
core.setOutput("plugins", config);

0 commit comments

Comments
 (0)