From e3c6d03f033585ff8ee73218b2c38dd7051f3ed9 Mon Sep 17 00:00:00 2001 From: Si Beaumont Date: Fri, 8 Nov 2024 09:57:59 +0000 Subject: [PATCH 1/2] Only run actions/checkout step if not running locally with act --- .github/workflows/soundness.yml | 9 +++++++++ .github/workflows/swift_package_test.yml | 2 ++ 2 files changed, 11 insertions(+) diff --git a/.github/workflows/soundness.yml b/.github/workflows/soundness.yml index 9cedbcf..27f9a57 100644 --- a/.github/workflows/soundness.yml +++ b/.github/workflows/soundness.yml @@ -79,6 +79,7 @@ jobs: timeout-minutes: 20 steps: - name: Checkout repository + if: env.ACT != 'true' uses: actions/checkout@v4 with: persist-credentials: false @@ -100,6 +101,7 @@ jobs: timeout-minutes: 20 steps: - name: Checkout repository + if: env.ACT != 'true' uses: actions/checkout@v4 with: persist-credentials: false @@ -116,6 +118,7 @@ jobs: timeout-minutes: 1 steps: - name: Checkout repository + if: env.ACT != 'true' uses: actions/checkout@v4 with: persist-credentials: false @@ -132,6 +135,7 @@ jobs: timeout-minutes: 1 steps: - name: Checkout repository + if: env.ACT != 'true' uses: actions/checkout@v4 with: persist-credentials: false @@ -148,6 +152,7 @@ jobs: timeout-minutes: 1 steps: - name: Checkout repository + if: env.ACT != 'true' uses: actions/checkout@v4 with: persist-credentials: false @@ -164,6 +169,7 @@ jobs: timeout-minutes: 20 steps: - name: Checkout repository + if: env.ACT != 'true' uses: actions/checkout@v4 with: persist-credentials: false @@ -185,6 +191,7 @@ jobs: timeout-minutes: 5 steps: - name: Checkout repository + if: env.ACT != 'true' uses: actions/checkout@v4 with: persist-credentials: false @@ -204,6 +211,7 @@ jobs: timeout-minutes: 5 steps: - name: Checkout repository + if: env.ACT != 'true' uses: actions/checkout@v4 with: persist-credentials: false @@ -224,6 +232,7 @@ jobs: timeout-minutes: 5 steps: - name: Checkout repository + if: env.ACT != 'true' uses: actions/checkout@v4 with: persist-credentials: false diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 4b5c5ab..5a6bcc7 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -67,6 +67,7 @@ jobs: - name: Swift version run: swift --version - name: Checkout repository + if: env.ACT != 'true' uses: actions/checkout@v4 - name: Set environment variables if: ${{ inputs.linux_env_vars }} @@ -92,6 +93,7 @@ jobs: - ${{ fromJson(inputs.windows_exclude_swift_versions) }} steps: - name: Checkout repository + if: env.ACT != 'true' uses: actions/checkout@v4 - name: Pull Docker image id: pull_docker_image From b3aa618468cd56a1a0d91d80aa1267cb33838421 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Tue, 5 Nov 2024 09:23:03 -0800 Subject: [PATCH 2/2] Include changes to the target branch when action is re-run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a GitHub action is re-run, it uses the same context as the original run. This means that it runs on the exact same merge commit and does not pick up changes done to the base branch since the last run. In case the base branch is was failing when a PR was opened, this means that we can’t get CI to pass by fixing the base branch without pushing a new commit to the PR branch. Adding `ref: ${{ github.ref }}` to the `actions/checkout` action works around this by checking out the PR merge ref (ie. `refs/pull//merge`) instead of a fixed commit and the PR merge ref is updated, as described in https://github.com/actions/checkout/issues/1036. --- .github/workflows/soundness.yml | 9 +++++++++ .github/workflows/swift_package_test.yml | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/.github/workflows/soundness.yml b/.github/workflows/soundness.yml index 27f9a57..480bda2 100644 --- a/.github/workflows/soundness.yml +++ b/.github/workflows/soundness.yml @@ -84,6 +84,7 @@ jobs: with: persist-credentials: false submodules: true + ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036 - name: Mark the workspace as safe # https://github.com/actions/checkout/issues/766 run: git config --global --add safe.directory ${GITHUB_WORKSPACE} @@ -106,6 +107,7 @@ jobs: with: persist-credentials: false submodules: true + ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036 - name: Run documentation check run: | apt-get -qq update && apt-get -qq -y install curl yq @@ -123,6 +125,7 @@ jobs: with: persist-credentials: false submodules: true + ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036 - name: Run unacceptable language check env: UNACCEPTABLE_WORD_LIST: ${{ inputs.unacceptable_language_check_word_list}} @@ -140,6 +143,7 @@ jobs: with: persist-credentials: false submodules: true + ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036 - name: Run license header check env: PROJECT_NAME: ${{ inputs.license_header_check_project_name }} @@ -157,6 +161,7 @@ jobs: with: persist-credentials: false submodules: true + ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036 - name: Run broken symlinks check run: curl -s https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/check-broken-symlinks.sh | bash @@ -174,6 +179,7 @@ jobs: with: persist-credentials: false submodules: true + ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036 - name: Mark the workspace as safe # https://github.com/actions/checkout/issues/766 run: git config --global --add safe.directory ${GITHUB_WORKSPACE} @@ -196,6 +202,7 @@ jobs: with: persist-credentials: false submodules: true + ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036 - name: Mark the workspace as safe # https://github.com/actions/checkout/issues/766 run: git config --global --add safe.directory ${GITHUB_WORKSPACE} @@ -216,6 +223,7 @@ jobs: with: persist-credentials: false submodules: true + ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036 - name: Run yamllint run: | which yamllint >/dev/null || ( apt-get update && apt-get install -y yamllint ) @@ -237,6 +245,7 @@ jobs: with: persist-credentials: false submodules: true + ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036 - name: Run flake8 run: | pip3 install flake8 flake8-import-order diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 5a6bcc7..736e3d1 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -69,6 +69,8 @@ jobs: - name: Checkout repository if: env.ACT != 'true' uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036 - name: Set environment variables if: ${{ inputs.linux_env_vars }} run: | @@ -95,6 +97,8 @@ jobs: - name: Checkout repository if: env.ACT != 'true' uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036 - name: Pull Docker image id: pull_docker_image run: |