-
Notifications
You must be signed in to change notification settings - Fork 799
150 lines (140 loc) · 5.81 KB
/
ci-build.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
name: Build and test the operator
on:
push:
branches:
- 'master'
- 'release-*'
- 'rhos-*'
pull_request:
branches:
- 'master'
- 'release-*'
- 'rhos-*'
jobs:
build-operator:
runs-on: ubuntu-latest
steps:
- name: Create checkout directory
run: mkdir -p ~/go/src/github.com/argoproj-labs
- name: Checkout code
uses: actions/checkout@v2
- name: Create symlink in GOPATH
run: ln -s $(pwd) ~/go/src/github.com/argoproj-labs
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Restore go build cache
uses: actions/cache@v1
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-v1-${{ github.run_id }}
- name: Build operator container image
run: make docker-build IMG=quay.io/argoprojlabs/argocd-operator:latest
test-e2e:
name: Run end-to-end tests
runs-on: ubuntu-latest
strategy:
matrix:
k3s-version: [ v1.27.1 ]
# k3s-version: [v1.20.2, v1.19.2, v1.18.9, v1.17.11, v1.16.15]
steps:
- name: Download kuttl plugin
env:
KUTTL_VERSION: '0.10.0'
KUTTL_PLUGIN_SUM: 'ad21c0d2be495a8f6cfc0821e592ae61afd191ebd453156d9b204e2524fceaf2'
KUTTL_PLUGIN_FILENAME: 'kubectl-kuttl_0.10.0_linux_x86_64'
run: |
set -x
echo ${KUTTL_PLUGIN_FILENAME}
curl -OL https://github.com/kudobuilder/kuttl/releases/download/v${KUTTL_VERSION}/${KUTTL_PLUGIN_FILENAME}
echo "${KUTTL_PLUGIN_SUM} ${KUTTL_PLUGIN_FILENAME}" | sha256sum -c -
sudo mv ${KUTTL_PLUGIN_FILENAME} /usr/local/bin/kubectl-kuttl
sudo chmod +x /usr/local/bin/kubectl-kuttl
kubectl-kuttl version
- name: Install K3D
run: |
set -x
curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash
sudo mkdir -p $HOME/.kube && sudo chown -R runner $HOME/.kube
k3d cluster create --servers 3 --image rancher/k3s:${{ matrix.k3s-version }}-k3s1
kubectl version
k3d version
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Golang
uses: actions/setup-go@v1
with:
go-version: 1.19
- name: GH actions workaround - Kill XSP4 process
run: |
sudo pkill mono || true
- name: Restore go build cache
uses: actions/cache@v1
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-v1-${{ github.run_id }}
- name: Add /usr/local/bin to PATH
run: |
echo "/usr/local/bin" >> $GITHUB_PATH
- name: Download Go dependencies
run: |
go mod download
- name: Run the operator locally
env:
ARGOCD_CLUSTER_CONFIG_NAMESPACES: argocd-e2e-cluster-config
run: |
set -o pipefail
make install generate fmt vet
# Use tee to flush output to the log. Other solutions like stdbuf don't work, not sure why.
REDIS_CONFIG_PATH="build/redis" GRAFANA_CONFIG_PATH="grafana" go run ./main.go 2>&1 | tee /tmp/e2e-operator-run.log &
- name: Run tests
run: |
set -o pipefail
bash hack/test.sh 2>&1 | tee /tmp/e2e-test.log
- name: Upload operator logs
uses: actions/upload-artifact@v2
with:
name: e2e-operator-run-${{ matrix.k3s-version }}.log
path: /tmp/e2e-operator-run.log
if: ${{ failure() }}
- name: Upload test logs
uses: actions/upload-artifact@v2
with:
name: e2e-test-${{ matrix.k3s-version }}.log
path: /tmp/e2e-test.log
if: ${{ failure() }}
- name: Save application controller and server logs
if: ${{ failure() }}
run: |
# Since the tests stop on the first failure, only one of the namespaces will exist
set -x
if [ $(kubectl get namespaces -o=name | grep '^namespace/argocd-e2e$') ]; then
hack/pods.sh argocd-e2e > /tmp/pods.log
kubectl logs -n argocd-e2e $(kubectl get po -n argocd-e2e -o=name | grep example-argocd-application-controller) > /tmp/e2e-application-controller.log
kubectl logs -n argocd-e2e $(kubectl get po -n argocd-e2e -o=name | grep example-argocd-server) > /tmp/e2e-server.log
kubectl describe -n argocd-e2e $(kubectl get po -n argocd-e2e -o=name | grep example-argocd-server) >> /tmp/e2e-server.log
elif [ $(kubectl get namespaces -o=name | grep '^namespace/argocd-e2e-cluster-config$') ]; then
hack/pods.sh argocd-e2e-cluster-config > /tmp/pods.log
kubectl logs -n argocd-e2e-cluster-config $(kubectl get po -n argocd-e2e-cluster-config -o=name | grep example-argocd-application-controller) > /tmp/e2e-application-controller.log
kubectl logs -n argocd-e2e-cluster-config $(kubectl get po -n argocd-e2e-cluster-config -o=name | grep example-argocd-server) > /tmp/e2e-server.log
kubectl describe -n argocd-e2e-cluster-config $(kubectl get po -n argocd-e2e-cluster-config -o=name | grep example-argocd-server) >> /tmp/e2e-server.log
fi
- name: Upload application controller logs
uses: actions/upload-artifact@v2
with:
name: e2e-application-controller-${{ matrix.k3s-version }}.log
path: /tmp/e2e-application-controller.log
if: ${{ failure() }}
- name: Upload server logs
uses: actions/upload-artifact@v2
with:
name: e2e-server-${{ matrix.k3s-version }}.log
path: /tmp/e2e-server.log
if: ${{ failure() }}
- name: Upload pod descriptions
uses: actions/upload-artifact@v2
with:
name: e2e-pods-${{ matrix.k3s-version }}.log
path: /tmp/pods.log
if: ${{ failure() }}