Skip to content

Commit

Permalink
Merge PR workflows together
Browse files Browse the repository at this point in the history
Signed-off-by: Kyle Squizzato <[email protected]>
  • Loading branch information
squizzi committed Sep 25, 2024
1 parent dc88554 commit 61c03e3
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 123 deletions.
52 changes: 0 additions & 52 deletions .github/workflows/build.yml

This file was deleted.

130 changes: 89 additions & 41 deletions .github/workflows/test.yml → .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
name: E2E Tests

on:
pull_request:
types:
Expand All @@ -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 }}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion config/dev/hmc_values.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/provider/hmc-templates/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions templates/provider/hmc-templates/files/release.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion templates/provider/hmc-templates/files/templates/hmc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ metadata:
spec:
helm:
chartName: hmc
chartVersion: v0.0.1-251-gfea83d7
chartVersion: v0.0.1-260-gdc88554
2 changes: 1 addition & 1 deletion templates/provider/hmc/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion templates/provider/hmc/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/controller.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package e2e

import (
. "github.com/onsi/ginkgo/v2"
)

var _ = Describe("Controller", Label("controller"), Ordered, func() {})
20 changes: 9 additions & 11 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions test/e2e/managedcluster/clusteridentity/clusteridentity.go
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
Loading

0 comments on commit 61c03e3

Please sign in to comment.