From 2d7b3fc07348419f372ee56de02133d5a21af931 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Wed, 24 Mar 2021 13:24:55 +0100 Subject: [PATCH] CI: reset existing repo to known state If at some point a PR accidentally deletes a git submodule without deleting it from .gitmodules, subsequent PRs using the same runner will fail because the checkout action will try to run `git submodule foreach ...` before updating the git repo to match the current PR and fail, we can avoid the problem by always resetting to origin/master which hopefully is always in a good state. The `-c "http.https://github.com/.extraheader="` resets a setting set by the checkout action which causes authentication issues when fetching. Ideally the checkout action would be more robust: https://github.com/actions/checkout/issues/354 --- .github/workflows/ci.yaml | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 73c33373c6b0..401de0eb51aa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -52,6 +52,9 @@ jobs: - name: Set JDK 16 as default run: echo "/usr/lib/jvm/java-16-openjdk-amd64/bin" >> $GITHUB_PATH + - name: Reset existing repo + run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true + - name: Checkout cleanup script uses: actions/checkout@v2 @@ -97,6 +100,9 @@ jobs: - name: Set JDK 16 as default run: echo "/usr/lib/jvm/java-16-openjdk-amd64/bin" >> $GITHUB_PATH + - name: Reset existing repo + run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true + - name: Checkout cleanup script uses: actions/checkout@v2 @@ -132,6 +138,10 @@ jobs: )" steps: + - name: Reset existing repo + run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true + shell: cmd + - name: Git Checkout uses: actions/checkout@v2 @@ -157,6 +167,10 @@ jobs: )" steps: + - name: Reset existing repo + run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true + shell: cmd + - name: Git Checkout uses: actions/checkout@v2 @@ -190,6 +204,9 @@ jobs: )" steps: + - name: Reset existing repo + run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true + - name: Checkout cleanup script uses: actions/checkout@v2 @@ -230,6 +247,9 @@ jobs: )" steps: + - name: Reset existing repo + run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true + - name: Checkout cleanup script uses: actions/checkout@v2 @@ -270,6 +290,9 @@ jobs: )" steps: + - name: Reset existing repo + run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true + - name: Checkout cleanup script uses: actions/checkout@v2 @@ -310,6 +333,9 @@ jobs: )" steps: + - name: Reset existing repo + run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true + - name: Checkout cleanup script uses: actions/checkout@v2 @@ -358,6 +384,9 @@ jobs: - name: Set JDK 8 as default run: echo "/usr/lib/jvm/java-8-openjdk-amd64/bin" >> $GITHUB_PATH + - name: Reset existing repo + run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true + - name: Checkout cleanup script uses: actions/checkout@v2 @@ -394,6 +423,9 @@ jobs: SONATYPE_USER: ${{ secrets.SONATYPE_USER_ORGSCALALANG }} steps: + - name: Reset existing repo + run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true + - name: Checkout cleanup script uses: actions/checkout@v2 @@ -428,6 +460,9 @@ jobs: # Make sure you have the write permissions to the repo: https://github.com/lampepfl/dotty-website steps: + - name: Reset existing repo + run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true + - name: Checkout cleanup script uses: actions/checkout@v2 @@ -474,6 +509,9 @@ jobs: SONATYPE_USER: ${{ secrets.SONATYPE_USER_ORGSCALALANG }} steps: + - name: Reset existing repo + run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true + - name: Checkout cleanup script uses: actions/checkout@v2 @@ -556,6 +594,9 @@ jobs: # Make sure you have the write permissions to the repo: https://github.com/lampepfl/dotty-website steps: + - name: Reset existing repo + run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true + - name: Checkout cleanup script uses: actions/checkout@v2 @@ -601,6 +642,9 @@ jobs: SONATYPE_USER: ${{ secrets.SONATYPE_USER }} steps: + - name: Reset existing repo + run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true + - name: Checkout cleanup script uses: actions/checkout@v2