Skip to content

Commit

Permalink
ci(wip): build plugins
Browse files Browse the repository at this point in the history
Signed-off-by: Yi Huang <[email protected]>
  • Loading branch information
0yi0 committed Jan 10, 2025
1 parent 4216eb7 commit d417999
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/plugins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"plugins": [
{
"plugin": "wasi_crypto",
"dir": "wasi_crypto",
"target": "wasmedgePluginWasiCrypto",
"test": "wasiCryptoTests",
"options": "-DWASMEDGE_PLUGIN_WASI_CRYPTO=ON",
"platforms": [
{
"key": "manylinux_2_28_x86_64"
},
{
"key": "ubuntu_2004_x86_64"
}
]
},
{
"plugin": "wasi_nn-openvino",
"dir": "wasi_nn",
"target": "wasmedgePluginWasiNN",
"test": "wasiNNTests",
"options": "-DWASMEDGE_PLUGIN_WASI_NN_BACKEND=OpenVINO",
"platforms": [
{
"key": "ubuntu_2004_x86_64"
}
]
}
],
"platforms": {
"manylinux_2_28_x86_64": {
"runner": "ubuntu-latest",
"docker_tag": "manylinux_2_28_x86_64-plugins-deps",
"asset_tag": "manylinux_2_28_x86_64"
}
}
}
26 changes: 26 additions & 0 deletions .github/scripts/parse-plugins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports.parse = (config) => {
let map = new Map();
for (const [key, def] of Object.entries(config.platforms)) {
map.set(key, config.plugins
.map((plugin) => {
let platform = plugin.platforms.find((platform) => platform.key == key);
if (undefined == platform)
return undefined;
let copy = { ...plugin, ...def };
delete copy.platforms;
copy.options = [plugin.options, platform.options].join(" ");
return copy;
})
.filter((plugin) => undefined != plugin));
}
return map;
};

if (require.main === module) {
const { parse } = module.exports;
const fs = require("fs");
const s = fs.readFileSync("plugins.json");
const o = JSON.parse(s);
let config = parse(o);
console.log(config.get("manylinux_2_28_x86_64"));
}
18 changes: 18 additions & 0 deletions .github/workflows/build-on-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Build on Linux

on:
workflow_call:
inputs:
plugin:
type: string
required: true

permissions: {}

jobs:
echo:
runs-on: ubuntu-latest
steps:
- run: |
echo "${{ inputs.plugin }}"
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Build

on:
pull_request:
branches: [main]

permissions: {}

jobs:
parse:
uses: ./.github/workflows/parse-plugins.yml

echo:
needs: parse
runs-on: ubuntu-latest
steps:
- run: |
echo "${{ needs.parse.outputs.plugins }}"
manylinux_2_28:
needs: parse
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.parse.outputs.plugins).manylinux_2_28_x86_64 }}
uses: ./.github/workflows/build-on-linux.yml
with:
plugin: ${{ matrix.plugin }}
secrets: inherit
27 changes: 27 additions & 0 deletions .github/workflows/parse-plugins.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Parse plugins

on:
workflow_call:
outputs:
plugins:
value: ${{ jobs.parse.outputs.plugins }}

jobs:
parse:
runs-on: ubuntu-latest
outputs:
plugins: ${{ steps.readfile.outputs.plugins }}
steps:
- uses: actions/checkout@v4
- id: readfile
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { parse } = require(".github/scripts/parse-plugins.js");
const fs = require("fs");
const s = fs.readFileSync(".github/plugins.json");
const config = parse(JSON.parse(s));
console.log(JSON.stringify(config));
core.setOutput("plugins", config);

0 comments on commit d417999

Please sign in to comment.