Skip to content

ci: run integration test #240

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

Merged
merged 5 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
10 changes: 10 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,19 @@ jobs:
go mod download

- name: Build
env:
CGO_ENABLED: "0"
Comment on lines +36 to +37
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: this is required because coder/coder is based on alpine and it will otherwise look for libc

run: |
go build -v .

- name: Run integration test
timeout-minutes: 10
env:
CODER_IMAGE: "ghcr.io/coder/coder"
CODER_VERSION: "latest"
run: |
go test -v ./integration

# run acceptance tests in a matrix with Terraform core versions
test:
name: Matrix Test
Expand Down
16 changes: 13 additions & 3 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
"io"
"os"
"path/filepath"
"runtime"
Expand All @@ -15,6 +16,7 @@ import (

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/client"
"github.com/docker/docker/pkg/stdcopy"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -82,8 +84,8 @@ func TestIntegration(t *testing.T) {
"workspace_owner.name": `testing`,
"workspace_owner.oidc_access_token": `^$`, // TODO: test OIDC integration
"workspace_owner.session_token": `.+`,
"workspace_owner.ssh_private_key": `^$`, // Depends on coder/coder#13366
"workspace_owner.ssh_public_key": `^$`, // Depends on coder/coder#13366
"workspace_owner.ssh_private_key": `(?s)^.+?BEGIN OPENSSH PRIVATE KEY.+?END OPENSSH PRIVATE KEY.+?$`,
"workspace_owner.ssh_public_key": `(?s)^ssh-ed25519.+$`,
},
},
} {
Expand Down Expand Up @@ -148,9 +150,17 @@ func setup(ctx context.Context, t *testing.T) string {
require.NoError(t, err, "get abs path of parent")
t.Logf("src path is %s\n", srcPath)

// Ensure the image is available locally.
refStr := coderImg + ":" + coderVersion
t.Logf("ensuring image %q", refStr)
resp, err := cli.ImagePull(ctx, refStr, image.PullOptions{})
require.NoError(t, err)
_, err = io.ReadAll(resp)
require.NoError(t, err)

// Stand up a temporary Coder instance
ctr, err := cli.ContainerCreate(ctx, &container.Config{
Image: coderImg + ":" + coderVersion,
Image: refStr,
Env: []string{
"CODER_ACCESS_URL=" + localURL, // Set explicitly to avoid creating try.coder.app URLs.
"CODER_IN_MEMORY=true", // We don't necessarily care about real persistence here.
Expand Down
Loading