1
0
Fork 0
mirror of https://github.com/imjasonh/git-k8s synced 2026-07-09 23:27:01 +00:00
git-k8s/.github/workflows/ci.yaml
copilot-swe-agent[bot] 75552e7c2c Add go test step to CI build job
Co-authored-by: imjasonh <210737+imjasonh@users.noreply.github.com>
2026-02-28 00:14:00 +00:00

114 lines
2.7 KiB
YAML

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: Test
run: go test ./...
- 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