From ea00371d852d037de76fe014805c0fbbd11afe44 Mon Sep 17 00:00:00 2001 From: Ashay Rane Date: Fri, 24 Feb 2023 14:44:35 -0600 Subject: [PATCH] CI: clear workspace directory before checkout (#1900) We have recently started seeing errors like: ``` Synchronizing submodule url for 'externals/llvm-project' Synchronizing submodule url for 'externals/mlir-hlo' /usr/bin/git -c protocol.version=2 submodule update --init --force --depth=1 Error: fatal: Unable to create '/home/anush/actions-runner/_work/torch-mlir/torch-mlir/.git/modules/externals/llvm-project/index.lock': File exists. ``` As a workaround, this patch removes the workspace directory before the checkout step. --- .github/workflows/RollPyTorch.yml | 10 ++++++---- .github/workflows/bazelBuildAndTest.yml | 6 ++++++ .github/workflows/buildAndTest.yml | 6 ++++-- .github/workflows/buildRelease.yml | 10 ++++++---- .github/workflows/gh-pages-releases.yml | 7 ++++++- .github/workflows/oneshotSnapshotPackage.yml | 8 +++++++- .github/workflows/releaseSnapshotPackage.yml | 9 ++++++++- 7 files changed, 43 insertions(+), 13 deletions(-) diff --git a/.github/workflows/RollPyTorch.yml b/.github/workflows/RollPyTorch.yml index 25cb26395be..2976df3442b 100644 --- a/.github/workflows/RollPyTorch.yml +++ b/.github/workflows/RollPyTorch.yml @@ -14,11 +14,13 @@ jobs: if: github.repository == 'llvm/torch-mlir' steps: - - - name: chown $GITHUB_WORKSPACE + + - name: Prepare workspace run: | - sudo chown -R $USER:$USER $GITHUB_WORKSPACE - + # Clear the workspace directory so that we don't run into errors about + # existing lock files. + rm -rf $GITHUB_WORKSPACE/* + - name: Get torch-mlir uses: actions/checkout@v3 with: diff --git a/.github/workflows/bazelBuildAndTest.yml b/.github/workflows/bazelBuildAndTest.yml index dd053ae7f0a..17a14189933 100644 --- a/.github/workflows/bazelBuildAndTest.yml +++ b/.github/workflows/bazelBuildAndTest.yml @@ -20,6 +20,12 @@ jobs: runs-on: ubuntu-latest steps: + - name: Prepare workspace + run: | + # Clear the workspace directory so that we don't run into errors about + # existing lock files. + rm -rf $GITHUB_WORKSPACE/* + - name: Checkout torch-mlir uses: actions/checkout@v3 with: diff --git a/.github/workflows/buildAndTest.yml b/.github/workflows/buildAndTest.yml index aaaa84aab13..8590649541d 100644 --- a/.github/workflows/buildAndTest.yml +++ b/.github/workflows/buildAndTest.yml @@ -52,10 +52,12 @@ jobs: steps: - - name: chown $GITHUB_WORKSPACE + - name: Prepare workspace if: ${{ matrix.os-arch == 'ubuntu-x86_64' }} run: | - sudo chown -R $USER:$USER $GITHUB_WORKSPACE + # Clear the workspace directory so that we don't run into errors about + # existing lock files. + rm -rf $GITHUB_WORKSPACE/* - name: Checkout torch-mlir uses: actions/checkout@v3 diff --git a/.github/workflows/buildRelease.yml b/.github/workflows/buildRelease.yml index 6ea420dfedf..051811c0673 100644 --- a/.github/workflows/buildRelease.yml +++ b/.github/workflows/buildRelease.yml @@ -15,11 +15,13 @@ jobs: name: Manylinux Build runs-on: a100 steps: - - - name: chown $GITHUB_WORKSPACE + + - name: Prepare workspace run: | - sudo chown -R $USER:$USER $GITHUB_WORKSPACE - + # Clear the workspace directory so that we don't run into errors about + # existing lock files. + rm -rf $GITHUB_WORKSPACE/* + - name: Get torch-mlir uses: actions/checkout@v3 with: diff --git a/.github/workflows/gh-pages-releases.yml b/.github/workflows/gh-pages-releases.yml index ecac146b9b6..1849f8d4521 100644 --- a/.github/workflows/gh-pages-releases.yml +++ b/.github/workflows/gh-pages-releases.yml @@ -13,8 +13,13 @@ jobs: if: github.repository == 'llvm/torch-mlir' steps: + - name: Prepare workspace + run: | + # Clear the workspace directory so that we don't run into errors about + # existing lock files. + rm -rf $GITHUB_WORKSPACE/* - name: Checking out repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: token: ${{ secrets.WORKFLOW_INVOCATION_TOKEN }} - name: Run scrape releases script diff --git a/.github/workflows/oneshotSnapshotPackage.yml b/.github/workflows/oneshotSnapshotPackage.yml index c21ed8f9e36..07d0863a741 100644 --- a/.github/workflows/oneshotSnapshotPackage.yml +++ b/.github/workflows/oneshotSnapshotPackage.yml @@ -10,8 +10,14 @@ jobs: # Don't run this in everyone's forks. if: github.repository == 'llvm/torch-mlir' steps: + - name: Prepare workspace + run: | + # Clear the workspace directory so that we don't run into errors about + # existing lock files. + rm -rf $GITHUB_WORKSPACE/* + - name: Checking out repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: token: ${{ secrets.WORKFLOW_INVOCATION_TOKEN }} diff --git a/.github/workflows/releaseSnapshotPackage.yml b/.github/workflows/releaseSnapshotPackage.yml index 1037abca0b2..a9878633865 100644 --- a/.github/workflows/releaseSnapshotPackage.yml +++ b/.github/workflows/releaseSnapshotPackage.yml @@ -13,8 +13,15 @@ jobs: # Don't run this in everyone's forks. if: github.repository == 'llvm/torch-mlir' steps: + + - name: Prepare workspace + run: | + # Clear the workspace directory so that we don't run into errors about + # existing lock files. + rm -rf $GITHUB_WORKSPACE/* + - name: Checking out repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: token: ${{ secrets.WORKFLOW_INVOCATION_TOKEN }}