Repository navigation
180 lines (149 loc) · 5.57 KB
/
Copy pathci-test.yaml
File metadata and controls
180 lines (149 loc) · 5.57 KB
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
name: CI Tests
on:
workflow_dispatch:
permissions:
actions: read
contents: read
jobs:
run-kind-with-arc:
runs-on: ubuntu-latest
steps:
-
name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
-
name: Start kind cluster
run: |
cat <<EOF > kind-config.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.35.0@sha256:452d707d4862f52530247495d180205e029056831160e22870e37e3f6c1ac31f
- role: worker
image: kindest/node:v1.35.0@sha256:452d707d4862f52530247495d180205e029056831160e22870e37e3f6c1ac31f
EOF
kind create cluster --config kind-config.yaml
kubectl wait --for=condition=Ready nodes --all --timeout=120s
helm install cncf-gha-controller \
--namespace arc-systems \
--create-namespace \
--version 0.14.1 \
oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set-controller
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/component=controller-manager --timeout=600s -n arc-systems
kubectl create secret generic oci-api-key --from-literal=oci_api_key.pem="${{ secrets.OCI_CLI_KEY_CONTENT }}" -n arc-systems
kubectl create secret generic github-arc-secret --from-literal=github_token=${{ secrets.GHA_PAT }} -n arc-systems
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
name: oci-config
namespace: arc-systems
type: Opaque
stringData:
config: |
[DEFAULT]
user=${{ secrets.OCI_CLI_USER }}
fingerprint=${{ secrets.OCI_CLI_FINGERPRINT }}
tenancy=${{ secrets.OCI_CLI_TENANCY }}
region=${{ secrets.OCI_CLI_REGION }}
key_file=/oci/oci_api_key.pem
EOF
sed 's/oracle-vm-2cpu-8gb-x86-64/oci-ci-test/g' ci/cluster/oci/vm-runners/2cpu-8gb/install.yaml \
| sed '/subnet-id/a \ - --running-environment=ci' \
| sed 's/20187466606/20428190013/' \
| sed '/nodeSelector/,+1d'| kubectl apply -f -
- name: Wait for completion signal
run: |
MAX_ITERATIONS=120
ITERATION=0
while true; do
ITERATION=$((ITERATION + 1))
if [ "$ITERATION" -gt "$MAX_ITERATIONS" ]; then
echo "ERROR: Timed out after $MAX_ITERATIONS iterations"
exit 1
fi
if ! RESULT=$(gh api "repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/jobs"); then
echo "WARNING: gh api call failed, retrying..."
sleep 30
continue
fi
PENDING=$(echo "$RESULT" | jq '[.jobs[] | select(.name != "run-kind-with-arc" and .status != "completed")] | length')
FAILED=$(echo "$RESULT" | jq '[.jobs[] | select(.conclusion == "failure")] | length')
if [ "$FAILED" -gt 0 ]; then
echo "ERROR: $FAILED job(s) failed"
exit 1
fi
if [ "$PENDING" -eq 0 ]; then
echo "All jobs completed"
break
fi
echo "There are $PENDING pending jobs (iteration $ITERATION/$MAX_ITERATIONS)..."
sleep 30
done
env:
GH_TOKEN: ${{ github.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_RUN_ID: ${{ github.run_id }}
test-runner:
runs-on: oci-ci-test
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Update APT
run: |
sudo apt-get update
sudo apt-get install -y mc
- name: Run uname to verify architecture
run: |
uname -a
lsb_release -a
cat /proc/cpuinfo
- name: Run kind cluster
run: |
CLUSTER_NAME="kind-test"
KIND_CONFIG="kind-config.yaml"
sudo sysctl fs.inotify.max_user_instances=1280
sudo sysctl fs.inotify.max_user_watches=655360
cat <<EOF > $KIND_CONFIG
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
EOF
echo "[*] Creating Kind cluster..."
kind create cluster --name $CLUSTER_NAME --config $KIND_CONFIG
kubectl wait --for=condition=Ready nodes --all --timeout=120s
echo "[*] Creating pod ..."
kubectl apply -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx:latest
resources:
requests:
memory: "256Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "500m"
EOF
echo "[*] Waiting for pods to be ready..."
kubectl wait --for=condition=Ready pod/nginx --timeout=300s
echo "[*] Pods running, doing test workload..."
sleep 60
echo "[*] Deleting pods..."
kubectl delete pod nginx
echo "[*] Deleting Kind cluster..."
kind delete cluster --name $CLUSTER_NAME
echo "[*] Done!"