Add CI and a workflow to sync the WIT submodule
This commit is contained in:
parent
28c3e929ca
commit
00bae41ebd
62
.github/workflows/main.yml
vendored
Normal file
62
.github/workflows/main.yml
vendored
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
name: Main
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
workflow_run:
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
workflows:
|
||||||
|
- "Update WIT"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
main:
|
||||||
|
name: Build and test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
|
||||||
|
- name: Set up Zig
|
||||||
|
uses: mlugg/setup-zig@v2
|
||||||
|
with:
|
||||||
|
version: 0.16.0
|
||||||
|
|
||||||
|
- name: Set up wasm-tools
|
||||||
|
uses: bytecodealliance/actions/wasm-tools/setup@v1
|
||||||
|
with:
|
||||||
|
# The generated src/plugin.wit is printed by wasm-tools, keep this in
|
||||||
|
# sync with what `zig build gen` was last run with.
|
||||||
|
version: "1.259.0"
|
||||||
|
|
||||||
|
- name: Format
|
||||||
|
run: zig fmt --check build.zig src tools example
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: zig build test --summary all
|
||||||
|
|
||||||
|
- name: Generated bindings are up to date
|
||||||
|
run: |
|
||||||
|
set -eux
|
||||||
|
zig build gen
|
||||||
|
git diff --exit-code -- src
|
||||||
|
|
||||||
|
- name: Compile every binding
|
||||||
|
run: zig build check
|
||||||
|
|
||||||
|
- name: Build example
|
||||||
|
run: |
|
||||||
|
set -eux
|
||||||
|
zig build
|
||||||
|
wasm-tools validate zig-out/pumpkin-plugin-example.wasm
|
||||||
|
|
||||||
|
- name: Upload example
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: pumpkin-plugin-example
|
||||||
|
path: zig-out/pumpkin-plugin-example.wasm
|
||||||
65
.github/workflows/update-wit.yml
vendored
Normal file
65
.github/workflows/update-wit.yml
vendored
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
name: Update WIT
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-wit:
|
||||||
|
name: Update WIT
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
|
||||||
|
- name: Set up Zig
|
||||||
|
uses: mlugg/setup-zig@v2
|
||||||
|
with:
|
||||||
|
version: 0.16.0
|
||||||
|
|
||||||
|
- name: Set up wasm-tools
|
||||||
|
uses: bytecodealliance/actions/wasm-tools/setup@v1
|
||||||
|
with:
|
||||||
|
# The generated src/plugin.wit is printed by wasm-tools, keep this in
|
||||||
|
# sync with what `zig build gen` was last run with.
|
||||||
|
version: "1.259.0"
|
||||||
|
|
||||||
|
- name: Update submodule
|
||||||
|
id: update_submodule
|
||||||
|
run: |
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
cd wit
|
||||||
|
git fetch origin master
|
||||||
|
git checkout FETCH_HEAD
|
||||||
|
|
||||||
|
echo "wit_commit=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Regenerate bindings
|
||||||
|
run: |
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
zig build gen
|
||||||
|
zig build test
|
||||||
|
zig build check
|
||||||
|
zig build
|
||||||
|
|
||||||
|
- name: Commit
|
||||||
|
run: |
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
witCommit='${{ steps.update_submodule.outputs.wit_commit }}'
|
||||||
|
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
|
git add wit src
|
||||||
|
if git diff --cached --quiet; then
|
||||||
|
echo "already up to date"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
git commit -m "Sync to Pumpkin-MC/pumpkin-plugin-wit@${witCommit}"
|
||||||
|
git push
|
||||||
Loading…
Reference in New Issue
Block a user