Skip to content

Commit dc933d4

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

File tree

5 files changed

+139
-0
lines changed

5 files changed

+139
-0
lines changed

.github/plugins.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
{
11+
"key": "manylinux_2_28_x86_64"
12+
},
13+
{
14+
"key": "ubuntu_2004_x86_64"
15+
}
16+
]
17+
},
18+
{
19+
"plugin": "wasi_nn-openvino",
20+
"dir": "wasi_nn",
21+
"target": "wasmedgePluginWasiNN",
22+
"test": "wasiNNTests",
23+
"options": "-DWASMEDGE_PLUGIN_WASI_NN_BACKEND=OpenVINO",
24+
"platforms": [
25+
{
26+
"key": "ubuntu_2004_x86_64"
27+
}
28+
]
29+
}
30+
],
31+
"platforms": {
32+
"manylinux_2_28_x86_64": {
33+
"runner": "ubuntu-latest",
34+
"docker_tag": "manylinux_2_28_x86_64-plugins-deps",
35+
"asset_tag": "manylinux_2_28_x86_64"
36+
}
37+
}
38+
}

.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, def] of Object.entries(config.platforms)) {
4+
map.set(key, config.plugins
5+
.map((plugin) => {
6+
let platform = plugin.platforms.find((platform) => platform.key == key);
7+
if (undefined == platform)
8+
return undefined;
9+
let copy = { ...plugin, ...def };
10+
delete copy.platforms;
11+
copy.options = [plugin.options, platform.options].join(" ");
12+
return copy;
13+
})
14+
.filter((plugin) => undefined != plugin));
15+
}
16+
return 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(config.get("manylinux_2_28_x86_64"));
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 = Object.fromEntries(parse(JSON.parse(s)));
26+
console.log(JSON.stringify(config));
27+
core.setOutput("plugins", config);

0 commit comments

Comments
 (0)