Skip to content

Commit e6d23e3

Browse files
Update e2e workflow to conditionally 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 ci: Run Nutanix provider e2e tests on self-hosted runner
1 parent 4048446 commit e6d23e3

File tree

6 files changed

+208
-112
lines changed

6 files changed

+208
-112
lines changed

.github/actionlint.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright 2024 Nutanix. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
self-hosted-runner:
5+
# Labels of self-hosted runner in array of string
6+
labels:
7+
- self-hosted-ncn-dind

.github/workflows/checks.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ jobs:
5959
matrix:
6060
provider:
6161
- Docker
62+
- Nutanix
6263
# Uncomment below once we have the ability to run e2e tests on other providers from GHA.
6364
# - AWS
64-
# - Nutanix
6565
fail-fast: false
6666
uses: ./.github/workflows/e2e.yml
6767
with:
6868
provider: ${{ matrix.provider }}
6969
focus: Quick start
70+
runs-on: ${{ matrix.provider == 'Nutanix' && 'self-hosted-ncn-dind' || 'ubuntu-22.04' }}
7071
secrets: inherit
7172
permissions:
7273
contents: read
@@ -77,14 +78,15 @@ jobs:
7778
matrix:
7879
provider:
7980
- Docker
81+
- Nutanix
8082
# Uncomment below once we have the ability to run e2e tests on other providers from GHA.
8183
# - AWS
82-
# - Nutanix
8384
fail-fast: false
8485
uses: ./.github/workflows/e2e.yml
8586
with:
8687
provider: ${{ matrix.provider }}
8788
focus: Self-hosted
89+
runs-on: ${{ matrix.provider == 'Nutanix' && 'self-hosted-ncn-dind' || 'ubuntu-22.04' }}
8890
secrets: inherit
8991
permissions:
9092
contents: read

.github/workflows/e2e.yml

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ on:
1414
focus:
1515
description: e2e tests to focus
1616
type: string
17+
runs-on:
18+
description: The runner to run the e2e tests on
19+
type: string
20+
required: true
1721

1822
jobs:
1923
e2e-test:
20-
runs-on: ubuntu-22.04
24+
runs-on: ${{ inputs.runs-on }}
2125
permissions:
2226
contents: read
2327
checks: write
@@ -27,41 +31,65 @@ jobs:
2731
with:
2832
fetch-depth: 0
2933

30-
- name: Install devbox
31-
uses: jetify-com/[email protected]
34+
- uses: cachix/install-nix-action@V27
35+
if: inputs.provider == 'Nutanix'
3236
with:
33-
enable-cache: true
37+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
3438

35-
- name: Go cache
36-
uses: actions/cache@v4
39+
- name: Install devbox
40+
uses: jetify-com/[email protected]
3741
with:
38-
path: |
39-
~/.cache/go-build
40-
~/go/pkg/mod
41-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
42-
restore-keys: |
43-
${{ runner.os }}-go-
42+
enable-cache: "true"
43+
skip-nix-installation: ${{ inputs.provider == 'Nutanix' }}
4444

4545
# The default disk size of these runners is ~14GB, this is not enough to run the e2e tests.
4646
# Cleanup the disk, see upstream discussion https://github.com/actions/runner-images/issues/2840.
4747
- name: Cleanup Disk Space
48+
if: inputs.runs-on != 'self-hosted-ncn-dind'
4849
run: |
4950
echo "Before removing files:"
5051
df -h
5152
sudo rm -rf /usr/share/dotnet
5253
sudo rm -rf /opt/ghc
5354
sudo rm -rf "/usr/local/share/boost"
54-
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
55+
sudo rm -rf "${AGENT_TOOLSDIRECTORY}"
5556
echo "After removing files:"
5657
df -h
5758
59+
- name: Get Control Plane endpoint IP
60+
id: get-control-plane-endpoint-ip
61+
if: inputs.provider == 'Nutanix'
62+
run: |
63+
CONTROL_PLANE_ENDPOINT_RANGE_START="${{ secrets.NUTANIX_CONTROL_PLANE_ENDPOINT_RANGE_START }}"
64+
CONTROL_PLANE_ENDPOINT_RANGE_END="${{ secrets.NUTANIX_CONTROL_PLANE_ENDPOINT_RANGE_END }}"
65+
control_plane_endpoint_ip="$(devbox run -- fping -g -u "${CONTROL_PLANE_ENDPOINT_RANGE_START}" "${CONTROL_PLANE_ENDPOINT_RANGE_END}" 2>/dev/null | devbox run -- shuf --head-count=1)"
66+
echo "control_plane_endpoint_ip=${control_plane_endpoint_ip}" >> "${GITHUB_OUTPUT}"
67+
- name: Go cache
68+
uses: actions/cache@v4
69+
with:
70+
path: |
71+
~/.cache/go-build
72+
~/go/pkg/mod
73+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
74+
restore-keys: |
75+
${{ runner.os }}-go-
76+
5877
- name: Run e2e tests
5978
run: devbox run -- make e2e-test E2E_LABEL='provider:${{ inputs.provider }}' E2E_SKIP='${{ inputs.skip }}' E2E_FOCUS='${{ inputs.focus }}'
6079
env:
6180
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
82+
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
6283
NUTANIX_ENDPOINT: ${{ secrets.NUTANIX_ENDPOINT }}
63-
NUTANIX_PASSWORD: ${{ secrets.NUTANIX_PASSWORD }}
6484
NUTANIX_USER: ${{ secrets.NUTANIX_USER }}
85+
NUTANIX_PASSWORD: ${{ secrets.NUTANIX_PASSWORD }}
86+
NUTANIX_PORT: ${{ vars.NUTANIX_PORT }}
87+
NUTANIX_INSECURE: ${{ vars.NUTANIX_INSECURE }}
88+
NUTANIX_PRISM_ELEMENT_CLUSTER_NAME: ${{ vars.NUTANIX_PRISM_ELEMENT_CLUSTER_NAME }}
89+
NUTANIX_SUBNET_NAME: ${{ vars.NUTANIX_SUBNET_NAME }}
90+
NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME: ${{ vars.NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME }}
91+
NUTANIX_STORAGE_CONTAINER_NAME: ${{ vars.NUTANIX_STORAGE_CONTAINER_NAME }}
92+
CONTROL_PLANE_ENDPOINT_IP: ${{ steps.get-control-plane-endpoint-ip.outputs.control_plane_endpoint_ip }}
6593

6694
- if: success() || failure() # always run even if the previous step fails
6795
name: Publish e2e test report
@@ -71,3 +99,13 @@ jobs:
7199
check_name: 'e2e test report'
72100
detailed_summary: true
73101
require_passed_tests: true
102+
103+
- if: success() || failure() # always run even if the previous step fails
104+
name: Upload e2e test artifacts
105+
uses: actions/upload-artifact@v4
106+
with:
107+
if-no-files-found: warn
108+
overwrite: false
109+
name: ${{ inputs.provider }} ${{ inputs.focus }} e2e artifacts
110+
path: |
111+
_artifacts

devbox.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"crane@latest",
77
"envsubst@latest",
88
"findutils@latest",
9+
"fping@latest",
910
"gh@latest",
1011
"ginkgo@latest",
1112
"git@latest",

devbox.lock

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,54 @@
381381
}
382382
}
383383
},
384+
"fping@latest": {
385+
"last_modified": "2024-06-12T20:55:33Z",
386+
"resolved": "github:NixOS/nixpkgs/a9858885e197f984d92d7fe64e9fff6b2e488d40#fping",
387+
"source": "devbox-search",
388+
"version": "5.2",
389+
"systems": {
390+
"aarch64-darwin": {
391+
"outputs": [
392+
{
393+
"name": "out",
394+
"path": "/nix/store/clxfp6jl0d2fs1bp2d1278534n2gixbj-fping-5.2",
395+
"default": true
396+
}
397+
],
398+
"store_path": "/nix/store/clxfp6jl0d2fs1bp2d1278534n2gixbj-fping-5.2"
399+
},
400+
"aarch64-linux": {
401+
"outputs": [
402+
{
403+
"name": "out",
404+
"path": "/nix/store/ilzq042wih0h5vdzxcpf6sd826h37g6w-fping-5.2",
405+
"default": true
406+
}
407+
],
408+
"store_path": "/nix/store/ilzq042wih0h5vdzxcpf6sd826h37g6w-fping-5.2"
409+
},
410+
"x86_64-darwin": {
411+
"outputs": [
412+
{
413+
"name": "out",
414+
"path": "/nix/store/hrh3202f2njx3skj3xn33fish5az5691-fping-5.2",
415+
"default": true
416+
}
417+
],
418+
"store_path": "/nix/store/hrh3202f2njx3skj3xn33fish5az5691-fping-5.2"
419+
},
420+
"x86_64-linux": {
421+
"outputs": [
422+
{
423+
"name": "out",
424+
"path": "/nix/store/2nr99jpa9g7b5z8pwj85awzh4qbhas28-fping-5.2",
425+
"default": true
426+
}
427+
],
428+
"store_path": "/nix/store/2nr99jpa9g7b5z8pwj85awzh4qbhas28-fping-5.2"
429+
}
430+
}
431+
},
384432
"gh@latest": {
385433
"last_modified": "2024-05-30T12:09:21Z",
386434
"resolved": "github:NixOS/nixpkgs/aa61b27554a5fc282758bf0324781e3464ef2cde#gh",

0 commit comments

Comments
 (0)