forked from kserve/kserve
-
Notifications
You must be signed in to change notification settings - Fork 3
63 lines (53 loc) · 2.03 KB
/
verify-codegen.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: "Verify Generated Code"
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
verify-codegen:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Install dependencies
run: |
go mod download
- name: Update Codegen
shell: bash
run: |
GOPATH=$(go env GOPATH)
KSERVE_PATH=$GOPATH/src/github.com/kserve/kserve
echo "KSERVE_PATH=$KSERVE_PATH" >> "$GITHUB_ENV"
mkdir -p $KSERVE_PATH
cp -a . $KSERVE_PATH
cd $KSERVE_PATH
make generate
make manifests
- name: Verify
shell: bash
run: |
cd $KSERVE_PATH
# From: https://backreference.org/2009/12/23/how-to-match-newlines-in-sed/
# This is to leverage this workaround:
# https://github.com/actions/toolkit/issues/193#issuecomment-605394935
urlencode() {
sed ':begin;$!N;s/\n/%0A/;tbegin'
}
# When running make generate, it introduces some lint errors which is fixed manually.
# Reset these files to avoid false triggers due to those changes.
git checkout -- python/kserve/test/__init__.py python/kserve/kserve/api_client.py
if [ -z "$(git status --porcelain ./pkg ./python ./config ./charts)" ]; then
echo "${{ github.repository }} up to date."
else
echo "Found diffs in: $(git diff-index --name-only HEAD -- ./pkg ./python ./charts)"
for x in $(git diff-index --name-only HEAD -- ./pkg ./python ./charts); do
echo "::error file=$x::Please run make generate.%0A$(git diff $x | urlencode)"
done
echo "${{ github.repository }} is out of date. Please run make generate"
exit 1
fi