Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Holodeck GitHub Action #20

Merged
merged 7 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
## Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.##
## 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: Go

Expand All @@ -23,7 +34,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version-file: 'go.mod'

ArangoGutierrez marked this conversation as resolved.
Show resolved Hide resolved
- name: Build
run: go build -v ./...
59 changes: 59 additions & 0 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.##
## 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: image
ArangoGutierrez marked this conversation as resolved.
Show resolved Hide resolved

on:
pull_request:
branches:
- 'main'
- 'release-*'
push:
tags:
- 'v*.*.*'
ArangoGutierrez marked this conversation as resolved.
Show resolved Hide resolved
branches:
- 'main'
- 'release-*'

jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Check out code
- 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: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/nvidia/holodeck
tags: |
type=semver,pattern={{raw}}
type=ref,event=branch
- name: Build and push
uses: docker/build-push-action@v5
with:
push: ${{ github.event_name != 'pull_request' }}
ArangoGutierrez marked this conversation as resolved.
Show resolved Hide resolved
tags: ${{ steps.meta.outputs.tags }}
context: .
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.##
## 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.
##

FROM golang:1.21

WORKDIR /src
COPY . .

RUN make build
ArangoGutierrez marked this conversation as resolved.
Show resolved Hide resolved
RUN install -m 755 /src/bin/holodeck /usr/local/bin/holodeck && \
install -m 755 /src/scripts/run.sh /usr/local/bin/run.sh && \
install -m 755 /src/scripts/cleanup.sh /usr/local/bin/cleanup.sh

RUN echo "nobody:x:65534:65534:Nobody:/:" >> /etc/passwd
# Run as unprivileged user
USER 65534:65534

ENTRYPOINT ["/usr/local/bin/run.sh"]
37 changes: 37 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.##
## 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: Holodeck
description: A tool for creating and managing GPU-ready cloud test environments.

runs:
using: docker
image: `docker://ghcr.io/nvidia/holodeck:main`
ArangoGutierrez marked this conversation as resolved.
Show resolved Hide resolved
entrypoint: 'run.sh'
post-entrypoint: 'cleanup.sh'

inputs:
aws-access-key-id:
description: 'AWS Access Key ID'
required: true
aws-secret-access-key:
description: 'AWS Secret Access Key'
required: true
holodeck-config:
description: 'Holodeck configuration file'
required: true

branding:
icon: 'cloud'
color: 'green'
26 changes: 26 additions & 0 deletions scripts/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.##
## 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.
##

#! /usr/bin/env bash
set +x
set +e

export DEBIAN_FRONTEND=noninteractive
rm -f /github/workspace/key.pem /github/workspace/kubeconfig

/user/bin/holodeck delete -f /github/workspace/$INPUT_HOLODECK_CONFIG -c /github/workspace/.cache
ArangoGutierrez marked this conversation as resolved.
Show resolved Hide resolved
exit_code=$?

rm -rf /github/workspace/.cache
exit $exit_code
44 changes: 44 additions & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.##
## 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.
##

#! /usr/bin/env bash
set +x

export DEBIAN_FRONTEND=noninteractive

if [ -n "$INPUT_HOLODECK_CONFIG" ]; then
ArangoGutierrez marked this conversation as resolved.
Show resolved Hide resolved
if [ ! -f "/github/workspace/$INPUT_HOLODECK_CONFIG" ]; then
echo "Holodeck config file not found in /workspace"
exit 1
fi
fi

if [ -z "$INPUT_AWS_ACCESS_KEY_ID" ] || [ -z "$INPUT_AWS_SECRET_ACCESS_KEY" ]; then
echo "AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are not set"
exit 1
fi

export AWS_ACCESS_KEY_ID=$INPUT_AWS_ACCESS_KEY_ID
ArangoGutierrez marked this conversation as resolved.
Show resolved Hide resolved
export AWS_SECRET_ACCESS_KEY=$INPUT_AWS_SECRET_ACCESS_KEY

if [ -n "$SSH_KEY" ]; then
$(umask 077; echo "$SSH_KEY" > /github/workspace/key.pem)
fi

mkdir -p /github/workspace/.cache

/user/local/bin/holodeck create --provision \
-f /github/workspace/$INPUT_HOLODECK_CONFIG \
-c /github/workspace/.cache \
-k /github/workspace/kubeconfig
Loading