Skip to content

Commit

Permalink
Remove SSH setup action (#1300)
Browse files Browse the repository at this point in the history
This removes our custom SSH setup action in favor of some logic within
the test that needs it.
  • Loading branch information
blampe authored Dec 9, 2024
1 parent 3d6cde8 commit d983eca
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 24 deletions.
7 changes: 1 addition & 6 deletions .ci-mgmt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ env:
GOOGLE_REGION: us-central1
GOOGLE_ZONE: us-central1-a
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
PRIVATE_SSH_KEY_FOR_DIGITALOCEAN: ${{ secrets.PRIVATE_SSH_KEY_FOR_DIGITALOCEAN }}
makeTemplate: bridged
docsCmd: "cd provider/pkg/docs-gen/examples/ && go run generate.go ./yaml ./"
hybrid: true
Expand All @@ -31,11 +32,5 @@ plugins:
- name: aws
version: "6.8.0"
team: ecosystem
actions:
preTest:
- name: Setup SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.PRIVATE_SSH_KEY_FOR_DIGITALOCEAN }}
pulumiConvert: 1
registryDocs: true
5 changes: 1 addition & 4 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NUGET_PUBLISH_KEY: ${{ secrets.NUGET_PUBLISH_KEY }}
PRIVATE_SSH_KEY_FOR_DIGITALOCEAN: ${{ secrets.PRIVATE_SSH_KEY_FOR_DIGITALOCEAN }}
PUBLISH_REPO_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
PUBLISH_REPO_USERNAME: ${{ secrets.OSSRH_USERNAME }}
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
Expand Down Expand Up @@ -208,10 +209,6 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v2.5.0
- name: Setup SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.PRIVATE_SSH_KEY_FOR_DIGITALOCEAN }}
- name: Run tests
run: cd examples && go test -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -parallel 4
strategy:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NUGET_PUBLISH_KEY: ${{ secrets.NUGET_PUBLISH_KEY }}
PRIVATE_SSH_KEY_FOR_DIGITALOCEAN: ${{ secrets.PRIVATE_SSH_KEY_FOR_DIGITALOCEAN }}
PUBLISH_REPO_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
PUBLISH_REPO_USERNAME: ${{ secrets.OSSRH_USERNAME }}
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
Expand Down Expand Up @@ -149,10 +150,6 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v2.5.0
- name: Setup SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.PRIVATE_SSH_KEY_FOR_DIGITALOCEAN }}
- name: Run tests
run: cd examples && go test -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -parallel 4 .
strategy:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NUGET_PUBLISH_KEY: ${{ secrets.NUGET_PUBLISH_KEY }}
PRIVATE_SSH_KEY_FOR_DIGITALOCEAN: ${{ secrets.PRIVATE_SSH_KEY_FOR_DIGITALOCEAN }}
PUBLISH_REPO_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
PUBLISH_REPO_USERNAME: ${{ secrets.OSSRH_USERNAME }}
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
Expand Down Expand Up @@ -155,10 +156,6 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v2.5.0
- name: Setup SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.PRIVATE_SSH_KEY_FOR_DIGITALOCEAN }}
- name: Run tests
run: cd examples && go test -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -parallel 4 .
strategy:
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/run-acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NUGET_PUBLISH_KEY: ${{ secrets.NUGET_PUBLISH_KEY }}
PRIVATE_SSH_KEY_FOR_DIGITALOCEAN: ${{ secrets.PRIVATE_SSH_KEY_FOR_DIGITALOCEAN }}
PUBLISH_REPO_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
PUBLISH_REPO_USERNAME: ${{ secrets.OSSRH_USERNAME }}
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
Expand Down Expand Up @@ -204,13 +205,9 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v2.5.0
- name: Setup SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.PRIVATE_SSH_KEY_FOR_DIGITALOCEAN }}
- name: Run tests
if: matrix.testTarget == 'local'
run: cd examples && go test -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -skip TestPulumiExamples -parallel 4 .
run: cd examples && go test -count=1 -v -cover -timeout 2h -tags=${{ matrix.language }} -skip TestPulumiExamples -parallel 4 .
- name: Run pulumi/examples tests
if: matrix.testTarget == 'pulumiExamples'
run: cd examples && go test -count=1 -cover -timeout 2h -tags=${{ matrix.language }} -run TestPulumiExamples -parallel 4 .
Expand Down
47 changes: 47 additions & 0 deletions examples/examples_nodejs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ package examples
import (
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
"net"
"os"
"path"
"path/filepath"
"testing"

"github.com/pulumi/pulumi/pkg/v3/testing/integration"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent"
)

func TestNginxTs(t *testing.T) {
Expand Down Expand Up @@ -207,6 +215,44 @@ func TestSSHConnNode(t *testing.T) {
if token == "" {
t.Skipf("Skipping test due to missing DIGITALOCEAN_TOKEN environment variable")
}
key := os.Getenv("PRIVATE_SSH_KEY_FOR_DIGITALOCEAN")
if key == "" {
t.Skip("PRIVATE_SSH_KEY_FOR_DIGITALOCEAN is unset")
}

// sshagent crates an in-memory SSH agent with our DO private key loaded, and it returns the listening socket.
sshagent := func() string {
dir, err := os.MkdirTemp(os.TempDir(), "docker-test-*")
require.NoError(t, err)

sock := filepath.Join(dir, "test.sock")

l, err := net.Listen("unix", sock)
require.NoError(t, err)

a := agent.NewKeyring()

privateKey, err := ssh.ParseRawPrivateKey([]byte(key))
require.NoError(t, err)

err = a.Add(agent.AddedKey{PrivateKey: privateKey})
require.NoError(t, err)

go func() {
for {
conn, err := l.Accept()
if err != nil {
panic(err)
}
if err := agent.ServeAgent(a, conn); err != nil && !errors.Is(err, io.EOF) {
panic(err)
}
}
}()

return sock
}

test := getJsOptions(t).
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "test-ssh-conn", "ts"),
Expand All @@ -221,6 +267,7 @@ func TestSSHConnNode(t *testing.T) {
Config: map[string]string{
"digitalocean:token": token,
},
Env: []string{fmt.Sprintf("SSH_AUTH_SOCK=%s", sshagent())},
Verbose: true,
})
integration.ProgramTest(t, &test)
Expand Down
2 changes: 1 addition & 1 deletion examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/docker/docker v27.0.3+incompatible
github.com/pulumi/pulumi/pkg/v3 v3.140.0
github.com/stretchr/testify v1.9.0
golang.org/x/crypto v0.26.0
)

replace github.com/pulumi/pulumi-docker/sdk/v4 => ../sdk
Expand Down Expand Up @@ -162,7 +163,6 @@ require (
go.uber.org/atomic v1.10.0 // indirect
gocloud.dev v0.37.0 // indirect
gocloud.dev/secrets/hashivault v0.37.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/net v0.28.0 // indirect
Expand Down

0 comments on commit d983eca

Please sign in to comment.