-
Notifications
You must be signed in to change notification settings - Fork 9
197 lines (176 loc) · 6.79 KB
/
ci.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
---
name: ci
on:
pull_request:
push:
branches:
- 'release/**'
concurrency:
group: '${{ github.ref_name }}'
cancel-in-progress: true
jobs:
yamllint:
uses: networkservicemesh/.github/.github/workflows/yamllint.yaml@main
shellcheck:
uses: networkservicemesh/.github/.github/workflows/shellcheck.yaml@main
golangci-lint:
uses: networkservicemesh/.github/.github/workflows/golangci-lint.yaml@main
exclude-fmt-errorf:
uses: networkservicemesh/.github/.github/workflows/exclude-fmt-errorf.yaml@main
checkgomod:
uses: networkservicemesh/.github/.github/workflows/checkgomod.yaml@main
make-matrix:
name: make matrix
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
matrix: ${{ steps.make-matrix.outputs.matrix }}
steps:
- id: make-matrix
run: |
if ${{ startsWith(github.ref_name, 'release/') }}; then
echo "matrix={\"config\":[ \
{\"node_type\":\"n3.xlarge.x86\",\"CNI\":\"default\"}, \
{\"node_type\":\"n3.xlarge.x86\",\"CNI\":\"calico-vpp\"}, \
{\"node_type\":\"c3.large.arm64\",\"CNI\":\"default\"} \
]}" >> $GITHUB_OUTPUT
else
echo "matrix={\"config\":[ \
{\"node_type\":\"n3.xlarge.x86\",\"CNI\":\"default\"}, \
{\"node_type\":\"n3.xlarge.x86\",\"CNI\":\"calico-vpp\"} \
]}" >> $GITHUB_OUTPUT
fi
packet:
name: ${{ matrix.config.node_type }} (CNI ${{ matrix.config.CNI }})
runs-on: ubuntu-latest
needs: make-matrix
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.make-matrix.outputs.matrix) }}
steps:
- name: Set up /bin permissions
run: |
sudo chmod -R 777 /bin
- name: Install metal CLI
run: |
curl -L https://github.com/equinix/metal-cli/releases/download/v0.22.0/metal-linux-amd64 -o metal
chmod +x ./metal
mv ./metal /usr/local/bin/metal
metal -v
- name: Set envs
run: |
# Set SRIOV_ENABLED
echo SRIOV_ENABLED=true >> $GITHUB_ENV
if [[ "${{ matrix.config.node_type }}" != "n3.xlarge.x86" ]]; then
echo SRIOV_ENABLED=false >> $GITHUB_ENV
fi
# Set CLUSTER_NAME and SSH_KEY
node_type=${{ matrix.config.node_type }}
id=${node_type:0:2}-${{ github.run_number }}
if [[ "${{ matrix.config.CNI }}" == "calico-vpp" ]]; then
id=c-${id}
fi
echo CLUSTER_NAME=nsm-ci-${id} >> $GITHUB_ENV
echo SSH_KEY=nsm-ssh-${id} >> $GITHUB_ENV
# Checking server availability by metro and node_type
- name: Find metro
run: |
metros_to_check=da,ny
if [[ "${{ matrix.config.CNI }}" == "calico-vpp" ]]; then
metros_to_check=at,ch
elif [[ "${{ matrix.config.node_type }}" == "c3.large.arm64" ]]; then
metros_to_check=da,dc
fi
METRO=$(metal capacity check -m ${metros_to_check} -P "${{ matrix.config.node_type }}" -q 2 -o json | jq -r '[.[] | select( .available == true ) | .metro][0]')
if [ ${METRO} == "null" ]; then
exit 1;
fi
echo METRO=${METRO} >> $GITHUB_ENV
env:
METAL_AUTH_TOKEN: ${{ secrets.PACKET_AUTH_TOKEN }}
- name: Set up go
uses: actions/setup-go@v1
with:
go-version: 1.20.11
- name: Checkout files
uses: actions/checkout@v2
with:
path: ${{ github.repository }}
- name: Install kind
uses: engineerd/setup-kind@v0.5.0
with:
config: ${{ github.repository }}/kind-cluster-config.yaml
version: v0.20.0
image: kindest/node:v1.28.0
- name: Check kind
run: |
kubectl version
kubectl get pods -n kube-system
- name: Install clusterctl
run: |
curl -L https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.6.2/clusterctl-linux-amd64 -o clusterctl
chmod +x ./clusterctl
mv ./clusterctl /usr/local/bin/clusterctl
clusterctl version
- name: Setup ssh
working-directory: ${{ github.repository }}
id: setup_ssh
run: |
ssh-keygen -t rsa -f /tmp/sshkey -q -N ""
eval `ssh-agent -s`
ssh-add /tmp/sshkey
ssh_id=$(metal ssh-key create --key "$(cat /tmp/sshkey.pub)" --label ${SSH_KEY} -o json | jq -r '.id')
echo ssh_id=${ssh_id} >> $GITHUB_OUTPUT
env:
METAL_AUTH_TOKEN: ${{ secrets.PACKET_AUTH_TOKEN }}
- name: Setup cluster
uses: nick-fields/retry@v2.8.3
with:
timeout_minutes: 60
max_attempts: 3
command: |
cd ${{ github.repository }}
scripts/setup-cluster.sh "/tmp/sshkey"
on_retry_command: |
cd ${{ github.repository }}
scripts/cleanup-cluster.sh
env:
# METRO env was set above
PACKET_API_KEY: ${{ secrets.PACKET_AUTH_TOKEN }}
METAL_AUTH_TOKEN: ${{ secrets.PACKET_AUTH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PROJECT_ID: 383890d0-f5d1-4de1-881a-4d1ede549d18
NODE_OS: ubuntu_20_04
KUBERNETES_VERSION: "v1.27.1"
CNI: ${{ matrix.config.CNI }}
CONTROLPLANE_NODE_TYPE: ${{ matrix.config.node_type }}
WORKER_NODE_TYPE: ${{ matrix.config.node_type }}
- name: Integration tests
run: |
export KUBECONFIG=$HOME/.kube/config_packet
if [[ "${{ matrix.config.CNI }}" == "calico-vpp" ]]; then
go test -count 1 -timeout 1h50m -race -v ./test/${{ matrix.config.CNI }} -parallel 4 || true
elif [ "${SRIOV_ENABLED}" == true ]; then
go test -count 1 -timeout 1h50m -race -v ./test/${{ matrix.config.CNI }} -parallel 4
else
go test -count 1 -timeout 1h50m -race -v ./test/${{ matrix.config.CNI }}/main_test.go -parallel 4
fi
env:
ARTIFACTS_DIR: logs
working-directory: ${{ github.repository }}
- name: Upload logs
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: ${{ matrix.config.node_type }}-${{ matrix.config.CNI }}-logs
path: ${{ github.repository }}/test/${{ matrix.config.CNI }}/logs
- name: Cleanup
if: ${{ always() }}
working-directory: ${{ github.repository }}
run: |
export KUBECONFIG=$HOME/.kube/config
yes | metal ssh-key delete --id "${{ steps.setup_ssh.outputs.ssh_id }}"
scripts/cleanup-cluster.sh
env:
PROJECT_ID: 383890d0-f5d1-4de1-881a-4d1ede549d18
METAL_AUTH_TOKEN: ${{ secrets.PACKET_AUTH_TOKEN }}