Skip to content

Commit

Permalink
Break e2e tests into own workflow, use pull_request for build workflow
Browse files Browse the repository at this point in the history
This patch breaks the e2e test and build workflows apart making it so that
the build workflow no longer relies on 'pull_request_target' to function.

We now have 2 workflow files, one for build and unit tests which uses
'pull_request' and one for e2e tests that uses 'pull_request_target'.

Signed-off-by: Kyle Squizzato <[email protected]>
  • Loading branch information
squizzi committed Oct 29, 2024
1 parent 9cb3960 commit aa27078
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 49 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build_unit_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and Unit Tests
on:
pull_request:
types:
- labeled
- opened
- synchronize
- reopened
branches:
- main
- release-*
paths-ignore:
- 'config/**'
- '**.md'
- '.github/**'
push:
tags:
- '*'

env:
GO_VERSION: '1.22'

jobs:
build:
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
name: Build and Unit Test
runs-on: ubuntu-latest
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: Lint
uses: golangci/golangci-lint-action@v6
with:
args: --timeout 10m0s
- name: Verify all generated pieces are up-to-date
run: make generate-all && git add -N . && git diff --exit-code
- name: Unit tests
run: |
make test
- name: Build HMC controller image
run: |
make docker-build
91 changes: 42 additions & 49 deletions .github/workflows/build_test.yml → .github/workflows/e2e_test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: E2E Tests
on:
pull_request_target:
types:
Expand All @@ -22,11 +22,11 @@ env:
REGISTRY_REPO: 'oci://ghcr.io/mirantis/hmc/charts-ci'

jobs:
build:
push:
concurrency:
group: build-${{ github.head_ref || github.run_id }}
group: push-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
name: Build and Unit Test
name: Push Images and Charts to GHCR
runs-on: ubuntu-latest
outputs:
version: ${{ steps.vars.outputs.version }}
Expand Down Expand Up @@ -69,15 +69,6 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- name: Lint
uses: golangci/golangci-lint-action@v6
with:
args: --timeout 10m0s
- name: Verify all generated pieces are up-to-date
run: make generate-all && git add -N . && git diff --exit-code
- name: Unit tests
run: |
make test
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
Expand All @@ -92,7 +83,8 @@ jobs:
GIT_VERSION=$(git describe --tags --always)
echo "version=${GIT_VERSION:1}" >> $GITHUB_OUTPUT
echo "clustername=ci-$(date +%s | cut -b6-10)" >> $GITHUB_OUTPUT
- name: Build and push HMC controller image
- name: Push HMC Controller Image to GHCR
if:
uses: docker/build-push-action@v6
with:
build-args: |
Expand All @@ -104,36 +96,37 @@ jobs:
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Prepare and push HMC template charts
- name: Prepare and push HMC template charts to GHCR
run: |
make hmc-chart-release
make helm-push
controller-e2etest:
name: E2E Controller
name: Controller
runs-on: ubuntu-latest
needs: build
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.build.outputs.clustername }}
version: ${{ needs.build.outputs.version }}
pr: ${{ needs.build.outputs.pr }}
clustername: ${{ needs.push.outputs.clustername }}
version: ${{ needs.push.outputs.version }}
pr: ${{ needs.push.outputs.pr }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{fromJSON(needs.build.outputs.pr).merge_commit_sha}}
ref: ${{fromJSON(needs.push.outputs.pr).merge_commit_sha}}
- name: Setup kubectl
uses: azure/setup-kubectl@v4
- name: Run E2E tests
env:
GINKGO_LABEL_FILTER: 'controller'
MANAGED_CLUSTER_NAME: ${{ needs.build.outputs.clustername }}
IMG: 'ghcr.io/mirantis/hmc/controller-ci:${{ needs.build.outputs.version }}'
VERSION: ${{ needs.build.outputs.version }}
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
Expand All @@ -145,17 +138,17 @@ jobs:
test/e2e/*.log
provider-cloud-e2etest:
name: E2E Cloud Providers
name: Cloud Providers
runs-on: ubuntu-latest
if: ${{ contains( github.event.pull_request.labels.*.name, 'test e2e') }}
needs: build
needs: push
concurrency:
group: cloud-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
outputs:
clustername: ${{ needs.build.outputs.clustername }}
version: ${{ needs.build.outputs.version }}
pr: ${{ needs.build.outputs.pr }}
clustername: ${{ needs.push.outputs.clustername }}
version: ${{ needs.push.outputs.version }}
pr: ${{ needs.push.outputs.pr }}
env:
AWS_REGION: us-west-2
AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_ACCESS_KEY_ID }}
Expand All @@ -170,7 +163,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{fromJSON(needs.build.outputs.pr).merge_commit_sha}}
ref: ${{fromJSON(needs.push.outputs.pr).merge_commit_sha}}
- name: Setup Go
uses: actions/setup-go@v5
with:
Expand All @@ -181,9 +174,9 @@ jobs:
- name: Run E2E tests
env:
GINKGO_LABEL_FILTER: 'provider:cloud'
MANAGED_CLUSTER_NAME: ${{ needs.build.outputs.clustername }}
IMG: 'ghcr.io/mirantis/hmc/controller-ci:${{ needs.build.outputs.version }}'
VERSION: ${{ needs.build.outputs.version }}
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
Expand All @@ -195,17 +188,17 @@ jobs:
test/e2e/*.log
provider-onprem-e2etest:
name: E2E On-Prem Providers
name: On-Prem Providers
runs-on: self-hosted
if: ${{ contains( github.event.pull_request.labels.*.name, 'test e2e') }}
needs: build
needs: push
concurrency:
group: onprem-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
outputs:
clustername: ${{ needs.build.outputs.clustername }}
version: ${{ needs.build.outputs.version }}
pr: ${{ needs.build.outputs.pr }}
clustername: ${{ needs.push.outputs.clustername }}
version: ${{ needs.push.outputs.version }}
pr: ${{ needs.push.outputs.pr }}
env:
VSPHERE_USER: ${{ secrets.CI_VSPHERE_USER }}
VSPHERE_PASSWORD: ${{ secrets.CI_VSPHERE_PASSWORD }}
Expand All @@ -224,7 +217,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{fromJSON(needs.build.outputs.pr).merge_commit_sha}}
ref: ${{fromJSON(needs.push.outputs.pr).merge_commit_sha}}
- name: Setup Go
uses: actions/setup-go@v5
with:
Expand All @@ -234,9 +227,9 @@ jobs:
- name: Run E2E tests
env:
GINKGO_LABEL_FILTER: 'provider:onprem'
MANAGED_CLUSTER_NAME: ${{ needs.build.outputs.clustername }}
IMG: 'ghcr.io/mirantis/hmc/controller-ci:${{ needs.build.outputs.version }}'
VERSION: ${{ needs.build.outputs.version }}
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
Expand All @@ -250,21 +243,21 @@ jobs:
cleanup:
name: Cleanup
needs:
- build
- push
- provider-cloud-e2etest
runs-on: ubuntu-latest
if: ${{ always() && !contains(needs.provider-cloud-e2etest.result, 'skipped') && contains(needs.build.result, 'success') }}
if: ${{ always() && !contains(needs.provider-cloud-e2etest.result, 'skipped') && contains(needs.push.result, 'success') }}
timeout-minutes: 15
outputs:
clustername: ${{ needs.build.outputs.clustername }}
version: ${{ needs.build.outputs.version }}
pr: ${{ needs.build.outputs.pr }}
clustername: ${{ needs.push.outputs.clustername }}
version: ${{ needs.push.outputs.version }}
pr: ${{ needs.push.outputs.pr }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{fromJSON(needs.build.outputs.pr).merge_commit_sha}}
ref: ${{fromJSON(needs.push.outputs.pr).merge_commit_sha}}
- name: Setup Go
uses: actions/setup-go@v5
with:
Expand All @@ -279,7 +272,7 @@ jobs:
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.build.outputs.clustername }}'
CLUSTER_NAME: '${{ needs.push.outputs.clustername }}'
run: |
make dev-aws-nuke
make dev-azure-nuke

0 comments on commit aa27078

Please sign in to comment.