Skip to content

test

test #11

Workflow file for this run

---
name: test
on:
workflow_call: {}
workflow_dispatch:
inputs:
debug_unit:
description: "start tmate before unit tests"
type: boolean
required: false
default: false
debug_e2e:
description: "start tmate before e2e tests"
type: boolean
required: false
default: false
jobs:
unit:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: load env vars for workflow run
run: |
source .github/vars.env
echo "GO_VERSION=$GO_VERSION" >> "$GITHUB_ENV"
echo "DEVSPACE_VERSION=$DEVSPACE_VERSION" >> "$GITHUB_ENV"
echo "GCI_VERSION=$GCI_VERSION" >> "$GITHUB_ENV"
echo "GOFUMPT_VERSION=$GOFUMPT_VERSION" >> "$GITHUB_ENV"
echo "GOLANGCI_LINT_VERSION=$GOLANGCI_LINT_VERSION" >> "$GITHUB_ENV"
echo "GOLINES_VERSION=$GOLINES_VERSION" >> "$GITHUB_ENV"
echo "GOTESTSUM_VERSION=$GOTESTSUM_VERSION" >> "$GITHUB_ENV"
echo "HELM_VERSION=$HELM_VERSION" >> "$GITHUB_ENV"
- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: install go test tools
run: |
go install gotest.tools/gotestsum@${{ env.GOTESTSUM_VERSION }}
- name: setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_unit }}
- name: run the unit tests
run: make test-race
e2e:
runs-on: ubuntu-latest
needs:
- unit
# run e2e on main or prs pointing to main
if: (github.ref_name == 'main' || github.base_ref == 'main') || (github.event_name == 'workflow_dispatch' && inputs.debug_e2e)
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: load env vars for workflow run
run: |
source .github/vars.env
echo "GO_VERSION=$GO_VERSION" >> "$GITHUB_ENV"
echo "DEVSPACE_VERSION=$DEVSPACE_VERSION" >> "$GITHUB_ENV"
echo "GCI_VERSION=$GCI_VERSION" >> "$GITHUB_ENV"
echo "GOFUMPT_VERSION=$GOFUMPT_VERSION" >> "$GITHUB_ENV"
echo "GOLANGCI_LINT_VERSION=$GOLANGCI_LINT_VERSION" >> "$GITHUB_ENV"
echo "GOLINES_VERSION=$GOLINES_VERSION" >> "$GITHUB_ENV"
echo "GOTESTSUM_VERSION=$GOTESTSUM_VERSION" >> "$GITHUB_ENV"
echo "HELM_VERSION=$HELM_VERSION" >> "$GITHUB_ENV"
- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: install go test tools
run: |
go install gotest.tools/gotestsum@${{ env.GOTESTSUM_VERSION }}
- name: install devspace
run: |
curl -L -o devspace \
"https://github.com/loft-sh/devspace/releases/download/${{ env.DEVSPACE_VERSION}}/devspace-linux-amd64" &&
install -c -m 0755 devspace /usr/local/bin
working-directory: /tmp
- name: spin up kind cluster
uses: helm/kind-action@v1.9.0
- name: verify kind cluster
run: |
set -x
kubectl cluster-info
kubectl get pods -A
- name: deploy clabernetes
run: devspace run deploy --profile debug
- name: setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_e2e }}
- name: wait for clabernetes
run: |
kubectl rollout status deployment clabernetes-manager -n clabernetes
- name: run the e2e tests
id: run-the-e2e-tests
run: make test-e2e
continue-on-error: true
- name: dump logs from controller if tests fail
if: steps.run-the-e2e-tests.outcome != 'success'
run: |
set -x
kubectl get pods -n clabernetes -o yaml
echo "********************************"
echo "**** events ****"
echo "********************************"
kubectl get events -n clabernetes --sort-by='.lastTimestamp'
echo "********************************"
echo "**** logs ****"
echo "********************************"
kubectl logs -l clabernetes/name=clabernetes-manager -n clabernetes --tail=-1
exit 1