diff --git a/.github/workflows/package-npm.yml b/.github/workflows/package-npm.yml index 29b17d5..4c05915 100644 --- a/.github/workflows/package-npm.yml +++ b/.github/workflows/package-npm.yml @@ -23,6 +23,14 @@ on: description: The tree-sitter ABI version default: 15 type: number + swap-size: + description: > + Resize the runner swap space before the Wasm build. + Set to a size such as "64G" to allocate that much swap, or leave + as "normal" (the default) to skip the resize entirely. + Useful for grammars whose Wasm compilation exceeds available memory. + default: normal + type: string secrets: NODE_AUTH_TOKEN: description: An authentication token for npm @@ -57,6 +65,17 @@ jobs: done < <(jq -r '.grammars[].path // "."' tree-sitter.json) env: TREE_SITTER_ABI_VERSION: ${{inputs.abi-version}} + - name: Increase swap space + if: inputs.swap-size != 'normal' + run: | + sudo swapoff -a + sudo fallocate -l "$SWAP_SIZE" /swapfile + sudo chmod 600 /swapfile + sudo mkswap /swapfile + sudo swapon /swapfile + sudo swapon --show + env: + SWAP_SIZE: ${{inputs.swap-size}} - name: Build Wasm binaries run: |- while read -r grammar_dir; do diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a7363a..0d4048b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,6 +14,14 @@ on: description: The tree-sitter ABI version default: 15 type: number + swap-size: + description: > + Resize the runner swap space before the Wasm build. + Set to a size such as "64G" to allocate that much swap, or leave + as "normal" (the default) to skip the resize entirely. + Useful for grammars whose Wasm compilation exceeds available memory. + default: normal + type: string permissions: contents: write @@ -54,6 +62,17 @@ jobs: done < <(jq -r '.grammars[].path // "."' tree-sitter.json) env: TREE_SITTER_ABI_VERSION: ${{inputs.abi-version}} + - name: Increase swap space + if: inputs.swap-size != 'normal' + run: | + sudo swapoff -a + sudo fallocate -l "$SWAP_SIZE" /swapfile + sudo chmod 600 /swapfile + sudo mkswap /swapfile + sudo swapon /swapfile + sudo swapon --show + env: + SWAP_SIZE: ${{inputs.swap-size}} - name: Build Wasm binaries shell: bash run: |-