Skip to content

Commit 25fa80b

Browse files
Add another e2e workflow that gets run on self-hosted-github runner
This is necessary as we want some e2e jobs to run on hosted runners and some to run on self-hosted runners. The actions runner controller does not support using multiple labels to target the runners See: https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners-with-actions-runner-controller/using-actions-runner-controller-runners-in-a-workflow#using-runner-scale-set-names
1 parent 2d2a3f7 commit 25fa80b

File tree

5 files changed

+202
-2
lines changed

5 files changed

+202
-2
lines changed

.github/actionlint.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
self-hosted-runner:
2+
# Labels of self-hosted runner in array of string
3+
labels:
4+
- self-hosted-ncn-dind

.github/workflows/checks.yml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ jobs:
6161
- Docker
6262
# Uncomment below once we have the ability to run e2e tests on other providers from GHA.
6363
# - AWS
64-
# - Nutanix
6564
fail-fast: false
6665
uses: ./.github/workflows/e2e.yml
6766
with:
@@ -72,14 +71,32 @@ jobs:
7271
contents: read
7372
checks: write
7473

74+
# The actions runner controller does not support using multiple labels to target the runners so we have to create separate jobs for self-hosted runners.
75+
# https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners-with-actions-runner-controller/using-actions-runner-controller-runners-in-a-workflow#using-runner-scale-set-names
76+
e2e-quick-start-custom-runner:
77+
strategy:
78+
matrix:
79+
provider:
80+
- Nutanix
81+
# Uncomment below once we have the ability to run e2e tests on other providers via self-hosted runners.
82+
# - Vsphere (example)
83+
fail-fast: false
84+
uses: ./.github/workflows/e2e-custom-runner.yml
85+
with:
86+
provider: ${{ matrix.provider }}
87+
focus: Quick start
88+
secrets: inherit
89+
permissions:
90+
contents: read
91+
checks: write
92+
7593
e2e-self-hosted:
7694
strategy:
7795
matrix:
7896
provider:
7997
- Docker
8098
# Uncomment below once we have the ability to run e2e tests on other providers from GHA.
8199
# - AWS
82-
# - Nutanix
83100
fail-fast: false
84101
uses: ./.github/workflows/e2e.yml
85102
with:
@@ -90,6 +107,25 @@ jobs:
90107
contents: read
91108
checks: write
92109

110+
# The actions runner controller does not support using multiple labels to target the runners so we have to create separate jobs for self-hosted runners.
111+
# https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners-with-actions-runner-controller/using-actions-runner-controller-runners-in-a-workflow#using-runner-scale-set-names
112+
e2e-self-hosted-custom-runner:
113+
strategy:
114+
matrix:
115+
provider:
116+
- Nutanix
117+
# Uncomment below once we have the ability to run e2e tests on other providers via self-hosted runners.
118+
# - Vsphere (example)
119+
fail-fast: false
120+
uses: ./.github/workflows/e2e-custom-runner.yml
121+
with:
122+
provider: ${{ matrix.provider }}
123+
focus: Self-hosted
124+
secrets: inherit
125+
permissions:
126+
contents: read
127+
checks: write
128+
93129
lint-go:
94130
runs-on: ubuntu-22.04
95131
strategy:
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Copyright 2024 Nutanix. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
provider:
8+
description: Infrastructure provider to run e2e tests with
9+
type: string
10+
required: true
11+
skip:
12+
description: e2e tests to skip
13+
type: string
14+
focus:
15+
description: e2e tests to focus
16+
type: string
17+
18+
jobs:
19+
e2e-test:
20+
runs-on: "self-hosted-ncn-dind"
21+
permissions:
22+
contents: read
23+
checks: write
24+
steps:
25+
- name: Check out code
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Check Docker service status
31+
run: docker info
32+
33+
- name: Enable debug logging
34+
run: echo "ENABLE_DEBUG=true" >> $GITHUB_ENV
35+
36+
- name: Install Devbox
37+
uses: jetify-com/[email protected]
38+
with:
39+
enable-cache: true
40+
41+
- name: Go cache
42+
uses: actions/cache@v4
43+
with:
44+
path: |
45+
~/.cache/go-build
46+
~/go/pkg/mod
47+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
48+
restore-keys: |
49+
${{ runner.os }}-go-
50+
51+
- name: Set IP range based on provider
52+
run: |
53+
if [[ "${{ inputs.provider }}" == "Nutanix" ]]; then
54+
CONTROL_PLANE_ENDPOINT_RANGE_START="${{ secrets.NUTANIX_CONTROL_PLANE_ENDPOINT_RANGE_START }}"
55+
CONTROL_PLANE_ENDPOINT_RANGE_END="${{ secrets.NUTANIX_CONTROL_PLANE_ENDPOINT_RANGE_END }}"
56+
fi
57+
58+
echo "CONTROL_PLANE_ENDPOINT_RANGE_START=$CONTROL_PLANE_ENDPOINT_RANGE_START" >> $GITHUB_ENV
59+
echo "CONTROL_PLANE_ENDPOINT_RANGE_END=$CONTROL_PLANE_ENDPOINT_RANGE_END" >> $GITHUB_ENV
60+
61+
- name: Get Control Plane endpoint IP
62+
id: get-control-plane-endpoint-ip
63+
run: |
64+
# Get all available IPs in the range
65+
available_ips=$(fping -g -u $CONTROL_PLANE_ENDPOINT_RANGE_START $CONTROL_PLANE_ENDPOINT_RANGE_END 2>/dev/null)
66+
67+
# Convert the list of available IPs to an array
68+
available_ips_array=(${(f)ip_list})
69+
70+
# Get the number of available IPs
71+
num_ips=${#available_ips_array[@]}
72+
73+
if [ $num_ips -eq 0 ]; then
74+
echo "No available IPs found"
75+
exit 1
76+
fi
77+
78+
# Get a random index
79+
random_index=$((RANDOM % num_ips +1))
80+
81+
# Get the random IP
82+
control_plane_endpoint_ip=${available_ips_array[$random_index]}
83+
84+
# Set the random IP as an output variable
85+
echo "control_plane_endpoint_ip=$control_plane_endpoint_ip" >> $GITHUB_OUTPUT
86+
87+
- name: Run e2e tests
88+
run: devbox run -- make e2e-test E2E_LABEL='provider:${{ inputs.provider }}' E2E_SKIP='${{ inputs.skip }}' E2E_FOCUS='${{ inputs.focus }}'
89+
env:
90+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
92+
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
93+
NUTANIX_ENDPOINT: ${{ secrets.NUTANIX_ENDPOINT }}
94+
NUTANIX_USER: ${{ secrets.NUTANIX_USER }}
95+
NUTANIX_PASSWORD: ${{ secrets.NUTANIX_PASSWORD }}
96+
NUTANIX_PORT: ${{ vars.NUTANIX_PORT }}
97+
NUTANIX_INSECURE: ${{ vars.NUTANIX_INSECURE }}
98+
NUTANIX_PRISM_ELEMENT_CLUSTER_NAME: ${{ vars.NUTANIX_PRISM_ELEMENT_CLUSTER_NAME }}
99+
NUTANIX_SUBNET_NAME: ${{ vars.NUTANIX_SUBNET_NAME }}
100+
NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME: ${{ vars.NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME }}
101+
NUTANIX_STORAGE_CONTAINER_NAME: ${{ vars.NUTANIX_STORAGE_CONTAINER_NAME }}
102+
CONTROL_PLANE_ENDPOINT_IP: ${{ steps.get-control-plane-endpoint-ip.outputs.control_plane_endpoint_ip }}
103+
104+
- if: success() || failure() # always run even if the previous step fails
105+
name: Publish e2e test report
106+
uses: mikepenz/action-junit-report@v4
107+
with:
108+
report_paths: 'junit-e2e.xml'
109+
check_name: 'e2e test report'
110+
detailed_summary: true
111+
require_passed_tests: true

devbox.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"coreutils@latest",
66
"envsubst@latest",
77
"findutils@latest",
8+
"fping@latest",
89
"gh@latest",
910
"ginkgo@latest",
1011
"git@latest",

devbox.lock

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,54 @@
297297
}
298298
}
299299
},
300+
"fping@latest": {
301+
"last_modified": "2024-06-12T20:55:33Z",
302+
"resolved": "github:NixOS/nixpkgs/a9858885e197f984d92d7fe64e9fff6b2e488d40#fping",
303+
"source": "devbox-search",
304+
"version": "5.2",
305+
"systems": {
306+
"aarch64-darwin": {
307+
"outputs": [
308+
{
309+
"name": "out",
310+
"path": "/nix/store/clxfp6jl0d2fs1bp2d1278534n2gixbj-fping-5.2",
311+
"default": true
312+
}
313+
],
314+
"store_path": "/nix/store/clxfp6jl0d2fs1bp2d1278534n2gixbj-fping-5.2"
315+
},
316+
"aarch64-linux": {
317+
"outputs": [
318+
{
319+
"name": "out",
320+
"path": "/nix/store/ilzq042wih0h5vdzxcpf6sd826h37g6w-fping-5.2",
321+
"default": true
322+
}
323+
],
324+
"store_path": "/nix/store/ilzq042wih0h5vdzxcpf6sd826h37g6w-fping-5.2"
325+
},
326+
"x86_64-darwin": {
327+
"outputs": [
328+
{
329+
"name": "out",
330+
"path": "/nix/store/hrh3202f2njx3skj3xn33fish5az5691-fping-5.2",
331+
"default": true
332+
}
333+
],
334+
"store_path": "/nix/store/hrh3202f2njx3skj3xn33fish5az5691-fping-5.2"
335+
},
336+
"x86_64-linux": {
337+
"outputs": [
338+
{
339+
"name": "out",
340+
"path": "/nix/store/2nr99jpa9g7b5z8pwj85awzh4qbhas28-fping-5.2",
341+
"default": true
342+
}
343+
],
344+
"store_path": "/nix/store/2nr99jpa9g7b5z8pwj85awzh4qbhas28-fping-5.2"
345+
}
346+
}
347+
},
300348
"gh@latest": {
301349
"last_modified": "2024-05-30T12:09:21Z",
302350
"resolved": "github:NixOS/nixpkgs/aa61b27554a5fc282758bf0324781e3464ef2cde#gh",

0 commit comments

Comments
 (0)