diff --git a/.github/workflows/codegen.yml b/.github/workflows/codegen.yml index 740ed0f3d..aeb43b894 100644 --- a/.github/workflows/codegen.yml +++ b/.github/workflows/codegen.yml @@ -16,5 +16,5 @@ jobs: run: GOPATH=$(go env GOPATH) make codegen - name: validate codegen - run: hack/validate-codegen.sh + run: hack/validate_modified_files.sh codegen diff --git a/.github/workflows/mod-check.yml b/.github/workflows/mod-check.yml new file mode 100644 index 000000000..5de61dfc8 --- /dev/null +++ b/.github/workflows/mod-check.yml @@ -0,0 +1,20 @@ +name: Mod check +on: [pull_request] + +jobs: + modcheck: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v1 + + - uses: actions/setup-go@v2 + with: + go-version: 1.13 + + - name: run mod check + run: GOPATH=$(go env GOPATH) make -j $(nproc) mod.check + + - name: validate modcheck + run: hack/validate_modified_files.sh modcheck + diff --git a/Jenkinsfile b/Jenkinsfile index 200eb19a3..973b41dc3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -97,9 +97,6 @@ pipeline { } } steps { - // quick check that no files are modified for the go modules - sh 'build/run make -j\$(nproc) mod.check' - sh 'git diff-index --quiet HEAD || { echo "CHANGES FOUND. You may need to run make clean"; git status -s; exit 1; }' // run the build sh 'build/run make -j\$(nproc) build.all' sh 'git status' diff --git a/hack/validate-codegen.sh b/hack/validate-codegen.sh deleted file mode 100755 index e7b1e7bab..000000000 --- a/hack/validate-codegen.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -set -ex - -for file in $(git status --porcelain); do - if [[ "$file" =~ "zz" ]]; then - echo "found codegen files!" - echo "please run 'make codegen' and update your PR" - exit 1 - fi -done diff --git a/hack/validate_modified_files.sh b/hack/validate_modified_files.sh new file mode 100755 index 000000000..0e754ec8e --- /dev/null +++ b/hack/validate_modified_files.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -ex + +############# +# VARIABLES # +############# +MOD_FILE="mod" +CODEGEN_FILE="zz" +CODEGEN_ERR="found codegen files! please run 'make codegen' and update your PR" +MOD_ERR="changes found by mod.check. You may need to run make clean" + +############# +# FUNCTIONS # +############# +function validate(){ + for file in $(git status --porcelain); do + if [[ "$file" =~ $1 ]]; then + echo "$2" + exit 1 + fi + done +} + +######## +# MAIN # +######## +case "$1" in + codegen) + validate "$CODEGEN_FILE" "$CODEGEN_ERR" + ;; + modcheck) + validate "$MOD_FILE" "$MOD_ERR" + ;; + *) + echo $"Usage: $0 {codegen|modcheck}" + exit 1 +esac + +