From 4e7b7624660f076bb0184f107b3f4156a70a0b53 Mon Sep 17 00:00:00 2001 From: Nick Volynkin Date: Fri, 20 Oct 2023 12:56:12 +0300 Subject: [PATCH] ci: Clean index.lock files Cancelling a job while the checkout step is running often results in index.lock files persisting in one of the submodules. The checkout action only removes index.lock files in the root repo, but not in submodules. (See issue https://github.com/actions/checkout/issues/1153). On the following job runs, checkout fails, being unable to operate on a submodule with an index.lock file. This new step will remove such files when the job was cancelled or has failed on the checkout step or before it. For details on the status check functions, used in this step, see https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions Resolves #316 Co-authored-by: Mikhail Aksenov --- .github/workflows/build_linux.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index b777c896..bd13913d 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -67,6 +67,11 @@ jobs: submodules: 'recursive' fetch-depth: 0 + - name: Clean index.lock files if checkout step was cancelled or failed + if: cancelled() || failure() + run: | + find .git -name 'index.lock' -exec rm -v {} \; + # Workaround: https://github.com/actions/checkout/issues/1169 - name: Mark directory as safe run: |