-
Notifications
You must be signed in to change notification settings - Fork 1
179 lines (159 loc) · 4.71 KB
/
integration-tests.yml
File metadata and controls
179 lines (159 loc) · 4.71 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
# Team Operator Integration Tests
#
# This workflow runs integration tests using both:
# - envtest (API-level tests, fast)
# - kind cluster (full stack tests, slower)
#
# Envtest runs on every PR. Kind tests run on every PR that touches
# relevant paths (api/, internal/, Dockerfile, etc.), on push to main,
# nightly, and on manual dispatch.
name: Integration Tests
on:
push:
branches:
- main
paths-ignore:
- '**/*.md'
- 'docs/**'
- '.claude/**'
- 'LICENSE'
pull_request:
paths-ignore:
- '**/*.md'
- 'docs/**'
- '.claude/**'
- 'LICENSE'
schedule:
# Run nightly at 2:00 AM UTC
- cron: '0 2 * * *'
workflow_dispatch:
inputs:
run_kind_tests:
description: 'Run kind integration tests'
required: false
default: 'true'
type: boolean
permissions:
contents: read
env:
KIND_VERSION: 'v0.23.0'
KIND_CLUSTER_NAME: 'team-operator-test'
jobs:
check-changes:
name: Detect relevant changes
runs-on: ubuntu-latest
outputs:
relevant: ${{ steps.filter.outputs.relevant }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
relevant:
- 'api/**'
- 'internal/**'
- 'cmd/**'
- 'hack/test-kind.sh'
- 'dist/chart/**'
- 'Dockerfile'
- 'Makefile'
- 'go.mod'
- 'go.sum'
envtest:
name: Envtest (API-level tests)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- name: Cache envtest binaries
uses: actions/cache@v4
with:
path: bin/
key: ${{ runner.os }}-envtest-${{ hashFiles('Makefile') }}
restore-keys: |
${{ runner.os }}-envtest-
- name: Install envtest
run: make envtest
- name: Run envtest suite
run: make go-test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload coverage
uses: codecov/codecov-action@v5
with:
files: coverage.out
flags: envtest
fail_ci_if_error: false
kind:
name: Kind (full stack tests)
runs-on: ubuntu-latest
needs: [envtest, check-changes]
# Run on PRs touching relevant paths, push to main, nightly, or manual trigger
if: |
(github.event_name == 'pull_request' && needs.check-changes.outputs.relevant == 'true') ||
github.ref == 'refs/heads/main' ||
github.event_name == 'schedule' ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.run_kind_tests == 'true')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- name: Install kind
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
- name: Install Helm
uses: azure/setup-helm@v4
with:
version: 'latest'
- name: Create kind cluster
run: make kind-create KIND_CLUSTER_NAME=${{ env.KIND_CLUSTER_NAME }}
- name: Run integration tests
run: |
make test-kind KIND_CLUSTER_NAME=${{ env.KIND_CLUSTER_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Collect cluster logs on failure
if: failure()
run: |
echo "=== Cluster Info ==="
kubectl cluster-info --context kind-${{ env.KIND_CLUSTER_NAME }}
echo ""
echo "=== All Pods ==="
kubectl get pods -A
echo ""
echo "=== Events ==="
kubectl get events -A --sort-by='.lastTimestamp'
echo ""
echo "=== Operator Logs ==="
kubectl logs -n posit-team-system -l app.kubernetes.io/name=team-operator --tail=100 || true
- name: Delete kind cluster
if: always()
run: make kind-delete KIND_CLUSTER_NAME=${{ env.KIND_CLUSTER_NAME }}
# Summary job for branch protection
integration-tests-complete:
name: Integration Tests Complete
runs-on: ubuntu-latest
needs: [envtest]
if: always()
steps:
- name: Check results
run: |
if [[ "${{ needs.envtest.result }}" != "success" ]]; then
echo "Envtest failed"
exit 1
fi
echo "All required tests passed!"