Skip to content

Commit

Permalink
Add Github Action for E2E
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderboltsid committed Jul 2, 2024
1 parent 63a7048 commit a0418af
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 10 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
on:
workflow_call:
inputs:
e2e-labels:
description: Labels to filter e2e tests
type: string
required: true

jobs:
test:
runs-on:
- self-hosted-ncn-dind
steps:
- name: Checkout
uses: actions/checkout@v4

# Install nix using cachix/install-nix-action if running on ARC runners
# See: https://github.com/DeterminateSystems/nix-installer-action/issues/68
- name: Install Nix on self-hosted ARC runners
uses: cachix/install-nix-action@V27
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Install devbox
uses: jetify-com/devbox-install-action@v0.11.0
with:
enable-cache: "true"
skip-nix-installation: "true"

- uses: actions/cache@v4
with:
path: |
~/.cache/golangci-lint
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get Control Plane endpoint IP
id: get-control-plane-endpoint-ip
run: |
export CONTROL_PLANE_ENDPOINT_RANGE_START="${{ vars.CONTROL_PLANE_ENDPOINT_RANGE_START }}"
export CONTROL_PLANE_ENDPOINT_RANGE_END="${{ vars.CONTROL_PLANE_ENDPOINT_RANGE_END }}"
control_plane_endpoint_ip="$(devbox run -- make nutanix-cp-endpoint-ip)"
echo "control_plane_endpoint_ip=${control_plane_endpoint_ip}" >> "${GITHUB_OUTPUT}"
- name: Check Control Plane endpoint IP
run: |
if [[ -z "${{ steps.get-control-plane-endpoint-ip.outputs.control_plane_endpoint_ip }}" ]]; then
echo "control_plane_endpoint_ip is empty; cannot proceed with e2e tests"
exit 1
fi
- name: Test build
run: devbox run -- make test-e2e LABEL_FILTERS='${{ inputs.e2e-labels }}'
env:
NUTANIX_USER: ${{ secrets.NUTANIX_USER }}
NUTANIX_PASSWORD: ${{ secrets.NUTANIX_PASSWORD }}
NUTANIX_ENDPOINT: ${{ vars.NUTANIX_ENDPOINT }}
NUTANIX_PRISM_ELEMENT_CLUSTER_NAME: ${{ vars.NUTANIX_PRISM_ELEMENT_CLUSTER_NAME }}
NUTANIX_SUBNET_NAME: ${{ vars.NUTANIX_SUBNET_NAME }}
LOCAL_IMAGE_REGISTRY: ${{ vars.LOCAL_IMAGE_REGISTRY }}
CONTROL_PLANE_ENDPOINT_IP: ${{ steps.get-control-plane-endpoint-ip.outputs.control_plane_endpoint_ip }}

- if: success() || failure() # always run even if the previous step fails
name: Publish e2e test report
uses: mikepenz/action-junit-report@v4
with:
report_paths: 'junit-e2e.xml'
check_name: 'e2e test report'
detailed_summary: true
require_passed_tests: true
38 changes: 38 additions & 0 deletions .github/workflows/pull_request_target.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Trigger e2e tests on pull_request_target

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
pull_request_target:
types:
- opened
- synchronize
- reopened

permissions:
contents: read

defaults:
run:
shell: bash

jobs:
e2e:
strategy:
matrix:
e2e-labels:
- "capx"
fail-fast: false
uses: ./.github/workflows/e2e.yml
with:
e2e-labels: ${{ matrix.e2e-labels }}
secrets: inherit
permissions:
contents: read
checks: write
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ test-e2e: docker-push ## Run the e2e tests
-e2e.artifacts-folder="$(ARTIFACTS)" \
-e2e.config="$(E2E_CONF_FILE)" \

##@ Development

## --------------------------------------
## Dev
## --------------------------------------

.PHONY: nutanix-cp-endpoint-ip
nutanix-cp-endpoint-ip: ## Gets a random free IP from the control plane endpoint range set in the environment.
shuf --head-count=1 < <(fping -g -u "$(CONTROL_PLANE_ENDPOINT_RANGE_START)" "$(CONTROL_PLANE_ENDPOINT_RANGE_END)")


##@ Deployment

Expand Down
1 change: 1 addition & 0 deletions devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"packages": [
"bash@latest",
"envsubst@1.4.2",
"fping@5.2",
"gnumake@4.4.1",
"ginkgo@2.19.0",
"go@1.22.2",
Expand Down
48 changes: 48 additions & 0 deletions devbox.lock
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,54 @@
}
}
},
"fping@5.2": {
"last_modified": "2024-06-12T20:55:33Z",
"resolved": "github:NixOS/nixpkgs/a9858885e197f984d92d7fe64e9fff6b2e488d40#fping",
"source": "devbox-search",
"version": "5.2",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/clxfp6jl0d2fs1bp2d1278534n2gixbj-fping-5.2",
"default": true
}
],
"store_path": "/nix/store/clxfp6jl0d2fs1bp2d1278534n2gixbj-fping-5.2"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/ilzq042wih0h5vdzxcpf6sd826h37g6w-fping-5.2",
"default": true
}
],
"store_path": "/nix/store/ilzq042wih0h5vdzxcpf6sd826h37g6w-fping-5.2"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/hrh3202f2njx3skj3xn33fish5az5691-fping-5.2",
"default": true
}
],
"store_path": "/nix/store/hrh3202f2njx3skj3xn33fish5az5691-fping-5.2"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/2nr99jpa9g7b5z8pwj85awzh4qbhas28-fping-5.2",
"default": true
}
],
"store_path": "/nix/store/2nr99jpa9g7b5z8pwj85awzh4qbhas28-fping-5.2"
}
}
},
"ginkgo@2.19.0": {
"last_modified": "2024-05-29T10:04:41Z",
"resolved": "github:NixOS/nixpkgs/ac82a513e55582291805d6f09d35b6d8b60637a1#ginkgo",
Expand Down
20 changes: 10 additions & 10 deletions test/e2e/config/nutanix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ images:
# Cluster API v1beta1 Preloads
- name: ghcr.io/nutanix-cloud-native/cluster-api-provider-nutanix/controller:v1.4.0
loadBehavior: tryLoad
- name: registry.k8s.io/cluster-api/cluster-api-controller:v1.6.0
- name: registry.k8s.io/cluster-api/cluster-api-controller:v1.7.3
loadBehavior: tryLoad
- name: registry.k8s.io/cluster-api/kubeadm-bootstrap-controller:v1.6.0
- name: registry.k8s.io/cluster-api/kubeadm-bootstrap-controller:v1.7.3
loadBehavior: tryLoad
- name: registry.k8s.io/cluster-api/kubeadm-control-plane-controller:v1.6.0
- name: registry.k8s.io/cluster-api/kubeadm-control-plane-controller:v1.7.3
loadBehavior: tryLoad
- name: registry.k8s.io/cluster-api/kubeadm-control-plane-controller:v1.6.0
- name: registry.k8s.io/cluster-api/kubeadm-control-plane-controller:v1.7.3
loadBehavior: tryLoad

providers:
- name: cluster-api
type: CoreProvider
versions:
- name: v1.6.0
- name: v1.7.3
# Use manifest from source files
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.6.0/core-components.yaml
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.7.3/core-components.yaml
type: url
contract: v1beta1
files:
Expand All @@ -29,9 +29,9 @@ providers:
- name: kubeadm
type: BootstrapProvider
versions:
- name: v1.6.0
- name: v1.7.3
# Use manifest from source files
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.6.0/bootstrap-components.yaml
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.7.3/bootstrap-components.yaml
type: url
contract: v1beta1
files:
Expand All @@ -42,9 +42,9 @@ providers:
- name: kubeadm
type: ControlPlaneProvider
versions:
- name: v1.6.0
- name: v1.7.3
# Use manifest from source files
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.6.0/control-plane-components.yaml
value: https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.7.3/control-plane-components.yaml
type: url
contract: v1beta1
files:
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/data/shared/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ releaseSeries:
- major: 1
minor: 6
contract: v1beta1
- major: 1
minor: 7
contract: v1beta1

0 comments on commit a0418af

Please sign in to comment.