diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 19f96e157..09b9ad48e 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -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 diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index fa837c4ea..9e2154022 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -25,7 +25,6 @@ on: - release-* jobs: - build: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 1f8b54a41..f57058f8d 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -56,4 +56,5 @@ jobs: with: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} + platforms: linux/amd64,linux/arm64 context: . diff --git a/action.yml b/action.yml index 4013f44dd..82aaed31f 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/cmd/action/ci/ci.go b/cmd/action/ci/ci.go index a4ef0916d..b1031373d 100644 --- a/cmd/action/ci/ci.go +++ b/cmd/action/ci/ci.go @@ -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 { @@ -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 } @@ -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"), - } -} diff --git a/cmd/action/ci/entrypoint.go b/cmd/action/ci/entrypoint.go index ada7df7fa..6e1440868 100644 --- a/cmd/action/ci/entrypoint.go +++ b/cmd/action/ci/entrypoint.go @@ -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" ) @@ -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 diff --git a/cmd/action/ci/provider.go b/cmd/action/ci/provider.go index c70cb5e92..03812a587 100644 --- a/cmd/action/ci/provider.go +++ b/cmd/action/ci/provider.go @@ -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) @@ -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)