diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6900ba9c..9c17800a 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -11,6 +11,12 @@ jobs: verify-and-lint: runs-on: ubuntu-latest name: Verify codegen/vendor/licenses, do lint + env: + GOPATH: ${{ github.workspace }} + + # since client-go codegen requires that code checkout GOPATH + CODE_DIR: '${{github.workspace}}/src/github.com/kubeedge/sedna' + steps: - name: Install Go uses: actions/setup-go@v2 @@ -21,7 +27,7 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 0 - path: ./src/github.com/${{ github.repository }} + path: ${{ env.CODE_DIR }} - uses: actions/cache@v2 with: @@ -34,15 +40,15 @@ jobs: - name: Run verify test run: make verify - working-directory: ./src/github.com/${{ github.repository }} + working-directory: ${{ env.CODE_DIR }} - name: Run go lint test run: make lint - working-directory: ./src/github.com/${{ github.repository }} + working-directory: ${{ env.CODE_DIR }} - name: Run python code style test run: pycodestyle lib - working-directory: ./src/github.com/${{ github.repository }} + working-directory: ${{ env.CODE_DIR }} build: runs-on: ubuntu-latest diff --git a/hack/verify-codegen.sh b/hack/verify-codegen.sh index 885db193..a564f458 100755 --- a/hack/verify-codegen.sh +++ b/hack/verify-codegen.sh @@ -20,16 +20,24 @@ set -o pipefail SEDNA_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" -CLIENT_ROOT="${SEDNA_ROOT}/pkg/client" +CLIENT_PATTERN="pkg/client/" ZZ_FILE="zz_generated.deepcopy.go" +CODEGEN_PATTERN="${CLIENT_PATTERN}|${ZZ_FILE}" UPDATE_SCRIPT="hack/update-codegen.sh" + "${SEDNA_ROOT}/$UPDATE_SCRIPT" -if git status --short 2>/dev/null | grep -qE "${CLIENT_ROOT}|${ZZ_FILE}"; then +if dirty_files=$( + git status --porcelain | + awk '$0=$2' | + grep -E "$CODEGEN_PATTERN" | + sed 's/^/ /'); then echo "FAILED: codegen verify failed." >&2 - echo "Please run the command to update your codegen files: $UPDATE_SCRIPT" >&2 + echo "Please run the command '$UPDATE_SCRIPT' to update your codegen files:" >&2 + echo "$dirty_files" >&2 exit 1 -else + +elif [ $? -eq 1 ]; then # grep exit 1 when no matches echo "SUCCESS: codegen verified." fi