- Add envtest setup before running tests - Use 'make setup-envtest' to install test binaries - Use 'make test' instead of direct go test - Ensures proper test environment setup in CI This fixes the BeforeSuite panic caused by missing envtest binaries.
94 lines
2.2 KiB
YAML
94 lines
2.2 KiB
YAML
name: PR Validation
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
lint-and-test:
|
|
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
|
|
|
|
- name: Run go fmt
|
|
run: |
|
|
if [ -n "$(gofmt -s -l .)" ]; then
|
|
echo "Go code is not formatted:"
|
|
gofmt -s -d .
|
|
exit 1
|
|
fi
|
|
|
|
- name: Run go vet
|
|
run: go vet ./...
|
|
|
|
- name: Install envtest binaries
|
|
run: make setup-envtest
|
|
|
|
- name: Run tests
|
|
run: make test
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
file: ./coverage.out
|
|
fail_ci_if_error: false
|
|
|
|
helm-lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Helm
|
|
uses: azure/setup-helm@v4
|
|
with:
|
|
version: v3.14.0
|
|
|
|
- name: Lint Helm chart
|
|
run: |
|
|
helm lint helm/unifi-network-operator \
|
|
--set unifi.url="https://test.local" \
|
|
--set unifi.password="test"
|
|
|
|
- name: Template Helm chart
|
|
run: |
|
|
helm template test-release helm/unifi-network-operator \
|
|
--namespace test \
|
|
--set unifi.url="https://test.local" \
|
|
--set unifi.password="test" \
|
|
> /tmp/rendered.yaml
|
|
|
|
- name: Validate rendered manifests
|
|
run: |
|
|
# Check that the rendered output is valid YAML
|
|
kubectl --dry-run=client apply -f /tmp/rendered.yaml
|
|
|
|
docker-build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build Docker image (test only)
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: linux/amd64
|
|
push: false
|
|
tags: test:latest
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|