|
| 1 | +name: "E2E CI" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + debug: |
| 8 | + description: "Enable debug logs" |
| 9 | + required: false |
| 10 | + default: "false" |
| 11 | + k3s_version: |
| 12 | + description: "Version of k3s to use for the underlying cluster, should exist in https://hub.docker.com/r/rancher/k3s/tags" |
| 13 | + required: false |
| 14 | + pull_request: |
| 15 | + paths-ignore: |
| 16 | + - 'docs/**' |
| 17 | + - '*.md' |
| 18 | + - '.gitignore' |
| 19 | + - 'CODEOWNERS' |
| 20 | + - 'LICENSE' |
| 21 | + - 'Makefile' |
| 22 | + push: |
| 23 | + branches: |
| 24 | + - main |
| 25 | + - release/v[0-9]+.x |
| 26 | + - release/v[0-9]+.[0-9]+.[0-9]+ |
| 27 | + paths-ignore: |
| 28 | + - 'docs/**' |
| 29 | + - '*.md' |
| 30 | + - '.gitignore' |
| 31 | + - 'CODEOWNERS' |
| 32 | + - 'LICENSE' |
| 33 | +env: |
| 34 | + GOARCH: amd64 |
| 35 | + CGO_ENABLED: 0 |
| 36 | + SETUP_GO_VERSION: '^1.20' |
| 37 | + YQ_VERSION: v4.25.1 |
| 38 | + K3S_MIN_VERSION_TAG: v1.31.10-k3s1 |
| 39 | + E2E_CI: true |
| 40 | + REPO: rancher |
| 41 | + APISERVER_PORT: 8001 |
| 42 | + DEFAULT_SLEEP_TIMEOUT_SECONDS: 10 |
| 43 | + KUBECTL_WAIT_TIMEOUT: 300s |
| 44 | + DEBUG: ${{ github.event.inputs.debug || false }} |
| 45 | + CLUSTER_NAME: 'e2e-ci-kuberlr-kubectl' |
| 46 | + |
| 47 | +permissions: |
| 48 | + contents: write |
| 49 | + |
| 50 | +jobs: |
| 51 | + e2e-kuberlr-kubectl: |
| 52 | + strategy: |
| 53 | + matrix: |
| 54 | + arch: |
| 55 | + - x64 |
| 56 | + - arm64 |
| 57 | + runs-on: ${{ github.repository == 'rancher/kuberlr-kubectl' && format('runs-on,image=ubuntu22-full-{1},runner=4cpu-linux-{1},run-id={0}', github.run_id, matrix.arch) || 'ubuntu-latest' }} |
| 58 | + steps: |
| 59 | + - |
| 60 | + # Add support for more platforms with QEMU (optional) |
| 61 | + # https://github.com/docker/setup-qemu-action |
| 62 | + name: Set up QEMU |
| 63 | + uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3 |
| 64 | + - |
| 65 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 |
| 66 | + with: |
| 67 | + fetch-depth: 0 |
| 68 | + - uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5 |
| 69 | + with: |
| 70 | + go-version: '>=1.20.0' |
| 71 | + - uses: azure/setup-kubectl@3e0aec4d80787158d308d7b364cb1b702e7feb7f # v4 |
| 72 | + - name : Install helm |
| 73 | + uses: azure/setup-helm@b9e51907a09c216f16ebe8536097933489208112 # v4 |
| 74 | + with: |
| 75 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + - name: Check if yq is installed |
| 77 | + id: check_yq |
| 78 | + run: | |
| 79 | + if ! command -v yq &> /dev/null; then |
| 80 | + echo "yq not found, installing..." |
| 81 | + echo "::set-output name=install_yq::true" |
| 82 | + else |
| 83 | + echo "yq is already installed" |
| 84 | + YQ_BIN=$(which yq) |
| 85 | + echo "::set-output name=install_yq::false" |
| 86 | + echo "::set-output name=yq_path::$YQ_BIN" |
| 87 | + fi |
| 88 | + - name : Install YQ |
| 89 | + if: steps.check_yq.outputs.install_yq == 'true' |
| 90 | + run: | |
| 91 | + sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${{ matrix.arch == 'x64' && 'amd64' || matrix.arch }} -O /usr/bin/yq && sudo chmod +x /usr/bin/yq; |
| 92 | + - name : Export image version |
| 93 | + run : | |
| 94 | + source ./scripts/version |
| 95 | + echo REPO=$REPO >> $GITHUB_ENV |
| 96 | + echo IMAGE=$IMAGE >> $GITHUB_ENV |
| 97 | + echo TAG=$TAG >> $GITHUB_ENV |
| 98 | + echo FULL_IMAGE=$FULL_IMAGE >> $GITHUB_ENV |
| 99 | +
|
| 100 | + - name: Set K3S_VERSION |
| 101 | + run: echo "K3S_VERSION=${{ inputs.k3s_version || env.K3S_MIN_VERSION_TAG }}" >> $GITHUB_ENV |
| 102 | + - |
| 103 | + name: Perform pre-e2e image build |
| 104 | + run: | |
| 105 | + make package; |
| 106 | + make package-helm; |
| 107 | + - |
| 108 | + name : Install k3d |
| 109 | + run : ./.github/workflows/e2e/scripts/install-k3d.sh |
| 110 | + - |
| 111 | + name : Setup k3d cluster |
| 112 | + run : ./.github/workflows/e2e/scripts/setup-cluster.sh |
| 113 | + - |
| 114 | + name: Import Images Into k3d |
| 115 | + run: | |
| 116 | + k3d image import ${FULL_IMAGE} -c $CLUSTER_NAME; |
| 117 | + - |
| 118 | + name: Setup kubectl context |
| 119 | + run: | |
| 120 | + kubectl config use-context "k3d-$CLUSTER_NAME"; |
| 121 | + - |
| 122 | + name: Install Kuberlr-Kubectl |
| 123 | + run: ./.github/workflows/e2e/scripts/install-ci-chart.sh; |
| 124 | + - |
| 125 | + name: Check if Kuberlr-Kubectl is up |
| 126 | + run: ./.github/workflows/e2e/scripts/validate-ci-chart.sh; |
| 127 | + |
| 128 | + - |
| 129 | + name: Uninstall Kuberlr-Kubectl |
| 130 | + run: ./.github/workflows/e2e/scripts/uninstall-ci-chart.sh; |
| 131 | + - name: Generate artifacts on failure |
| 132 | + if: failure() |
| 133 | + run: ./.github/workflows/e2e/scripts/generate-artifacts.sh; |
| 134 | + - name: Upload logs and manifests on failure |
| 135 | + if: failure() |
| 136 | + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4 |
| 137 | + with: |
| 138 | + name: artifacts-${{ matrix.arch }}-${{ inputs.k3s_version || env.K3S_MIN_VERSION_TAG }} |
| 139 | + path: artifacts/ |
| 140 | + retention-days: 1 |
| 141 | + - |
| 142 | + name: Delete k3d cluster |
| 143 | + if: always() |
| 144 | + run: k3d cluster delete e2e-ci-kuberlr-kubectl |
0 commit comments