From 0f8d681954866d54b93189821aa02008fe5ce794 Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Mon, 18 Dec 2023 14:27:27 +0100 Subject: [PATCH] [CI] Don't update file while reading it The pattern is 'cat <<< $(echo < input-file.txt) > input-file.txt' which makes no guarantee that the input file isn't being clobbered while we still being read. Fix it by creating a temporary copy. --- .github/workflows/base-windows.yml | 6 ++++-- .github/workflows/base.yml | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/base-windows.yml b/.github/workflows/base-windows.yml index 2483bb4d309a..07715bab36f7 100644 --- a/.github/workflows/base-windows.yml +++ b/.github/workflows/base-windows.yml @@ -468,7 +468,8 @@ jobs: if: startsWith(matrix.os-name, 'windows') shell: bash run: | - cat <<< $(jq '.HttpHeaders += {"User-Agent": "Mandrel-CI-Docker-Client"}' ~/.docker/config.json) > ~/.docker/config.json + cat <<< $(jq '.HttpHeaders += {"User-Agent": "Mandrel-CI-Docker-Client"}' ~/.docker/config.json) > ~/.docker/config.json.new + mv ~/.docker/config.json.new ~/.docker/config.json - name: Change quarkus.version for Quarkus 2.2 to make mandrel-integration-test not apply quarkus_main.patch if: startsWith(matrix.os-name, 'windows') # See https://github.com/Karm/mandrel-integration-tests/pull/64 @@ -610,7 +611,8 @@ jobs: - name: Update Docker Client User Agent shell: bash run: | - cat <<< $(jq '.HttpHeaders += {"User-Agent": "Mandrel-CI-Docker-Client"}' ~/.docker/config.json) > ~/.docker/config.json + cat <<< $(jq '.HttpHeaders += {"User-Agent": "Mandrel-CI-Docker-Client"}' ~/.docker/config.json) > ~/.docker/config.json.new + mv ~/.docker/config.json.new ~/.docker/config.json - name: Build with Maven run: | cmd.exe /c "call `"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%\vcvars64.txt" diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 5e7b01aeff0d..5e54959b80a0 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -542,7 +542,8 @@ jobs: if: "!startsWith(matrix.os-name, 'windows')" shell: bash run: | - cat <<< $(jq '.HttpHeaders += {"User-Agent": "Mandrel-CI-Docker-Client"}' ~/.docker/config.json) > ~/.docker/config.json + cat <<< $(jq '.HttpHeaders += {"User-Agent": "Mandrel-CI-Docker-Client"}' ~/.docker/config.json) > ~/.docker/config.json.new + mv ~/.docker/config.json.new ~/.docker/config.json - name: Change quarkus.version for Quarkus 2.2 to make mandrel-integration-test not apply quarkus_main.patch if: "!startsWith(matrix.os-name, 'windows')" # See https://github.com/Karm/mandrel-integration-tests/pull/64 @@ -696,7 +697,8 @@ jobs: tar -xzvf jdk.tgz -C ${GRAALVM_HOME} --strip-components=1 - name: Update Docker Client User Agent run: | - cat <<< $(jq '.HttpHeaders += {"User-Agent": "Mandrel-CI-Docker-Client"}' ~/.docker/config.json) > ~/.docker/config.json + cat <<< $(jq '.HttpHeaders += {"User-Agent": "Mandrel-CI-Docker-Client"}' ~/.docker/config.json) > ~/.docker/config.json.new + mv ~/.docker/config.json.new ~/.docker/config.json - name: Install gdb run: | sudo apt-get update -y @@ -735,4 +737,4 @@ jobs: if: failure() with: name: test-reports-mandrel-it-${{ needs.get-test-matrix.outputs.artifacts-suffix }} - path: 'test-reports-mandrel-it.tgz' \ No newline at end of file + path: 'test-reports-mandrel-it.tgz'