Skip to content

Commit

Permalink
Add e2e github action
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
  • Loading branch information
ArangoGutierrez committed Feb 21, 2024
1 parent c469c54 commit 1ea5108
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 8 deletions.
122 changes: 122 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Copyright 2024 NVIDIA CORPORATION
#
# 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.

name: e2e

on:
pull_request:
types:
- opened
- synchronize
- labeled
branches:
- main
- release-*
push:
branches:
- main
- release-*

jobs:
build:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test') || github.event_name == 'push'
steps:
- uses: actions/checkout@v4
name: Check out code
- name: Calculate build vars
id: vars
run: |
echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV
echo "LOWERCASE_REPO_OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | awk '{print tolower($0)}')" >> $GITHUB_ENV
REPO_FULL_NAME="${{ github.event.pull_request.head.repo.full_name }}"
echo "${REPO_FULL_NAME}"
echo "LABEL_IMAGE_SOURCE=https://github.com/${REPO_FULL_NAME}" >> $GITHUB_ENV
GENERATE_ARTIFACTS="false"
if [[ "${{ github.actor }}" == "dependabot[bot]" ]]; then
GENERATE_ARTIFACTS="false"
fi
echo "PUSH_ON_BUILD=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV
echo "BUILD_MULTI_ARCH_IMAGES=false" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
env:
IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/k8s-device-plugin
VERSION: ${COMMIT_SHORT_SHA}
run: |
echo "${VERSION}"
make -f deployments/container/Makefile build-ubuntu20.04
test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
name: Checkout code
- name: Calculate test env vars
id: vars
run: |
echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Install YQ
run: |
sudo add-apt-repository ppa:rmescandon/yq -y
sudo apt-get update
sudo apt-get install yq -y
- name: Get private key
run: |
cat << EOF > ./key.pem
${{ secrets.AWS_SSH_KEY }}
EOF
chmod00 ./key.pem
- name: Install and setup Holodeck
env:
HOLODECK_VERSION: v0.1.1
HOLODECK_INSTANCE: gh-action-${GITHUB_SHA:0:8}
SSH_KEY: ${{ github.workspace }}/key.pem
run: |
curl -sL https://github.com/NVIDIA/holodeck/releases/download/${HOLODECK_VERSION}/holodeck-linux-amd64 -o /usr/local/bin/holodeck
chmod +x /usr/local/bin/holodeck
yq -i --arg hi "${{ env.HOLODECK_INSTANCE }}" '.metadata.name = "$hi"' holodeck.yaml
yq -i --arg key "${{ env.SSH_KEY }}" '.spec.auth.privateKey = "$key"' holodeck.yaml
- name: Create test environment
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
holodeck create -f holodeck.yaml -p -c ${{ github.workspace }}/${COMMIT_SHORT_SHA} -k ./kubeconfig
- name: Run tests
env:
KUBECONFIG: ${{ github.workspace }}/kubeconfig
E2E_IMAGE_REPO: ghcr.io/nvidia/k8s-device-plugin
E2E_IMAGE_TAG: ${COMMIT_SHORT_SHA}-ubuntu20.04
run: |
echo "Running e2e-tests"
make -f tests/e2e/Makefile e2e-test
- name: Cleanup
run: |
holodeck delete -f holodeck.yaml -c ${{ github.workspace }}/${COMMIT_SHORT_SHA}
9 changes: 8 additions & 1 deletion .github/workflows/golang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: Golang
name: golang

on:
pull_request:
types:
- opened
- synchronize
- labeled
branches:
- main
- release-*
Expand All @@ -27,6 +31,7 @@ on:
jobs:
check:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test') || github.event_name == 'push'
steps:
- uses: actions/checkout@v4
name: Checkout code
Expand All @@ -43,6 +48,7 @@ jobs:
test:
name: Unit test
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test') || github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -53,6 +59,7 @@ jobs:
- run: make test
build:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test') || github.event_name == 'push'
steps:
- uses: actions/checkout@v4
name: Checkout code
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Run this workflow on pull requests or merge to main/release branches
name: image

on:
pull_request:
types:
- opened
- synchronize
- labeled
branches:
- main
- release-*
Expand All @@ -31,6 +31,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test') || github.event_name == 'push'
strategy:
matrix:
dist: [ubuntu20.04, ubi8]
Expand Down
Binary file added holodeck
Binary file not shown.
19 changes: 19 additions & 0 deletions kubeconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
clusters:
- cluster:
certificate-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WgwdHA2ZUl5NnBEcktBCmMyTnVqUjcrS1NmTEFCVmZEamV5S0tKZGhIbzZiR0xSWnp2SzIrNnFmQThrU1FyUEx6TmxVdThMd3p1RjZjQWQKWjl5bWh6amhQeGdaeFNOaEN2eTExRFN1Y1kwU21PWEZRak1hRllsZXFJK3oxay9mRFBUbWJIQk9nTE8zMXZ5YQpOckFKNmNmSThRdU9SZVRmcnpmaVlXM0l0dzFMUDhFT1AwK3d4cGNraTdhYnFQMDNBM3BKejUwRTQ0Sk5zaHFhCldlTDFWQUJhVXdDQUtyVG5wZHpxOHdXMlBqdjY3K014eE5SSGRPYkIrNERMZXF4RTYzaWVybG5kMktGbm5WOXAKTnNMb0pjc3FyeW9VCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
server: https://ec2-54-153-26-145.us-west-1.compute.amazonaws.com:6443
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: kubernetes-admin
name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQWdtZ0F3SUJBZ0lJWm1td2UrbkpZWmd3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TkRBeU1qRXhNRFUwTXpWYUZ3MHlOVEF5TWpBeE1EVTVNemRhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXVMMzFhSHZlUE43b2c4UC8KMjRZb1dKQzlYN2hrbFdZQVc3QjdFcUhLeWpLOG1HamdxOVFSTG1pMDN0YkoxTmphNVhBWWdJSzNiZ21zYS9XTQorYnRCVWNTdWxoM21rMm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4WmtIUApYUVl5ZG1mWllGSEVEMFRxRkJTRGV0dmlCbU5Xd2xLYm15V2dleFdSS1ZnM3dTMXVFSy9FCi0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==
13 changes: 7 additions & 6 deletions tests/e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@
GO_CMD ?= go
GO_FMT ?= gofmt

DRIVER_ENABLED ?= true
include $(CURDIR)/versions.mk

E2E_IMAGE_REPO ?= nvcr.io/nvidia/k8s-device-plugin
E2E_IMAGE_TAG ?= v0.14.3
E2E_IMAGE_PULL_POLICY ?= Always
DRIVER_ENABLED ?= true

HELM_CHART ?= $(CURDIR)/../../deployments/helm/nvidia-device-plugin
E2E_IMAGE_REPO ?= $(REGISTRY)/$(DRIVER_NAME)
E2E_IMAGE_TAG ?= $(VERSION)
E2E_IMAGE_PULL_POLICY ?= IfNotPresent
HELM_CHART ?= $(CURDIR)/deployments/helm/nvidia-device-plugin

.PHONY: e2e-test
e2e-test:
@if [ -z ${KUBECONFIG} ]; then \
echo "[ERR] KUBECONFIG missing, must be defined"; \
exit 1; \
fi
$(GO_CMD) test -v . -args \
$(GO_CMD) test -v $(CURDIR)/tests/e2e -args \
-kubeconfig=$(KUBECONFIG) \
-driver-enabled=$(DRIVER_ENABLED) \
-image.repo=$(E2E_IMAGE_REPO) \
Expand Down
29 changes: 29 additions & 0 deletions tests/e2e/holodeck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: holodeck.nvidia.com/v1alpha1
kind: Environment
metadata:
name: gh-action-5b6033b2
description: "Devel infra environment"
spec:
provider: aws
auth:
keyName: cnt-ci
privateKey: "/Users/eduardoa/.ssh/cnt-ci.pem"
instance:
type: g4dn.xlarge
region: us-west-1
ingressIpRanges:
- 0.0.0.0/0
image:
architecture: amd64
imageId: ami-0ce2cb35386fc22e9
containerRuntime:
install: true
name: containerd
nvidiaContainerToolkit:
install: true
nvidiaDriver:
install: true
kubernetes:
install: true
installer: kubeadm
version: v1.28.5

0 comments on commit 1ea5108

Please sign in to comment.