diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 43566691e..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Build and Unit Test - -concurrency: - group: test-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -on: - push: - branches: - - main - - release-* - tags: - - '*' - paths-ignore: - - '**.md' - pull_request: - branches: - - main - - release-* - paths-ignore: - - 'config/**' - - '**.md' - -env: - GO_VERSION: '1.22' - -jobs: - build: - name: Build and Unit Test - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GO_VERSION }} - - 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 - run: | - make build - - name: Image build - run: | - make docker-build diff --git a/.github/workflows/test.yml b/.github/workflows/build_test.yml similarity index 63% rename from .github/workflows/test.yml rename to .github/workflows/build_test.yml index 33cf15e43..76502670d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/build_test.yml @@ -1,5 +1,3 @@ -name: E2E Tests - on: pull_request: types: @@ -18,12 +16,11 @@ env: REGISTRY_REPO: 'oci://ghcr.io/mirantis/hmc/charts-ci' jobs: - setup: - if: ${{ contains( github.event.pull_request.labels.*.name, 'test e2e') }} + build: concurrency: - group: e2e-${{ github.head_ref || github.run_id }} + group: build-${{ github.head_ref || github.run_id }} cancel-in-progress: true - name: Setup + name: Build and Test runs-on: ubuntu-latest outputs: version: ${{ steps.vars.outputs.version }} @@ -33,6 +30,15 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + - 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 @@ -63,30 +69,21 @@ jobs: make hmc-chart-release make helm-push - provider-onprem-e2etest: - name: On-Prem Providers - runs-on: self-hosted - if: ${{ contains( github.event.pull_request.labels.*.name, 'test e2e') }} - needs: setup + controller-e2etest: + name: E2E Controller + runs-on: ubuntu-latest + needs: build concurrency: - group: onprem-e2e-${{ github.head_ref || github.run_id }} + group: cloud-e2e-${{ github.head_ref || github.run_id }} cancel-in-progress: true - outputs: - clustername: ${{ needs.setup.outputs.clustername }} - version: ${{ needs.setup.outputs.version }} env: - GINKGO_LABEL_FILTER: "provider:onprem" - 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 }} + GINKGO_LABEL_FILTER: 'provider:cloud' + 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 }} + outputs: + clustername: ${{ needs.build.outputs.clustername }} + version: ${{ needs.build.outputs.version }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -100,34 +97,84 @@ jobs: uses: azure/setup-kubectl@v4 - name: Run E2E tests env: - MANAGED_CLUSTER_NAME: ${{ needs.setup.outputs.clustername }} - IMG: 'ghcr.io/mirantis/hmc/controller-ci:${{ needs.setup.outputs.version }}' + GINKGO_LABEL_FILTER: '!provider' + MANAGED_CLUSTER_NAME: ${{ needs.build.outputs.clustername }} + IMG: 'ghcr.io/mirantis/hmc/controller-ci:${{ needs.build.outputs.version }}' run: | make test-e2e - name: Archive test results if: ${{ failure() }} uses: actions/upload-artifact@v4 with: - name: vsphere-e2e-test-logs + name: cloud-e2etest-logs path: | test/e2e/*.log provider-cloud-e2etest: - name: Cloud Providers + name: E2E Cloud Providers runs-on: ubuntu-latest if: ${{ contains( github.event.pull_request.labels.*.name, 'test e2e') }} - needs: setup + needs: build concurrency: group: cloud-e2e-${{ github.head_ref || github.run_id }} cancel-in-progress: true env: - GINKGO_LABEL_FILTER: "provider:cloud" + GINKGO_LABEL_FILTER: 'provider:cloud' 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 }} outputs: - clustername: ${{ needs.setup.outputs.clustername }} - version: ${{ needs.setup.outputs.version }} + clustername: ${{ needs.build.outputs.clustername }} + version: ${{ needs.build.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: Setup kubectl + uses: azure/setup-kubectl@v4 + - name: Run E2E tests + env: + MANAGED_CLUSTER_NAME: ${{ needs.build.outputs.clustername }} + IMG: 'ghcr.io/mirantis/hmc/controller-ci:${{ needs.build.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: E2E On-Prem Providers + runs-on: self-hosted + if: ${{ contains( github.event.pull_request.labels.*.name, 'test e2e') }} + needs: build + concurrency: + group: onprem-e2e-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + outputs: + clustername: ${{ needs.build.outputs.clustername }} + version: ${{ needs.build.outputs.version }} + env: + GINKGO_LABEL_FILTER: 'provider:onprem' + 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 }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -141,24 +188,25 @@ jobs: uses: azure/setup-kubectl@v4 - name: Run E2E tests env: - MANAGED_CLUSTER_NAME: ${{ needs.setup.outputs.clustername }} - IMG: 'ghcr.io/mirantis/hmc/controller-ci:${{ needs.setup.outputs.version }}' + MANAGED_CLUSTER_NAME: ${{ needs.build.outputs.clustername }} + IMG: 'ghcr.io/mirantis/hmc/controller-ci:${{ needs.build.outputs.version }}' run: | make test-e2e - name: Archive test results if: ${{ failure() }} uses: actions/upload-artifact@v4 with: - name: e2e-test-logs + name: onprem-e2etest-logs path: | test/e2e/*.log + cleanup: name: Cleanup needs: - - setup + - build - provider-cloud-e2etest runs-on: ubuntu-latest - if: ${{ always() && !contains(needs.*.result, 'skipped') }} + if: ${{ always() && !contains(needs.provider-cloud-e2etest.result, 'skipped') && contains(needs.build.result, 'success') }} timeout-minutes: 15 steps: - name: Checkout repository @@ -174,6 +222,6 @@ jobs: 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 }} - CLUSTER_NAME: '${{ needs.setup.outputs.clustername }}' + CLUSTER_NAME: '${{ needs.build.outputs.clustername }}' run: | make dev-aws-nuke diff --git a/config/dev/hmc_values.yaml b/config/dev/hmc_values.yaml index c25b634c8..143b805bb 100644 --- a/config/dev/hmc_values.yaml +++ b/config/dev/hmc_values.yaml @@ -1,6 +1,6 @@ image: repository: ghcr.io/mirantis/hmc/controller-ci - tag: v0.0.1-242-g2f6fbc0 + tag: v0.0.1-263-g25424af controller: defaultRegistryURL: oci://ghcr.io/mirantis/hmc/charts-ci insecureRegistry: true diff --git a/templates/provider/hmc-templates/Chart.yaml b/templates/provider/hmc-templates/Chart.yaml index 7eff06326..dbadf3abc 100644 --- a/templates/provider/hmc-templates/Chart.yaml +++ b/templates/provider/hmc-templates/Chart.yaml @@ -13,7 +13,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: v0.0.1-251-gfea83d7 +version: v0.0.1-260-gdc88554 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. diff --git a/templates/provider/hmc-templates/files/release.yaml b/templates/provider/hmc-templates/files/release.yaml index 38a664312..ff7e24f45 100644 --- a/templates/provider/hmc-templates/files/release.yaml +++ b/templates/provider/hmc-templates/files/release.yaml @@ -1,9 +1,9 @@ apiVersion: hmc.mirantis.com/v1alpha1 kind: Release metadata: - name: hmc-0-0-1-251-gfea83d7 + name: hmc-0-0-1-260-gdc88554 spec: - version: v0.0.1-251-gfea83d7 + version: v0.0.1-260-gdc88554 hmc: template: hmc capi: diff --git a/templates/provider/hmc-templates/files/templates/hmc.yaml b/templates/provider/hmc-templates/files/templates/hmc.yaml index 3fa636cdb..df6daae6c 100644 --- a/templates/provider/hmc-templates/files/templates/hmc.yaml +++ b/templates/provider/hmc-templates/files/templates/hmc.yaml @@ -5,4 +5,4 @@ metadata: spec: helm: chartName: hmc - chartVersion: v0.0.1-251-gfea83d7 + chartVersion: v0.0.1-260-gdc88554 diff --git a/templates/provider/hmc/Chart.yaml b/templates/provider/hmc/Chart.yaml index b8d758c77..df0da340d 100644 --- a/templates/provider/hmc/Chart.yaml +++ b/templates/provider/hmc/Chart.yaml @@ -13,7 +13,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: v0.0.1-251-gfea83d7 +version: v0.0.1-260-gdc88554 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. diff --git a/templates/provider/hmc/values.yaml b/templates/provider/hmc/values.yaml index 3bbcb4417..3dd745eb0 100644 --- a/templates/provider/hmc/values.yaml +++ b/templates/provider/hmc/values.yaml @@ -19,7 +19,7 @@ containerSecurityContext: - ALL image: repository: ghcr.io/mirantis/hmc/controller - tag: v0.0.1-251-gfea83d7 + tag: v0.0.1-260-gdc88554 pullPolicy: IfNotPresent resources: limits: diff --git a/test/e2e/controller.go b/test/e2e/controller.go new file mode 100644 index 000000000..2de02d163 --- /dev/null +++ b/test/e2e/controller.go @@ -0,0 +1,7 @@ +package e2e + +import ( + . "github.com/onsi/ginkgo/v2" +) + +var _ = Describe("Controller", Label("controller"), Ordered, func() {}) diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index 990c95b25..96f94cc52 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -61,7 +61,7 @@ var _ = BeforeSuite(func() { By("validating that the hmc-controller and CAPI provider controller is running and ready") kc := kubeclient.NewFromLocal(internalutils.DefaultSystemNamespace) Eventually(func() error { - err = verifyControllersUp(kc, managedcluster.ProviderCAPI) + err = verifyControllersUp(kc) if err != nil { _, _ = fmt.Fprintf(GinkgoWriter, "Controller validation failed: %v\n", err) return err @@ -85,20 +85,18 @@ var _ = AfterSuite(func() { } }) -// verifyControllersUp validates that controllers for the given providers list -// are running and ready. Optionally specify providers to check for rather than -// waiting for all providers to be ready. -func verifyControllersUp(kc *kubeclient.KubeClient, providers ...managedcluster.ProviderType) error { +// verifyControllersUp validates that controllers for all providers are running +// and ready. +func verifyControllersUp(kc *kubeclient.KubeClient) error { if err := validateController(kc, utils.HMCControllerLabel, "hmc-controller-manager"); err != nil { return err } - if providers == nil { - providers = []managedcluster.ProviderType{ - managedcluster.ProviderCAPI, - managedcluster.ProviderAWS, - managedcluster.ProviderAzure, - } + providers := []managedcluster.ProviderType{ + managedcluster.ProviderCAPI, + managedcluster.ProviderAWS, + managedcluster.ProviderAzure, + managedcluster.ProviderVSphere, } for _, provider := range providers { diff --git a/test/e2e/managedcluster/clusteridentity/clusteridentity.go b/test/e2e/managedcluster/clusteridentity/clusteridentity.go index 77b7adc35..798660d97 100644 --- a/test/e2e/managedcluster/clusteridentity/clusteridentity.go +++ b/test/e2e/managedcluster/clusteridentity/clusteridentity.go @@ -1,3 +1,17 @@ +// Copyright 2024 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package clusteridentity import ( diff --git a/test/e2e/provider_aws_test.go b/test/e2e/provider_aws_test.go index b748cd93f..540a25381 100644 --- a/test/e2e/provider_aws_test.go +++ b/test/e2e/provider_aws_test.go @@ -45,17 +45,6 @@ var _ = Describe("AWS Templates", Label("provider:cloud", "provider:aws"), Order By("setting AWS credentials") kc = kubeclient.NewFromLocal(internalutils.DefaultSystemNamespace) clusteridentity.New(kc, managedcluster.ProviderAWS) - - By("verifying CAPA controller is running and ready") - Eventually(func() error { - err := verifyControllersUp(kc, managedcluster.ProviderCAPI, managedcluster.ProviderAWS) - if err != nil { - _, _ = fmt.Fprintf( - GinkgoWriter, "controller validation failed: %v\n", err) - return err - } - return nil - }).WithTimeout(5 * time.Minute).WithPolling(10 * time.Second).Should(Succeed()) }) AfterAll(func() { @@ -130,7 +119,7 @@ var _ = Describe("AWS Templates", Label("provider:cloud", "provider:aws"), Order templateBy(managedcluster.TemplateAWSHostedCP, "validating that the controller is ready") Eventually(func() error { - err := verifyControllersUp(standaloneClient, managedcluster.ProviderCAPI, managedcluster.ProviderAWS) + err := verifyControllersUp(standaloneClient) if err != nil { _, _ = fmt.Fprintf( GinkgoWriter, "[%s] controller validation failed: %v\n",