This repository has been archived by the owner on Mar 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
91 lines (89 loc) · 3.46 KB
/
Kogito-Operator-PR-Check.yaml
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Kogito Operator PR Checks
on:
pull_request:
paths-ignore:
- "README.md"
- "RELEASE_NOTES.md"
- "examples/**"
- "LICENSE"
- "Makefile"
env:
GO_VERSION: 1.21
jobs:
golint:
name: Lint
concurrency:
group: ${{ github.repository.name }}_lint-${{ github.head_ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
id: go
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/go/pkg/mod/cache
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}-cache-
- name: Cache the binaries
uses: actions/cache@v1
with:
path: ~/go/bin/
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-v1-${{ hashFiles(format('{0}/bin', env.GOPATH)) }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}-v1-${{ hashFiles(format('{0}/bin', env.GOPATH)) }}
- name: Install Operator-sdk
run: ./hack/ci/install-operator-sdk.sh
- name: Check Vet
run: |
make vet
git diff
changed_files=$(git status -s | grep -v 'go.mod\|go.sum\|kogito-operator.yaml\|go.tools.mod\|go.tools.sum' || :)
generated_changed_files=$(git status -s | grep zz_generated || :)
[[ -z "$generated_changed_files" ]] || (printf "There is change in auto-generated files, Please make sure to upgrade openapi-gen" && exit 1)
[[ -z "$changed_files" ]] || (printf "Change is detected in some files: \n$changed_files\n Did you run 'make vet' before sending the PR?" && exit 1)
- name: Check Headers
run: |
./hack/addheaders.sh
changed_files=$(git status -s | grep -v 'go.mod\|go.sum\|kogito-operator.yaml\|go.tools.mod\|go.tools.sum' || :)
[[ -z "$changed_files" ]] || (printf "Some files are missing the headers: \n$changed_files\n Did you run 'make test' before sending the PR" && exit 1)
- name: Check Formatting
run: |
./hack/go-fmt.sh
changed_files=$(git status -s | grep -v 'go.mod\|go.sum\|kogito-operator.yaml\|go.tools.mod\|go.tools.sum' || :)
[[ -z "$changed_files" ]] || (printf "Some files are not formatted properly: \n$changed_files\n Did you run 'make test' before sending the PR?" && exit 1)
- name: Check lint
run: ./hack/go-lint.sh
bats_test:
concurrency:
group: ${{ github.repository.name }}_bats_tests-${{ github.head_ref }}
cancel-in-progress: true
name: Bats Test
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
id: go
- name: Cache the binaries
uses: actions/cache@v1
with:
path: ~/go/bin/
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}
- name: Setup Bats
run: |
git clone https://github.com/bats-core/bats-core.git
cd bats-core && ./install.sh $HOME
- name: Run Bats
run: $HOME/bin/bats hack/*.bats