From 58c8de95bebe9ec0c65e7d4f45f0b34f1183c2b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Wed, 26 Aug 2020 11:44:35 +0200 Subject: [PATCH] ci: add modcheck github workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new github workflow to verify with mod check. Signed-off-by: Sébastien Han --- .github/workflows/codegen.yml | 2 +- .github/workflows/mod-check.yml | 20 +++++++++++++++++ Jenkinsfile | 3 --- hack/validate-codegen.sh | 10 --------- hack/validate_modified_files.sh | 39 +++++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/mod-check.yml delete mode 100755 hack/validate-codegen.sh create mode 100755 hack/validate_modified_files.sh 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 + +