1
0
Fork 0
mirror of https://github.com/imjasonh/git-k8s synced 2026-07-08 14:55:17 +00:00

Add GitHub Actions CI with KinD e2e using chainguard-dev/actions

Two jobs:
- build: compiles all controller binaries and runs go vet
- e2e: spins up KinD cluster with Knative via chainguard-dev/actions,
  deploys CRDs and controllers with ko, verifies rollout, runs
  smoke test creating a GitRepository CR. On failure, collects
  kind-diag diagnostics as artifacts.

https://claude.ai/code/session_01QfFzqKQUsxxBsiZUhuJ3pG
This commit is contained in:
Claude 2026-02-28 00:10:31 +00:00
parent 8e65104201
commit 314915b5dd
No known key found for this signature in database

111
.github/workflows/ci.yaml vendored Normal file
View file

@ -0,0 +1,111 @@
name: CI
on:
pull_request:
branches: ["main"]
push:
branches: ["main"]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Go mod tidy
run: go mod tidy
- name: Build all binaries
run: |
go build ./cmd/push-controller/
go build ./cmd/sync-controller/
go build ./cmd/resolver-controller/
- name: Vet
run: go vet ./...
e2e:
name: e2e
runs-on: ubuntu-latest
needs: build
env:
KO_DOCKER_REPO: registry.local:5000/git-k8s
GOFLAGS: "-mod=mod"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Setup KinD
id: kind
uses: chainguard-dev/actions/setup-kind@main
with:
k8s-version: 1.33.x
- name: Setup Knative
uses: chainguard-dev/actions/setup-knative@main
with:
version: "1.15.0"
- name: Install ko
uses: ko-build/setup-ko@v0.9
- name: Go mod tidy
run: go mod tidy
- name: Install CRDs
run: kubectl apply -f config/crds/
- name: Deploy RBAC
run: |
kubectl create namespace git-system || true
kubectl apply -f config/rbac/
- name: Deploy controllers with ko
run: ko apply -f config/deployments/
- name: Wait for controllers to be ready
run: |
for deploy in push-controller sync-controller resolver-controller; do
echo "Waiting for ${deploy}..."
kubectl rollout status deployment/${deploy} \
--namespace=git-system --timeout=120s
done
- name: Verify CRDs are installed
run: |
kubectl get crd gitrepositories.git.k8s.io
kubectl get crd gitbranches.git.k8s.io
kubectl get crd gitpushtransactions.git.k8s.io
kubectl get crd gitreposyncs.git.k8s.io
- name: Smoke test - create a GitRepository
run: |
cat <<EOF | kubectl apply -f -
apiVersion: git.k8s.io/v1alpha1
kind: GitRepository
metadata:
name: test-repo
namespace: default
spec:
url: https://github.com/example/test.git
EOF
kubectl get gitrepositories -A
- name: Collect diagnostics
if: ${{ failure() }}
uses: chainguard-dev/actions/kind-diag@main
with:
artifact-name: kind-logs
cluster-resources: nodes,namespaces,crds
namespace-resources: pods,deployments,services