E2E on GKE #154
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: E2E on GKE | |
on: | |
schedule: | |
- cron: '0 1 * * *' | |
workflow_dispatch: | |
inputs: | |
ref: | |
description: "checkout git branch/tag" | |
required: true | |
default: "main" | |
keep_cluster: | |
description: "Keep the cluster afterwards?" | |
required: false | |
default: "no" | |
env: | |
GOARCH: amd64 | |
CGO_ENABLED: 0 | |
GINKGO_NODES: 1 | |
FLAKE_ATTEMPTS: 1 | |
GKE_ZONE: 'europe-west1-b' | |
GKE_MACHINE_TYPE: 'n2-standard-4' | |
jobs: | |
gke-fleet-examples: | |
runs-on: ubuntu-latest | |
if: > | |
github.repository == 'rancher/fleet' | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
fetch-depth: 0 | |
- | |
name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
check-latest: true | |
- | |
name: Setup Ginkgo Test Framework | |
run: go install github.com/onsi/ginkgo/v2/ginkgo | |
- | |
name: Authenticate to GCP | |
uses: 'google-github-actions/auth@v2' | |
with: | |
credentials_json: '${{ secrets.CI_GOOGLE_CREDENTIALS }}' | |
- | |
name: Setup gcloud | |
uses: google-github-actions/setup-gcloud@v2 | |
with: | |
install_components: 'gke-gcloud-auth-plugin' | |
- | |
name: Install gcloud kubectl version | |
run: gcloud components install kubectl | |
- | |
# needs a project and a network | |
name: Create GKE cluster | |
id: create-cluster | |
run: | | |
id=$RANDOM | |
echo "ID=$id" >> $GITHUB_OUTPUT | |
gcloud container clusters create fleetci$id \ | |
--disk-size 100 \ | |
--num-nodes=1 \ | |
--machine-type ${{ env.GKE_MACHINE_TYPE }} \ | |
--no-enable-cloud-logging \ | |
--no-enable-cloud-monitoring \ | |
--network fleet-ci \ | |
--zone ${{ env.GKE_ZONE }} | |
- | |
name: Get kubeconfig file from GKE | |
env: | |
USE_GKE_GCLOUD_AUTH_PLUGIN: True | |
run: | | |
id="${{ steps.create-cluster.outputs.ID }}" | |
gcloud container clusters get-credentials fleetci$id --zone ${{ env.GKE_ZONE }} --project ${{ secrets.CI_GOOGLE_PROJECT }} | |
- | |
name: Build fleet binaries | |
run: | | |
./.github/scripts/build-fleet-binaries.sh | |
- | |
name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Get UUID | |
id: uuid | |
run: echo "uuid=$(uuidgen)" >> $GITHUB_OUTPUT | |
- | |
id: meta-fleet | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ttl.sh/rancher/fleet-${{ steps.uuid.outputs.uuid }} | |
tags: type=raw,value=1h | |
- | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: package/Dockerfile | |
build-args: | | |
ARCH=${{ env.GOARCH }} | |
push: true | |
tags: ${{ steps.meta-fleet.outputs.tags }} | |
labels: ${{ steps.meta-fleet.outputs.labels }} | |
- | |
id: meta-fleet-agent | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ttl.sh/rancher/fleet-agent-${{ steps.uuid.outputs.uuid }} | |
tags: type=raw,value=1h | |
- | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: package/Dockerfile.agent | |
build-args: | | |
ARCH=${{ env.GOARCH }} | |
push: true | |
tags: ${{ steps.meta-fleet-agent.outputs.tags }} | |
labels: ${{ steps.meta-fleet-agent.outputs.labels }} | |
- | |
name: Deploy Fleet | |
run: | | |
kc_node=$(kubectl get nodes --no-headers -o name | head -n 1) | |
node=${kc_node#node/} | |
echo "${{ steps.meta-fleet.outputs.tags }} ${{ steps.meta-fleet-agent.outputs.tags }}" | |
NODE=$node SHARDS='[{"id":"shard0"},{"id":"shard1"},{"id":"shard2"}]' ./.github/scripts/deploy-fleet.sh \ | |
${{ steps.meta-fleet.outputs.tags }} \ | |
${{ steps.meta-fleet-agent.outputs.tags }} | |
- | |
name: Fleet E2E Tests | |
env: | |
FLEET_E2E_NS: fleet-local | |
run: | | |
ginkgo --github-output --label-filter='!infra-setup' e2e/single-cluster e2e/keep-resources | |
- | |
name: Acceptance Tests for Examples | |
env: | |
FLEET_E2E_NS: fleet-local | |
run: | | |
ginkgo --github-output e2e/acceptance/single-cluster-examples | |
- | |
name: Fleet Tests Requiring Github Secrets | |
# These tests can't run for PRs, because PRs don't have access to the secrets | |
env: | |
FLEET_E2E_NS: fleet-local | |
GIT_REPO_URL: "[email protected]:fleetrepoci/testgke.git" | |
GIT_REPO_HOST: "github.com" | |
GIT_REPO_USER: "git" | |
CI_OCI_USERNAME: ${{ secrets.CI_OCI_USERNAME }} | |
CI_OCI_PASSWORD: ${{ secrets.CI_OCI_PASSWORD }} | |
run: | | |
export GIT_SSH_KEY="$GITHUB_WORKSPACE/id_ecdsa" | |
export GIT_SSH_PUBKEY="$GITHUB_WORKSPACE/id_ecdsa.pub" | |
echo "${{ secrets.CI_GKE_SSH_KEY }}" > "$GIT_SSH_KEY" | |
echo "${{ secrets.CI_GKE_SSH_PUBKEY }}" > "$GIT_SSH_PUBKEY" | |
ginkgo --github-output e2e/require-secrets | |
- | |
name: Delete GKE cluster | |
if: ${{ always() && github.event.inputs.keep_cluster != 'yes' }} | |
run: | | |
id="${{ steps.create-cluster.outputs.ID }}" | |
gcloud container clusters delete fleetci$id --zone ${{ env.GKE_ZONE }} --quiet |