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

Release v0.2.1 #128

Merged
merged 15 commits into from
Jul 31, 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
45 changes: 19 additions & 26 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,24 @@ on:

jobs:
e2e-tests:
runs-on: ubuntu-latest
runs-on: pdx01-arc-runners
if: ${{ github.event.workflow_run.conclusion == 'success' }} && ${{ github.event.workflow_run.event == '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
- name: Set up Holodeck
uses: NVIDIA/holodeck@main
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Run e2e tests
env:
LOG_ARTIFACTS: ${{ github.workspace }}/e2e_logs
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
make -f tests/Makefile e2e-test
- name: Archive test logs
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: e2e-test-logs
path: ./e2e_logs/
retention-days: 15
- uses: actions/checkout@v4
name: Checkout code
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 'stable'
check-latest: true
- name: Run e2e-aws tests
run: make -f tests/Makefile e2e-aws
- name: Run e2e-vsphere tests
run: make -f tests/Makefile e2e-vsphere
- name: Archive test logs
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: e2e-test-logs
path: ./e2e_logs/
retention-days: 15
1 change: 0 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ on:
- release-*

jobs:

build:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ jobs:
with:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
context: .
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ runs:
inputs:
aws_access_key_id:
description: 'AWS Access Key ID'
required: true
required: false
aws_secret_access_key:
description: 'AWS Secret Access Key'
required: true
required: false
aws_ssh_key:
description: 'AWS SSH Key'
required: false
Expand Down
14 changes: 1 addition & 13 deletions cmd/action/ci/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ const (
cacheFile = "/github/workspace/.cache/holodeck.yaml"
kubeconfig = "/github/workspace/kubeconfig"
sshKeyFile = "/github/workspace/.cache/key.pem"
// Default EC2 instance UserName for ubuntu AMI's
username = "ubuntu"
)

func Run(log *logger.FunLogger) error {
Expand All @@ -43,6 +41,7 @@ func Run(log *logger.FunLogger) error {
}
} else {
if err := entrypoint(log); err != nil {
log.Error(err)
if err := cleanup(log); err != nil {
return err
}
Expand Down Expand Up @@ -78,14 +77,3 @@ func generateUID() string {

return string(b)
}

// instanceTags returns the tags to be applied to the holodeck instance
// based on the GitHub environment variables https://docs.github.com/en/actions/learn-github-actions/variables
func instanceTags() map[string]string {
return map[string]string{
"GITHUB_JOB": os.Getenv("GITHUB_JOB"),
"GITHUB_REPOSITORY": os.Getenv("GITHUB_REPOSITORY"),
"GITHUB_ACTOR": os.Getenv("GITHUB_ACTOR"),
"GITHUB_SHA": os.Getenv("GITHUB_SHA"),
}
}
39 changes: 19 additions & 20 deletions cmd/action/ci/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/NVIDIA/holodeck/internal/logger"
"github.com/NVIDIA/holodeck/pkg/jyaml"
"github.com/NVIDIA/holodeck/pkg/provider/aws"
"github.com/NVIDIA/holodeck/pkg/provider/vsphere"
"github.com/NVIDIA/holodeck/pkg/provisioner"
"github.com/NVIDIA/holodeck/pkg/utils"
)
Expand Down Expand Up @@ -64,30 +65,28 @@ func entrypoint(log *logger.FunLogger) error {
return fmt.Errorf("failed to read cache file: %v", err)
}

// Get the host url
var hostUrl string
var instanceID string
var vpcID string
for _, p := range cache.Status.Properties {
switch p.Name {
case aws.PublicDnsName:
hostUrl = p.Value
case aws.InstanceID:
instanceID = p.Value
case aws.VpcID:
vpcID = p.Value
default:
continue
var username string
if cfg.Spec.Provider == v1alpha1.ProviderAWS {
username = "ubuntu"
for _, p := range cache.Status.Properties {
if p.Name == aws.PublicDnsName {
hostUrl = p.Value
break
}
}
} else if cfg.Spec.Provider == v1alpha1.ProviderVSphere {
username = "nvidia"
for _, p := range cache.Status.Properties {
if p.Name == vsphere.IpAddress {
hostUrl = p.Value
break
}
}
}

// Tag the instance with info the GitHub event
resources := []string{instanceID, vpcID}
tags := instanceTags()
err = provider.UpdateResourcesTags(tags, resources...)
if err != nil {
return err
}

// Run the provisioner
p, err := provisioner.New(log, sshKeyFile, username, hostUrl)
if err != nil {
return err
Expand Down
32 changes: 31 additions & 1 deletion cmd/action/ci/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,22 @@ func newAwsProvider(log *logger.FunLogger, cfg v1alpha1.Environment) (*aws.Provi
}
}

// Get AWS_SSH_KEY and write it to a file
sshKey := os.Getenv("AWS_SSH_KEY")
if sshKey == "" {
log.Error(fmt.Errorf("ssh key not provided"))
os.Exit(1)
}

err := os.WriteFile(sshKeyFile, []byte(sshKey), 0600)
if err != nil {
log.Error(fmt.Errorf("error writing ssh key to file: %s", err))
os.Exit(1)
}

// Set auth.PrivateKey
cfg.Spec.Auth.PrivateKey = sshKeyFile
cfg.Spec.Auth.Username = username
cfg.Spec.Auth.Username = "ubuntu"

// Set env name
setCfgName(&cfg)
Expand All @@ -84,6 +97,23 @@ func newVsphereProvider(log *logger.FunLogger, cfg v1alpha1.Environment) (*vsphe
}
}

// Get VSPHERE_SSH_KEY and write it to a file
sshKey := os.Getenv("VSPHERE_SSH_KEY")
if sshKey == "" {
log.Error(fmt.Errorf("ssh key not provided"))
os.Exit(1)
}

err := os.WriteFile(sshKeyFile, []byte(sshKey), 0600)
if err != nil {
log.Error(fmt.Errorf("error writing ssh key to file: %s", err))
os.Exit(1)
}

// Set auth.PrivateKey
cfg.Spec.Auth.PrivateKey = sshKeyFile
cfg.Spec.Auth.Username = "nvidia"

// Set env name
setCfgName(&cfg)

Expand Down
Loading