diff --git a/.github/actions/set-swap-space/action.yml b/.github/actions/set-swap-space/action.yml new file mode 100644 index 00000000..18edf322 --- /dev/null +++ b/.github/actions/set-swap-space/action.yml @@ -0,0 +1,29 @@ +name: Set swap space +description: Replace the runner's swap with a swap file of the given size +inputs: + swap-size-gb: + description: Size of the swap file in GiB + required: true +runs: + using: composite + steps: + # Hosted images differ: some ship /swapfile, some ship no swap at all. Turn off whatever is + # active, then create the file at the path the image used, or /swapfile when there was none. + - shell: bash + env: + SWAP_SIZE_GB: ${{ inputs.swap-size-gb }} + run: | + set -euo pipefail + active="$(swapon --show=NAME --noheadings)" + swap_file="$(printf '%s\n' "$active" | grep '^/' | tail -n 1 || true)" + swap_file="${swap_file:-/swapfile}" + if [ -n "$active" ]; then + printf '%s\n' "$active" | xargs -r -n1 sudo swapoff + fi + sudo rm -f "$swap_file" + sudo fallocate -l "${SWAP_SIZE_GB}G" "$swap_file" + sudo chmod 600 "$swap_file" + sudo mkswap "$swap_file" + sudo swapon "$swap_file" + free -h + swapon --show diff --git a/.github/workflows/apk.yml b/.github/workflows/apk.yml index 500136c3..ccefc7c8 100644 --- a/.github/workflows/apk.yml +++ b/.github/workflows/apk.yml @@ -443,14 +443,14 @@ jobs: max-parallel: 20 matrix: ${{ fromJSON(needs.trace-cases.outputs.android) }} steps: - - name: Set swap space - uses: pierotofy/set-swap-space@v1.0 - with: - swap-size-gb: 8 - - name: Checkout repo uses: actions/checkout@v6 + - name: Set swap space + uses: ./.github/actions/set-swap-space + with: + swap-size-gb: 8 + - name: Download trace fixture uses: actions/download-artifact@v8 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0158ca95..79451080 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,16 +54,16 @@ jobs: CCACHE_NOHASHDIR: "true" steps: - - name: Set swap space - uses: pierotofy/set-swap-space@v1.0 - with: - swap-size-gb: 32 - - name: Checkout repo uses: actions/checkout@v6 with: submodules: recursive + - name: Set swap space + uses: ./.github/actions/set-swap-space + with: + swap-size-gb: 32 + - name: Configure runner environment uses: ./.github/actions/setup-test-runner @@ -252,15 +252,16 @@ jobs: CCACHE_COMPRESS: "true" CCACHE_NOHASHDIR: "true" steps: - - name: Set swap space - uses: pierotofy/set-swap-space@v1.0 - with: - swap-size-gb: 32 - - name: Checkout repo uses: actions/checkout@v6 with: submodules: recursive + + - name: Set swap space + uses: ./.github/actions/set-swap-space + with: + swap-size-gb: 32 + - name: Configure runner environment uses: ./.github/actions/setup-test-runner @@ -610,16 +611,16 @@ jobs: CCACHE_NOHASHDIR: "true" steps: - - name: Set swap space - uses: pierotofy/set-swap-space@v1.0 - with: - swap-size-gb: 32 - - name: Checkout repo uses: actions/checkout@v6 with: submodules: recursive + - name: Set swap space + uses: ./.github/actions/set-swap-space + with: + swap-size-gb: 32 + - name: Configure runner environment uses: ./.github/actions/setup-test-runner @@ -1322,7 +1323,7 @@ jobs: - name: Set swap space if: env.SPLIT_REUSE != 'true' - uses: pierotofy/set-swap-space@v1.0 + uses: ./.github/actions/set-swap-space with: swap-size-gb: 32 @@ -2530,16 +2531,16 @@ jobs: MOBILEGL_LIBRARY: ${{ github.workspace }}/build-linux/libMobileGL.so steps: - - name: Set swap space - uses: pierotofy/set-swap-space@v1.0 - with: - swap-size-gb: 32 - - name: Checkout repo uses: actions/checkout@v6 with: submodules: recursive + - name: Set swap space + uses: ./.github/actions/set-swap-space + with: + swap-size-gb: 32 + - name: Configure runner environment uses: ./.github/actions/setup-test-runner @@ -2829,15 +2830,15 @@ jobs: matrix: ${{ fromJSON(needs.trace-cases.outputs.matrix) }} steps: - - name: Set swap space - if: runner.environment != 'self-hosted' - uses: pierotofy/set-swap-space@v1.0 - with: - swap-size-gb: 16 - - name: Checkout repo uses: actions/checkout@v6 + - name: Set swap space + if: runner.environment != 'self-hosted' + uses: ./.github/actions/set-swap-space + with: + swap-size-gb: 16 + - name: Configure runner environment uses: ./.github/actions/setup-test-runner with: @@ -3070,15 +3071,15 @@ jobs: matrix: ${{ fromJSON(needs.trace-cases.outputs.verify-matrix) }} steps: - - name: Set swap space - if: runner.environment != 'self-hosted' - uses: pierotofy/set-swap-space@v1.0 - with: - swap-size-gb: 16 - - name: Checkout repo uses: actions/checkout@v6 + - name: Set swap space + if: runner.environment != 'self-hosted' + uses: ./.github/actions/set-swap-space + with: + swap-size-gb: 16 + - name: Configure runner environment uses: ./.github/actions/setup-test-runner with: @@ -3262,15 +3263,15 @@ jobs: matrix: ${{ fromJSON(needs.build-guard.outputs.verdict == 'identical' && needs.trace-cases.outputs.split-spawn-matrix || needs.trace-cases.outputs.split-matrix) }} steps: - - name: Set swap space - if: runner.environment != 'self-hosted' - uses: pierotofy/set-swap-space@v1.0 - with: - swap-size-gb: 16 - - name: Checkout repo uses: actions/checkout@v6 + - name: Set swap space + if: runner.environment != 'self-hosted' + uses: ./.github/actions/set-swap-space + with: + swap-size-gb: 16 + # build-linux's build when build-guard proved the two configurations identical, # build-linux-split's otherwise; integration-split prints the guard's evidence. A build-linux # that is not Release is never reused (scripts/ci/split_reuse_build_type.sh). @@ -3498,15 +3499,15 @@ jobs: case: [OpenRA] steps: - - name: Set swap space - if: runner.environment != 'self-hosted' - uses: pierotofy/set-swap-space@v1.0 - with: - swap-size-gb: 16 - - name: Checkout repo uses: actions/checkout@v6 + - name: Set swap space + if: runner.environment != 'self-hosted' + uses: ./.github/actions/set-swap-space + with: + swap-size-gb: 16 + - name: Configure runner environment uses: ./.github/actions/setup-test-runner with: @@ -3828,11 +3829,6 @@ jobs: CCACHE_NOHASHDIR: "true" steps: - - name: Set swap space - uses: pierotofy/set-swap-space@v1.0 - with: - swap-size-gb: 32 - - name: Checkout repo uses: actions/checkout@v6 with: @@ -3840,6 +3836,11 @@ jobs: # back to OFF when 3rdparty/flatbuffers/include is missing. submodules: recursive + - name: Set swap space + uses: ./.github/actions/set-swap-space + with: + swap-size-gb: 32 + - name: Configure runner environment uses: ./.github/actions/setup-test-runner