-
Notifications
You must be signed in to change notification settings - Fork 9
140 lines (133 loc) · 4.69 KB
/
example_test.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
name: Kubebb Core E2E Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
env:
LOG_DIR: "/tmp/kubebb-core-example-test/logs"
GO_VER: "1.21.6"
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
build-image:
runs-on: ubuntu-latest
steps:
- name: Check whether the operator image of the same commit has been built.
id: cache
uses: actions/cache/restore@v3
with:
key: operator.image-${{ github.sha }}
path: /tmp/operator.image.tar
- name: Checkout code
uses: actions/checkout@v3
# It would be foolish to add the same judgment over and over again, but GitHub action currently does not have
# the syntax to skip all the next steps unless we let the pre step fail, and failure is not what we want.
# see https://github.com/actions/runner/issues/662
if: steps.cache.outputs.cache-hit != 'true'
- name: Build operator image
if: steps.cache.outputs.cache-hit != 'true'
run: |
make docker-build
- name: Save operator image to /tmp
if: steps.cache.outputs.cache-hit != 'true'
run: |
docker save kubebb/core:latest > /tmp/operator.image.tar
- name: Upload operator image
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
key: operator.image-${{ github.sha }}
path: /tmp/operator.image.tar
rating-test:
needs:
- build-image
runs-on: ubuntu-latest
environment: Dev
strategy:
fail-fast: true
matrix:
no: [1, 2]
steps:
- uses: actions/checkout@v3
- name: Download operator image from cache
uses: actions/cache/restore@v3
with:
key: operator.image-${{ github.sha }}
path: /tmp/operator.image.tar
- name: Load component image to /tmp from cache
uses: actions/cache/restore@v3
with:
key: component-image-cache-${{ github.sha }}
restore-keys: component-image-cache-
path: |
/home/runner/work/kubebb-core/kubebb-core/tmp/images/
/home/runner/work/kubebb-core/kubebb-core/tmp/all.image.list
- name: Load kubebb core image to docker
run: |
docker load --input /tmp/operator.image.tar
- name: Copy the existing kustomize
# avoid kustomize installation to bypass the rate limit of GitHub.
run: |
mkdir -p ${GITHUB_WORKSPACE}/bin
cp /usr/local/bin/kustomize ${GITHUB_WORKSPACE}/bin/kustomize
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
- name: Rating test
run: config/samples/rating_test.sh
env:
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
example-test:
needs:
- build-image
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
no: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
steps:
- uses: actions/checkout@v3
- name: Download operator image from cache
uses: actions/cache/restore@v3
with:
key: operator.image-${{ github.sha }}
path: /tmp/operator.image.tar
- name: Load component image to /tmp from cache
uses: actions/cache/restore@v3
with:
key: component-image-cache-${{ github.sha }}
restore-keys: component-image-cache-
path: |
/home/runner/work/kubebb-core/kubebb-core/tmp/images/
/home/runner/work/kubebb-core/kubebb-core/tmp/all.image.list
- name: Load kubebb core image to docker
run: |
docker load --input /tmp/operator.image.tar
- name: Copy the existing kustomize
# avoid kustomize installation to bypass the rate limit of GitHub.
run: |
mkdir -p ${GITHUB_WORKSPACE}/bin
cp /usr/local/bin/kustomize ${GITHUB_WORKSPACE}/bin/kustomize
- uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
- name: Example test
run: config/samples/example-test.sh
- name: Upload logs if test fail
if: failure()
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.no }}.logs
path: ${{ env.LOG_DIR }}
- name: Upload component images to cache
if: ${{ env.UPLOAD_IMAGE == 'YES' }}
uses: actions/cache/save@v3
with:
key: component-image-cache-${{ github.sha }}
path: |
/home/runner/work/kubebb-core/kubebb-core/tmp/images/
/home/runner/work/kubebb-core/kubebb-core/tmp/all.image.list