generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
172 lines (143 loc) · 4.49 KB
/
run-tests.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Run Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
check-generate:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Check that generated artifacts are up-to-date
run: |
make generate
echo "Running 'git status' ..."
git status --porcelain | tee status.out
if [[ -s status.out ]]; then
echo "Generated artifacts are not up-to-date; probably 'make generate' was not run before committing"
exit 1
else
echo "Generated artifacts are up-to-date"
fi
unit-and-integration-tests:
runs-on: ubuntu-24.04
needs: check-generate
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Run tests
run: |
make test
test-scaffold:
runs-on: ubuntu-24.04
needs:
- check-generate
- unit-and-integration-tests
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Build scaffold
run: |
LDFLAGS=""
LDFLAGS+=" -X \"github.com/sap/component-operator-runtime/internal/version.version=$(pwd)\""
LDFLAGS+=" -X \"github.com/sap/component-operator-runtime/internal/version.gitCommit=${{ github.sha }}\""
LDFLAGS+=" -X \"github.com/sap/component-operator-runtime/internal/version.gitTreeState=clean\""
go build -o bin/scaffold -ldflags "$LDFLAGS" ./scaffold
echo "Running 'scaffold --version' ..."
bin/scaffold --version
- name: Run scaffold (without admission webhooks)
run: |
rm -rf $RUNNER_TEMP/src
mkdir $RUNNER_TEMP/src
./bin/scaffold \
--group-name example.io \
--group-version v1alpha1 \
--kind MyComponent \
--operator-name mycomponent-operator.example.io \
--go-module example.io/mycomponent-operator \
--image mycomponent-operator:latest \
$RUNNER_TEMP/src
- name: Build generated operator (without admission webhooks)
run: |
cd $RUNNER_TEMP/src
make build
- name: Test generated operator (without admission webhooks)
run: |
cd $RUNNER_TEMP/src
make test
- name: Validate generation of typed client (without admission webhooks)
run: |
cd $RUNNER_TEMP/src
make generate-client
- name: Run scaffold (with admission webhooks)
run: |
rm -rf $RUNNER_TEMP/src
mkdir $RUNNER_TEMP/src
./bin/scaffold \
--group-name example.io \
--group-version v1alpha1 \
--kind MyComponent \
--with-validating-webhook \
--with-mutating-webhook \
--operator-name mycomponent-operator.example.io \
--go-module example.io/mycomponent-operator \
--image mycomponent-operator:latest \
$RUNNER_TEMP/src
- name: Build generated operator (with admission webhooks)
run: |
cd $RUNNER_TEMP/src
make build
- name: Test generated operator (with admission webhooks)
run: |
cd $RUNNER_TEMP/src
make test
- name: Validate generation of typed client (with admission webhooks)
run: |
cd $RUNNER_TEMP/src
make generate-client
# commented out until github runners have docker 23.0
# - name: Validate docker build
# run: |
# cd $RUNNER_TEMP/src
# make docker-build
test-clm:
runs-on: ubuntu-24.04
needs:
- check-generate
- unit-and-integration-tests
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Build clm
run: |
LDFLAGS=""
LDFLAGS+=" -X \"github.com/sap/component-operator-runtime/internal/version.version=$(pwd)\""
LDFLAGS+=" -X \"github.com/sap/component-operator-runtime/internal/version.gitCommit=${{ github.sha }}\""
LDFLAGS+=" -X \"github.com/sap/component-operator-runtime/internal/version.gitTreeState=clean\""
go build -o bin/clm -ldflags "$LDFLAGS" ./clm
echo "Running 'clm version -o json' ..."
bin/clm version -o json