-
Notifications
You must be signed in to change notification settings - Fork 112
163 lines (141 loc) · 6.37 KB
/
Copy pathverify-operator-boot.yml
File metadata and controls
163 lines (141 loc) · 6.37 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
name: "Verify Operator Boot"
# Verifies that the operator binary builds and connects to a live kind cluster.
# Acceptance criteria:
# 1. cargo build --release succeeds with zero errors
# 2. ./target/release/stellar-operator run starts against a kind cluster
# 3. Log line "Connected to Kubernetes cluster" appears
#
# Uses shared composite actions for Rust setup and log collection.
on:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: verify-boot-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
CLUSTER_NAME: stellar-verify
OPERATOR_NAMESPACE: stellar-system
jobs:
verify-operator-boot:
name: Verify Operator Boot & Cluster Connection
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
# ── Scope check: skip on PRs that don't touch operator code ──────────
- name: Decide whether boot verification should run
id: scope
run: |
set -euo pipefail
if [[ "${{ github.event_name }}" != "pull_request" ]]; then
echo "run=true" >> "$GITHUB_OUTPUT"
exit 0
fi
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
CHANGED=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" || true)
echo "$CHANGED"
if echo "$CHANGED" | grep -Eq '^(src/|config/crd/|Cargo\.toml|Cargo\.lock|build\.rs|Makefile)'; then
echo "run=true" >> "$GITHUB_OUTPUT"
else
echo "run=false" >> "$GITHUB_OUTPUT"
fi
# ── Build (AC #1) — shared composite action (issue #1136) ──────────────
- name: Build operator binary
if: steps.scope.outputs.run == 'true'
uses: ./.github/actions/build-operator
with:
cache-key: "verify-boot"
binary-only: "true"
- name: Confirm binary exists
if: steps.scope.outputs.run == 'true'
run: |
ls -lh target/release/stellar-operator
echo "✅ cargo build --release succeeded"
# ── Create kind cluster (AC #2) ───────────────────────────────────────
- name: Install kind
if: steps.scope.outputs.run == 'true'
uses: helm/kind-action@v1.14.0
with:
install_only: true
- name: Create kind cluster
if: steps.scope.outputs.run == 'true'
run: |
kind create cluster --name ${{ env.CLUSTER_NAME }} --wait 60s
kubectl cluster-info --context kind-${{ env.CLUSTER_NAME }}
echo "✅ kind cluster '${{ env.CLUSTER_NAME }}' is ready"
# ── Install CRD ───────────────────────────────────────────────────────
- name: Install StellarNode CRD
if: steps.scope.outputs.run == 'true'
run: |
kubectl apply -f config/crd/stellarnode-crd.yaml
kubectl wait --for=condition=established --timeout=30s \
crd/stellarnodes.stellar.org || true
# ── Run operator and verify log line (AC #2 + AC #3) ─────────────────
- name: Run operator and verify cluster connection
if: steps.scope.outputs.run == 'true'
run: |
env -u GITHUB_REPOSITORY ./target/release/stellar-operator run \
--namespace ${{ env.OPERATOR_NAMESPACE }} \
> /tmp/operator.log 2>&1 &
OPERATOR_PID=$!
echo "Operator PID: $OPERATOR_PID"
TIMEOUT=60
ELAPSED=0
FOUND=false
while [[ $ELAPSED -lt $TIMEOUT ]]; do
if grep -q "Connected to Kubernetes cluster" /tmp/operator.log 2>/dev/null; then
FOUND=true
break
fi
sleep 1
ELAPSED=$((ELAPSED + 1))
done
echo "--- Operator log ---"
cat /tmp/operator.log || true
echo "--------------------"
kill "$OPERATOR_PID" 2>/dev/null || true
if [[ "$FOUND" == "true" ]]; then
echo "✅ Log line 'Connected to Kubernetes cluster' confirmed"
else
echo "❌ Log line 'Connected to Kubernetes cluster' NOT found within ${TIMEOUT}s"
exit 1
fi
# ── Runtime error check ───────────────────────────────────────────────
- name: Report runtime errors
if: always() && steps.scope.outputs.run == 'true'
run: |
echo "--- Runtime error check ---"
if grep -iE "error|panic|missing env" /tmp/operator.log 2>/dev/null; then
echo "⚠️ Errors found in operator log (see above)"
else
echo "✅ No runtime errors detected"
fi
# ── Upload log artifact (always-on boot log) ──────────────────────────
- name: Upload operator log
if: always() && steps.scope.outputs.run == 'true'
uses: actions/upload-artifact@v7
with:
name: operator-boot-log-${{ github.run_id }}
path: /tmp/operator.log
retention-days: 7
# ── Unified failure diagnostics bundle (issue #1151) ─────────────────
- name: Upload failure diagnostics bundle
if: failure() && steps.scope.outputs.run == 'true'
uses: ./.github/actions/collect-failure-diagnostics
with:
artifact-name: ci-diagnostics-verify-operator-boot-${{ github.run_id }}
operator-namespace: stellar-system
extra-paths: |
/tmp/operator.log
retention-days: "14"
# ── Cleanup ───────────────────────────────────────────────────────────
- name: Delete kind cluster
if: always() && steps.scope.outputs.run == 'true'
run: kind delete cluster --name ${{ env.CLUSTER_NAME }} || true
- name: Skip message
if: steps.scope.outputs.run != 'true'
run: echo "Skipping verify-operator-boot — no operator/runtime files changed."