(Template) E2E Tests workflow #18
Workflow file for this run
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
# This workflow is a reusable one called by other workflows | |
name: E2E Tests workflow | |
on: | |
workflow_dispatch: | |
# Variables to set when calling this reusable workflow | |
inputs: | |
rancher_version: | |
description: Rancher version to deploy | |
required: true | |
type: string | |
default: 2.8-head | |
k3s_version: | |
description: k3s version of local cluster | |
required: true | |
type: string | |
default: v1.26.10+k3s1 | |
run_provisioning_tests: | |
required: true | |
default: true | |
type: boolean | |
run_importing_tests: | |
required: true | |
default: true | |
type: boolean | |
run_support_matrix_provisioning_tests: | |
required: true | |
default: true | |
type: boolean | |
run_support_matrix_importing_tests: | |
required: true | |
default: true | |
type: boolean | |
destroy_runner: | |
description: Destroy the auto-generated self-hosted runner | |
default: true | |
type: boolean | |
runner_template: | |
description: Runner template to use | |
default: hosted-prov-e2e-ci-runner-spot-n2-highmem-16-gl-template-v1 | |
type: string | |
zone: | |
description: GCP zone to host the runner (use region asia-south2) | |
default: asia-south2-a | |
type: string | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
EKS_REGION: ${{ secrets.EKS_REGION }} | |
GCP_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} | |
AKS_CLIENT_ID: ${{ secrets.AKS_CLIENT_ID }} | |
AKS_CLIENT_SECRET: ${{ secrets.AKS_CLIENT_SECRET }} | |
AKS_SUBSCRIPTION_ID: ${{ secrets.AKS_SUBSCRIPTION_ID }} | |
AKS_TENANT_ID: ${{ secrets.AKS_TENANT_ID }} | |
GKE_PROJECT_ID: ${{ secrets.GKE_PROJECT_ID }} | |
RANCHER_PASSWORD: rancherpassword | |
jobs: | |
create-runner: | |
runs-on: ubuntu-latest | |
outputs: | |
uuid: ${{ steps.generator.outputs.uuid }} | |
runner: ${{ steps.generator.outputs.runner }} | |
steps: | |
# actions/checkout MUST come before auth | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Generate UUID and Runner hostname | |
id: generator | |
run: | | |
UUID=$(uuidgen) | |
GH_REPO_FULL=${{ github.repository }} | |
GH_REPO=${GH_REPO_FULL#*/} | |
echo "uuid=${UUID//-}" >> ${GITHUB_OUTPUT} | |
echo "runner=${GH_REPO//\//-}-ci-${UUID//-}" >> ${GITHUB_OUTPUT} | |
- name: Authenticate to GCP | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} | |
- name: Setup gcloud | |
uses: google-github-actions/setup-gcloud@v1 | |
- name: Create runner | |
run: | | |
REGION=echo "${{ inputs.zone }}" | sed 's/-[abcdef]//' | |
gcloud compute instances create ${{ steps.generator.outputs.runner }} \ | |
--zone ${{ inputs.zone }} \ | |
--source-instance-template projects/${{ env.GKE_PROJECT_ID }}/regions/${REGION}/instanceTemplates/${{ inputs.runner_template }} &> /dev/null | |
- name: Allow traffic | |
run: | | |
gcloud compute instances add-tags ${{ steps.generator.outputs.runner }} \ | |
--tags http-server,https-server --zone ${{ inputs.zone }} | |
- name: Create GCP secrets | |
run: | | |
echo -n ${{ secrets.PAT_TOKEN }} \ | |
| gcloud secrets create PAT_TOKEN_${{ steps.generator.outputs.uuid }} --data-file=- | |
echo -n ${{ github.repository }} \ | |
| gcloud secrets create GH_REPO_${{ steps.generator.outputs.uuid }} --data-file=- | |
installation: | |
runs-on: ${{ needs.create-runner.outputs.uuid }} | |
needs: create-runner | |
outputs: | |
PUBLIC_IP: ${{ steps.runner-ip.outputs.PUBLIC_IP }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get Runner IP | |
id: runner-ip | |
run: echo "PUBLIC_IP=$(curl -s ifconfig.co)" >> "$GITHUB_OUTPUT" | |
- name: Install K3s / Helm / Rancher | |
env: | |
KUBECONFIG: /etc/rancher/k3s/k3s.yaml | |
HELM_VERSION: 3.13.1 | |
K3S_VERSION: ${{ inputs.k3s_version }} | |
RANCHER_VERSION: ${{ inputs.rancher_version }} | |
RANCHER_HOSTNAME: ${{steps.runner-ip.outputs.PUBLIC_IP}}.sslip.io | |
run: | | |
make prepare-e2e-ci-rancher | |
- name: Install Azure cli | |
run: | | |
sudo zypper install -y azure-cli | |
pip install azure-cli | |
- name: Login to Azure | |
uses: azure/login@v1 | |
with: | |
creds: '{"clientId":"${{ env.AKS_CLIENT_ID }}","clientSecret":"${{ env.AKS_CLIENT_SECRET }}","subscriptionId":"${{ env.AKS_SUBSCRIPTION_ID }}","tenantId":"${{ env.AKS_TENANT_ID }}"}' | |
- name: Install EKSCTL | |
run: | | |
# Better to always use the latest eksctl binary to avoid API version issue | |
EKSCTL_GH=https://github.com/weaveworks/eksctl/releases/latest/download | |
curl --location ${EKSCTL_GH}/eksctl_$(uname -s)_amd64.tar.gz | tar xz -C . | |
chmod +x eksctl | |
sudo mv eksctl /usr/local/bin | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4.0.0 | |
with: | |
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.EKS_REGION }} | |
provisioning-tests: | |
if: ${{ github.event.inputs.run_provisioning_tests == 'true' }} | |
needs: [create-runner, installation] | |
runs-on: ${{ needs.create-runner.outputs.uuid }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: go.mod | |
- name: Provisioning cluster tests | |
env: | |
RANCHER_HOSTNAME: ${{ needs.installation.outputs.PUBLIC_IP}}.sslip.io | |
CATTLE_TEST_CONFIG: ${{ github.workspace }}/cattle-config-provisioning.yaml | |
run: | | |
make e2e-provisioning-tests | |
importing-tests: | |
if: ${{ github.event.inputs.run_importing_tests == 'true' }} | |
needs: [create-runner, installation] | |
runs-on: ${{ needs.create-runner.outputs.uuid }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: go.mod | |
- name: Authenticate to GCP | |
uses: 'google-github-actions/auth@v1' | |
with: | |
credentials_json: '${{ env.GCP_CREDENTIALS }}' | |
- name: Setup gcloud | |
uses: google-github-actions/setup-gcloud@v1 | |
- name: Importing cluster tests | |
env: | |
RANCHER_HOSTNAME: ${{ needs.installation.outputs.PUBLIC_IP}}.sslip.io | |
CATTLE_TEST_CONFIG: ${{ github.workspace }}/cattle-config-import.yaml | |
run: | | |
make e2e-import-tests | |
support-matrix-provisioning-tests: | |
if: ${{ github.event.inputs.run_support_matrix_provisioning_tests == 'true' }} | |
needs: [create-runner, installation] | |
runs-on: ${{ needs.create-runner.outputs.uuid }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: go.mod | |
- name: Support matrix provisioning tests | |
env: | |
RANCHER_HOSTNAME: ${{ needs.installation.outputs.PUBLIC_IP}}.sslip.io | |
CATTLE_TEST_CONFIG: ${{ github.workspace }}/cattle-config-provisioning.yaml | |
run: | | |
make e2e-support-matrix-provisioning-tests | |
support-matrix-importing-tests: | |
if: ${{ github.event.inputs.run_support_matrix_importing_tests == 'true' }} | |
needs: [create-runner, installation] | |
runs-on: ${{ needs.create-runner.outputs.uuid }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: go.mod | |
- name: Authenticate to GCP | |
uses: 'google-github-actions/auth@v1' | |
with: | |
credentials_json: '${{ env.GCP_CREDENTIALS }}' | |
- name: Setup gcloud | |
uses: google-github-actions/setup-gcloud@v1 | |
- name: Support matrix importing tests | |
env: | |
RANCHER_HOSTNAME: ${{ needs.installation.outputs.PUBLIC_IP}}.sslip.io | |
CATTLE_TEST_CONFIG: ${{ github.workspace }}/cattle-config-import.yaml | |
run: | | |
make e2e-support-matrix-importing-tests | |
delete-runner: | |
if: ${{ always() && inputs.destroy_runner == true }} | |
needs: [create-runner, installation, provisioning-tests, importing-tests, support-matrix-provisioning-tests, support-matrix-importing-tests] | |
runs-on: ubuntu-latest | |
steps: | |
# actions/checkout MUST come before auth | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Authenticate to GCP | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} | |
- name: Setup gcloud | |
uses: google-github-actions/setup-gcloud@v1 | |
- name: Delete PAT token secret | |
run: | | |
gcloud --quiet secrets delete PAT_TOKEN_${{ needs.create-runner.outputs.uuid }} | |
- name: Delete runner | |
run: | | |
gcloud --quiet compute instances delete ${{ needs.create-runner.outputs.runner }} \ | |
--delete-disks all \ | |
--zone ${{ inputs.zone }} |