E2E on HCP Terraform Operator [Helm] #800
This file contains hidden or 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 HCP Terraform Operator [Helm] | |
| # To run this workflow locally, you can use https://github.com/nektos/act. | |
| # Act is a tool for executing GitHub Actions in your local environment. | |
| # First, export the required secrets as environment variables: | |
| # export TFC_OAUTH_TOKEN=<OAUTH_TOKEN> | |
| # export TFC_ORG=<ORG_NAME> | |
| # export TFC_TOKEN=<TOKEN> | |
| # export TFC_VCS_REPO=<VCS_REPO> | |
| # Then execute the workflow with: | |
| # act workflow_dispatch --rm \ | |
| # --container-architecture linux/arm64 \ | |
| # -P linux=catthehacker/ubuntu:act-latest \ | |
| # --var KIND_VERSION=0.30.0 \ | |
| # --var BIN_NAME=manager \ | |
| # --env PLATFORMS=arm64 \ | |
| # -s TFC_OAUTH_TOKEN \ | |
| # -s TFC_ORG \ | |
| # -s TFC_TOKEN \ | |
| # -s TFC_VCS_REPO \ | |
| # -W .github/workflows/helm-end-to-end-tfc.yaml | |
| on: | |
| schedule: | |
| - cron: '30 6 * * 0' | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'internal/controller/**' | |
| - 'charts/hcp-terraform-operator/**' | |
| workflow_dispatch: | |
| workflow_call: | |
| env: | |
| USE_EXISTING_CLUSTER: true | |
| CLUSTER_NAME: 'this' | |
| DOCKER_IMAGE: 'this' | |
| KUBECONFIG: ${{ github.workspace }}/.kube/config | |
| PLATFORMS: 'amd64' | |
| jobs: | |
| tests: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Set up kind | |
| uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0 | |
| with: | |
| wait: 2m | |
| version: v${{ vars.KIND_VERSION }} | |
| cluster_name: ${{ env.CLUSTER_NAME }} | |
| - name: Set up Helm | |
| uses: Azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0 | |
| with: | |
| version: v3.11.2 | |
| - name: Generate Docker image metadata | |
| id: meta | |
| uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 | |
| with: | |
| images: ${{ env.DOCKER_IMAGE }} | |
| tags: | | |
| type=sha,prefix=,format=short | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 | |
| with: | |
| platforms: ${{ env.PLATFORMS }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 | |
| - name: Build and load Docker image | |
| uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 | |
| with: | |
| platforms: linux/${{ env.PLATFORMS }} | |
| load: true | |
| build-args: | |
| BIN_NAME=${{ vars.BIN_NAME }} | |
| tags: ${{ env.DOCKER_METADATA_OUTPUT_TAGS }} | |
| - name: Upload Docker image to kind | |
| run: | | |
| kind load docker-image ${{ env.DOCKER_METADATA_OUTPUT_TAGS }} --name ${{ env.CLUSTER_NAME }} | |
| - name: Install Helm chart | |
| run: | | |
| helm install --wait --timeout 1m this ./charts/hcp-terraform-operator \ | |
| --set operator.image.repository=${{ env.DOCKER_IMAGE }} \ | |
| --set operator.image.tag=${{ env.DOCKER_METADATA_OUTPUT_VERSION }} \ | |
| --set operator.syncPeriod=30s \ | |
| --set controllers.agentPool.workers=5 \ | |
| --set controllers.agentToken.workers=5 \ | |
| --set controllers.module.workers=5 \ | |
| --set controllers.project.workers=5 \ | |
| --set controllers.runsCollector.workers=5 \ | |
| --set controllers.workspace.workers=5 | |
| - name: Run end-to-end test suite | |
| run: make test | |
| env: | |
| TFC_OAUTH_TOKEN: ${{ secrets.TFC_OAUTH_TOKEN }} | |
| TFC_ORG: ${{ secrets.TFC_ORG }} | |
| TFC_TOKEN: ${{ secrets.TFC_TOKEN }} | |
| TFC_VCS_REPO: ${{ secrets.TFC_VCS_REPO }} |