Skip to content

E2E Gitjob

E2E Gitjob #1589

Workflow file for this run

name: E2E Gitjob
on:
schedule:
# Run everyday day at 7:00 AM
- cron: '0 7 * * *'
pull_request:
paths-ignore:
- 'docs/**'
- 'scripts/**'
- '*.md'
workflow_dispatch:
env:
GOARCH: amd64
CGO_ENABLED: 0
jobs:
e2e-gitjob-test:
runs-on: ubuntu-latest
strategy:
matrix:
k3s_version:
# k3d version list k3s | sed 's/+/-/' | sort -h
# - v1.24.1-k3s1
- v1.22.10-k3s1
steps:
-
uses: actions/checkout@v4
with:
fetch-depth: 0
-
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
check-latest: true
-
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
-
name: Install Ginkgo CLI
run: go install github.com/onsi/ginkgo/v2/ginkgo@v2.1
-
name: Build Binaries
run: |
go build -o "bin/gitjob"
go build -o bin/gitcloner ./cmd/gitcloner
-
name: Build Docker Images
run: |
docker build -f package/Dockerfile -t rancher/gitjob:dev .
-
name: Install k3d
run: curl --silent --fail https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=${{ env.SETUP_K3D_VERSION }} bash
-
name: Provision k3d Cluster
run: |
k3d cluster create k3s-default --wait \
--agents 3 \
--network "nw01" \
--image docker.io/rancher/k3s:${{matrix.k3s_version}}
-
name: Import Images Into k3d
run: |
k3d image import rancher/gitjob:dev
-
name: Deploy
run: |
# FIXME this generates a template file, can't copy it into crd/
go run pkg/crdgen/main.go > chart/templates/crds.yaml
HELM_VERSION=v0.0.0
sed -i \
-e "s/version:.*/version: $HELM_VERSION/" \
-e "s/appVersion:.*/appVersion: $HELM_VERSION/" \
chart/Chart.yaml
helm upgrade --install gitjob chart/ \
--set gitjob.tag=dev \
-n cattle-fleet-system --create-namespace --wait
-
name: Tests
run: |
go test -cover -tags=test $(go list ./... | grep -vE '/(e2e|integrationtests)')
-
name: E2E Tests
# git repo tests can't run for PRs from forks, because PRs don't have access to the secrets
if: github.repository == 'rancher/gitjob' && github.actor != 'dependabot[bot]'
run: |
export GIT_SSH_KEY="$GITHUB_WORKSPACE/id_ecdsa"
echo "${{ secrets.CI_SSH_KEY }}" > "$GIT_SSH_KEY"
ginkgo e2e/
-
name: Dump Failed Environment
if: failure()
run: |
mkdir -p tmp
kubectl get -A pod,secret,service,ingress -o json > tmp/cluster.json
kubectl get -A gitjobs -o json > tmp/gitjob.json
kubectl get -A events > tmp/events.log
helm list -A > tmp/helm.log
kubectl logs -n cattle-fleet-system -l app=gitjob > tmp/gitjobcontroller.log
-
name: Upload Logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: gha-gitjob-e2e-logs-${{ github.sha }}-${{ matrix.k3s_version }}-${{ github.run_id }}
path: |
tmp/*.json
tmp/*.log
retention-days: 2