Browse Source

Fix codegen verify checker

Note the codegen verify checker should report error

Signed-off-by: llhuii <liulinghui@huawei.com>
tags/v0.4.0
llhuii 4 years ago
parent
commit
153d34813e
2 changed files with 22 additions and 8 deletions
  1. +10
    -4
      .github/workflows/main.yaml
  2. +12
    -4
      hack/verify-codegen.sh

+ 10
- 4
.github/workflows/main.yaml View File

@@ -11,6 +11,12 @@ jobs:
verify-and-lint: verify-and-lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Verify codegen/vendor/licenses, do lint 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: steps:
- name: Install Go - name: Install Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
@@ -21,7 +27,7 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
path: ./src/github.com/${{ github.repository }}
path: ${{ env.CODE_DIR }}


- uses: actions/cache@v2 - uses: actions/cache@v2
with: with:
@@ -34,15 +40,15 @@ jobs:


- name: Run verify test - name: Run verify test
run: make verify run: make verify
working-directory: ./src/github.com/${{ github.repository }}
working-directory: ${{ env.CODE_DIR }}


- name: Run go lint test - name: Run go lint test
run: make lint run: make lint
working-directory: ./src/github.com/${{ github.repository }}
working-directory: ${{ env.CODE_DIR }}


- name: Run python code style test - name: Run python code style test
run: pycodestyle lib run: pycodestyle lib
working-directory: ./src/github.com/${{ github.repository }}
working-directory: ${{ env.CODE_DIR }}


build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest


+ 12
- 4
hack/verify-codegen.sh View File

@@ -20,16 +20,24 @@ set -o pipefail


SEDNA_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" 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" ZZ_FILE="zz_generated.deepcopy.go"
CODEGEN_PATTERN="${CLIENT_PATTERN}|${ZZ_FILE}"


UPDATE_SCRIPT="hack/update-codegen.sh" UPDATE_SCRIPT="hack/update-codegen.sh"

"${SEDNA_ROOT}/$UPDATE_SCRIPT" "${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 "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 exit 1
else

elif [ $? -eq 1 ]; then # grep exit 1 when no matches
echo "SUCCESS: codegen verified." echo "SUCCESS: codegen verified."
fi fi

Loading…
Cancel
Save