Skip to content

Commit

Permalink
Merge pull request #166 from llhuii/fix-verify-checker
Browse files Browse the repository at this point in the history
Fix codegen verify checker
  • Loading branch information
kubeedge-bot authored Aug 23, 2021
2 parents 008364c + 88d183d commit c3475e2
Show file tree
Hide file tree
Showing 17 changed files with 1,442 additions and 8 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down
16 changes: 12 additions & 4 deletions hack/verify-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit c3475e2

Please sign in to comment.