diff --git a/.github/workflows/llhttp-wasm-integrity.yml b/.github/workflows/llhttp-wasm-integrity.yml new file mode 100644 index 00000000000..fb4ebf895a4 --- /dev/null +++ b/.github/workflows/llhttp-wasm-integrity.yml @@ -0,0 +1,61 @@ +name: Ensure integrity of llhttp wasm files +on: + workflow_call: + +permissions: + contents: read + +jobs: + check: + name: Check files + if: ${{ github.event_name == 'pull_request' }} + outputs: + run_job: ${{ steps.check_files.outputs.run_job }} + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Check modified files + id: check_files + run: | + echo "=============== list modified files ===============" + git diff --name-only ${{ github.event.pull_request.base.sha }} HEAD + + echo "========== check paths of modified files ==========" + git diff --name-only ${{ github.event.pull_request.base.sha }} HEAD > files.txt + + echo "run_job=false" > "$GITHUB_OUTPUT" + + while IFS= read -r file + do + if [[ $file == deps/llhttp/* || $file == lib/llhttp/llhttp* ]]; then + echo "run_job=true" > "$GITHUB_OUTPUT" + fi + done < files.txt + + echo "GITHUB_OUTPUT: $(cat $GITHUB_OUTPUT)" + + llhttp-wasm: + if: ${{ github.event_name == 'pull_request' && needs.check.outputs.run_job == 'true' }} + name: Check integrity of generated wasm-files for llhttp + needs: check + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build wasm of llhttp + run: | + npm run prebuild:wasm && + npm run build:wasm + - name: Integrity Check + run: | + git diff --quiet lib/llhttp* + if [ $? -eq 0 ]; then + echo "No changes in the generated wasm files." + else + echo "Changes detected in the generated wasm files." + echo "Please run 'npm run prebuild:wasm' and 'npm run build:wasm' locally and commit the changes." + exit 1 + fi diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index b6f2936573d..4d673fccc8e 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -181,6 +181,10 @@ jobs: - name: Run typings tests run: npm run test:typescript + test-llhttp-integrity: + name: Ensure integrity of llhttp wasm files + uses: nodejs/undici/.github/workflows/llhttp-wasm-integrity.yml@main + automerge: if: > github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' @@ -190,6 +194,7 @@ jobs: - test-types - test-without-intl - test-fuzzing + - test-llhttp-integrity - lint runs-on: ubuntu-latest permissions: diff --git a/build/wasm.js b/build/wasm.js index 9c88427874a..14cdcfa7c92 100644 --- a/build/wasm.js +++ b/build/wasm.js @@ -59,7 +59,7 @@ if (process.argv[2] === '--prebuild') { } if (process.argv[2] === '--docker') { - let cmd = `docker run --rm -it --platform=${platform.toString().trim()}` + let cmd = `docker run --rm -t --platform=${platform.toString().trim()}` if (process.platform === 'linux') { cmd += ` --user ${process.getuid()}:${process.getegid()}` }