diff --git a/.github/scripts/wasm_stdlib.js b/.github/scripts/wasm_stdlib.js new file mode 100644 index 00000000..e1350094 --- /dev/null +++ b/.github/scripts/wasm_stdlib.js @@ -0,0 +1,25 @@ +module.exports = async ({ github, context, core }) => { + if (context.eventName !== 'pull_request') return; + + const prNumber = context.payload.pull_request.number; + const owner = context.repo.owner; + const repo = context.repo.repo; + + const { data: files } = await github.rest.pulls.listFiles({ + owner, + repo, + pull_number: prNumber + }); + + const changedFiles = files.map(file => file.filename); + + const wasmStdLibSrc = 'crates/language/wasm/'; + const dirChanged = changedFiles.some(file => file.startsWith(wasmStdLibSrc)); + + if (!dirChanged) return; + + const wasmStdLibHeader = 'lib/src/wasm/wasm-stdlib.h'; + const requiredChanged = changedFiles.includes(wasmStdLibHeader); + + if (!requiredChanged) core.setFailed(`Changes detected in ${wasmStdLibSrc} but ${wasmStdLibHeader} was not modified.`); +}; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 97a7e378..a60c93f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,3 +44,6 @@ jobs: build: uses: ./.github/workflows/build.yml + + check-wasm-stdlib: + uses: ./.github/workflows/wasm_stdlib.yml diff --git a/.github/workflows/wasm_stdlib.yml b/.github/workflows/wasm_stdlib.yml new file mode 100644 index 00000000..3e7ee0cc --- /dev/null +++ b/.github/workflows/wasm_stdlib.yml @@ -0,0 +1,19 @@ +name: Check Wasm Stdlib build + +on: + workflow_call: + +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Check directory changes + uses: actions/github-script@v7 + with: + script: | + const scriptPath = `${process.env.GITHUB_WORKSPACE}/.github/scripts/wasm_stdlib.js`; + const script = require(scriptPath); + return script({ github, context, core });