This is an automated email from the ASF dual-hosted git repository.

zrhoffman pushed a commit to branch 6.0.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 7c9832820f1efa97e13725b6fcfb5fa8b64d9488
Author: Zach Hoffman <[email protected]>
AuthorDate: Wed Oct 27 19:40:45 2021 +0000

    License coverage GHA: Re-tidy pkgsite's go modules before vendoring them 
(#6316)
    
    * Reorder YAML keys
    
    * Set id to `go-version`
    
    * License coverage GHA: Re-tidy pkgsite's go modules before vendoring them
    
    * Bust non-tidy cache
    
    (cherry picked from commit 14328dc1d4cea65e99ea6de2ea516cf172239473)
---
 .github/workflows/cache-config-tests.yml    |  2 +-
 .github/workflows/license-file-coverage.yml | 14 +++++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/cache-config-tests.yml 
b/.github/workflows/cache-config-tests.yml
index 63a1036..aad7660 100644
--- a/.github/workflows/cache-config-tests.yml
+++ b/.github/workflows/cache-config-tests.yml
@@ -22,8 +22,8 @@ env:
   ATS_VERSION: 8.1.x
 
 on:
-  push:
   workflow_dispatch:
+  push:
     paths:
       - .github/workflows/cache-config-tests.yml
       - go.mod
diff --git a/.github/workflows/license-file-coverage.yml 
b/.github/workflows/license-file-coverage.yml
index bb0f832..64ead4d 100644
--- a/.github/workflows/license-file-coverage.yml
+++ b/.github/workflows/license-file-coverage.yml
@@ -44,7 +44,8 @@ jobs:
     if: github.event.pull_request.draft == false
     runs-on: ubuntu-latest
     steps:
-      - name: go-version
+      - name: Go version
+        id: go-version
         run: |
           go_version="$(curl -L "${BLOB_URL}/GO_VERSION")" &&
           echo "::set-output name=value::${go_version}"
@@ -68,15 +69,22 @@ jobs:
         uses: actions/cache@v2
         with:
           path: ${{ env.PKGSITE_DIR }}/vendor
-          key: ${{ runner.os }}-go-${{ steps.go-version.outputs.value }}-${{ 
hashFiles('**/go.sum') }}-${{ hashFiles(format('{0}/{1}/{2}', env.PKGSITE_DIR, 
env.COVERAGE_TEST_NAME, format('{0}.go', env.COVERAGE_TEST_NAME))) }}
+          key: ${{ runner.os }}-go-${{ steps.go-version.outputs.value 
}}-tidy-${{ hashFiles('**/go.sum') }}-${{ hashFiles(format('{0}/{1}/{2}', 
env.PKGSITE_DIR, env.COVERAGE_TEST_NAME, format('{0}.go', 
env.COVERAGE_TEST_NAME))) }}
       - name: Download Go modules for ${{ env.PKGSITE_REPO }}
         run: |
-          set -o errexit -o nounset -o xtrace
+          set -o errexit -o nounset -o xtrace -o pipefail
           cd "$PKGSITE_DIR"
+          go_major_version_escaped="$(<<<"${{ steps.go-version.outputs.value 
}}" grep -Eo '^[0-9]+\.[0-9]+' | sed 's/\./\\\./g')"
           if [[ ! -e vendor/modules.txt ]]; then
+            if ! grep -q "go ${go_major_version_escaped}" go.mod; then
+              echo 'Go version in go.mod does not match, tidying modules...'
+              sed -Ei "s/^(go )[0-9].*/\1${go_major_version_escaped}/" go.mod
+            fi
             go mod vendor
+            cp go.mod go.sum vendor/
           else
             echo "Modules are already downloaded."
+            mv vendor/{go.mod,go.sum} .
           fi
       - name: Run the License file coverage check
         run: |

Reply via email to