Break workflows into separate 'E2E Test' and 'Build and Unit Test' workflows, use pull_request
instead of pull_request_target
across workflows
#2
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
name: E2E Tests | |
on: | |
pull_request: | |
types: | |
- labeled | |
- opened | |
- synchronize | |
- reopened | |
branches: | |
- main | |
- release-* | |
paths-ignore: | |
- 'config/**' | |
- '**.md' | |
push: | |
tags: | |
- '*' | |
env: | |
GO_VERSION: '1.22' | |
REGISTRY_REPO: 'oci://ghcr.io/mirantis/hmc/charts-ci' | |
jobs: | |
push: | |
concurrency: | |
group: push-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
name: Push Images and Charts to GHCR | |
runs-on: ubuntu-latest | |
if: ${{ contains( github.event.pull_request.labels.*.name, 'test e2e') }} | |
outputs: | |
version: ${{ steps.vars.outputs.version }} | |
clustername: ${{ steps.vars.outputs.clustername }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
cache: false | |
- name: Set up Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get outputs | |
id: vars | |
run: | | |
GIT_VERSION=$(git describe --tags --always) | |
echo "version=${GIT_VERSION:1}" >> $GITHUB_OUTPUT | |
echo "clustername=ci-$(date +%s | cut -b6-10)" >> $GITHUB_OUTPUT | |
- name: Push HMC Controller Image to GHCR | |
if: | |
uses: docker/build-push-action@v6 | |
with: | |
build-args: | | |
LD_FLAGS=-s -w -X github.com/Mirantis/hmc/internal/build.Version=${{ steps.vars.outputs.version }} | |
context: . | |
platforms: linux/amd64 | |
tags: | | |
ghcr.io/mirantis/hmc/controller-ci:${{ steps.vars.outputs.version }} | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Prepare and push HMC template charts to GHCR | |
run: | | |
make hmc-chart-release | |
make helm-push | |
controller-e2etest: | |
name: Controller | |
runs-on: ubuntu-latest | |
if: ${{ contains( github.event.pull_request.labels.*.name, 'test e2e') }} | |
needs: push | |
concurrency: | |
group: controller-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
outputs: | |
clustername: ${{ needs.push.outputs.clustername }} | |
version: ${{ needs.push.outputs.version }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup kubectl | |
uses: azure/setup-kubectl@v4 | |
- name: Run E2E tests | |
env: | |
GINKGO_LABEL_FILTER: 'controller' | |
MANAGED_CLUSTER_NAME: ${{ needs.push.outputs.clustername }} | |
IMG: 'ghcr.io/mirantis/hmc/controller-ci:${{ needs.push.outputs.version }}' | |
VERSION: ${{ needs.push.outputs.version }} | |
run: | | |
make test-e2e | |
- name: Archive test results | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cloud-e2etest-logs | |
path: | | |
test/e2e/*.log | |
provider-cloud-e2etest: | |
name: Cloud Providers | |
runs-on: ubuntu-latest | |
if: ${{ contains( github.event.pull_request.labels.*.name, 'test e2e') }} | |
needs: push | |
concurrency: | |
group: cloud-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
outputs: | |
clustername: ${{ needs.push.outputs.clustername }} | |
version: ${{ needs.push.outputs.version }} | |
env: | |
AWS_REGION: us-west-2 | |
AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_SECRET_ACCESS_KEY }} | |
AZURE_REGION: westus2 | |
AZURE_SUBSCRIPTION_ID: ${{ secrets.CI_AZURE_SUBSCRIPTION_ID }} | |
AZURE_TENANT_ID: ${{ secrets.CI_AZURE_TENANT_ID }} | |
AZURE_CLIENT_ID: ${{ secrets.CI_AZURE_CLIENT_ID }} | |
AZURE_CLIENT_SECRET: ${{ secrets.CI_AZURE_CLIENT_SECRET }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Setup kubectl | |
uses: azure/setup-kubectl@v4 | |
- uses: actions/checkout@v4 | |
- name: Run E2E tests | |
env: | |
GINKGO_LABEL_FILTER: 'provider:cloud' | |
MANAGED_CLUSTER_NAME: ${{ needs.push.outputs.clustername }} | |
IMG: 'ghcr.io/mirantis/hmc/controller-ci:${{ needs.push.outputs.version }}' | |
VERSION: ${{ needs.push.outputs.version }} | |
run: | | |
make test-e2e | |
- name: Archive test results | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cloud-e2etest-logs | |
path: | | |
test/e2e/*.log | |
provider-onprem-e2etest: | |
name: On-Prem Providers | |
runs-on: self-hosted | |
if: ${{ contains( github.event.pull_request.labels.*.name, 'test e2e') }} | |
needs: push | |
concurrency: | |
group: onprem-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
outputs: | |
clustername: ${{ needs.push.outputs.clustername }} | |
version: ${{ needs.push.outputs.version }} | |
env: | |
VSPHERE_USER: ${{ secrets.CI_VSPHERE_USER }} | |
VSPHERE_PASSWORD: ${{ secrets.CI_VSPHERE_PASSWORD }} | |
VSPHERE_SERVER: ${{ secrets.CI_VSPHERE_SERVER }} | |
VSPHERE_THUMBPRINT: ${{ secrets.CI_VSPHERE_THUMBPRINT }} | |
VSPHERE_DATACENTER: ${{ secrets.CI_VSPHERE_DATACENTER }} | |
VSPHERE_DATASTORE: ${{ secrets.CI_VSPHERE_DATASTORE }} | |
VSPHERE_RESOURCEPOOL: ${{ secrets.CI_VSPHERE_RESOURCEPOOL }} | |
VSPHERE_FOLDER: ${{ secrets.CI_VSPHERE_FOLDER }} | |
VSPHERE_CONTROL_PLANE_ENDPOINT: ${{ secrets.CI_VSPHERE_CONTROL_PLANE_ENDPOINT }} | |
VSPHERE_VM_TEMPLATE: ${{ secrets.CI_VSPHERE_VM_TEMPLATE }} | |
VSPHERE_NETWORK: ${{ secrets.CI_VSPHERE_NETWORK }} | |
VSPHERE_SSH_KEY: ${{ secrets.CI_VSPHERE_SSH_KEY }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Setup kubectl | |
uses: azure/setup-kubectl@v4 | |
- name: Run E2E tests | |
env: | |
GINKGO_LABEL_FILTER: 'provider:onprem' | |
MANAGED_CLUSTER_NAME: ${{ needs.push.outputs.clustername }} | |
IMG: 'ghcr.io/mirantis/hmc/controller-ci:${{ needs.push.outputs.version }}' | |
VERSION: ${{ needs.push.outputs.version }} | |
run: | | |
make test-e2e | |
- name: Archive test results | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: onprem-e2etest-logs | |
path: | | |
test/e2e/*.log | |
cleanup: | |
name: Cleanup | |
needs: | |
- push | |
- provider-cloud-e2etest | |
runs-on: ubuntu-latest | |
if: ${{ always() && !contains(needs.provider-cloud-e2etest.result, 'skipped') && contains(needs.push.result, 'success') }} | |
timeout-minutes: 15 | |
outputs: | |
clustername: ${{ needs.push.outputs.clustername }} | |
version: ${{ needs.push.outputs.version }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: AWS Test Resources | |
env: | |
AWS_REGION: us-west-2 | |
AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_SECRET_ACCESS_KEY }} | |
AZURE_REGION: westus2 | |
AZURE_SUBSCRIPTION_ID: ${{ secrets.CI_AZURE_SUBSCRIPTION_ID }} | |
AZURE_TENANT_ID: ${{ secrets.CI_AZURE_TENANT_ID }} | |
AZURE_CLIENT_ID: ${{ secrets.CI_AZURE_CLIENT_ID }} | |
AZURE_CLIENT_SECRET: ${{ secrets.CI_AZURE_CLIENT_SECRET }} | |
CLUSTER_NAME: '${{ needs.push.outputs.clustername }}' | |
run: | | |
make dev-aws-nuke | |
make dev-azure-nuke |