Skip to content

test

test #6

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
env:
GO_VERSION: "1.21"
jobs:
unit:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: set up go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: install go test tools
run: |
go install gotest.tools/gotestsum@${{ vars.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: set up go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: install go test tools
run: |
go install gotest.tools/gotestsum@${{ vars.GOTESTSUM_VERSION }}
- name: install devspace
run: |
curl -L -o devspace \
"https://github.com/loft-sh/devspace/releases/download/${{ vars.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
- 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