Skip to content

Commit f0607a6

Browse files
authored
ci: run integration tests against oldstable (#310)
* feawt(scripts/coderversion): emit OLDSTABLE version * chore: update README to better illustrate testing on tip of main * chore(integration): add test for workspace owner being set * ci: run integration tests against oldstable
1 parent 73f1852 commit f0607a6

File tree

5 files changed

+136
-2
lines changed

5 files changed

+136
-2
lines changed

.github/workflows/test.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ jobs:
3838
run: |
3939
go build -v .
4040
41+
- name: Run integration test (devel)
42+
timeout-minutes: 10
43+
env:
44+
CODER_IMAGE: "ghcr.io/coder/coder-preview"
45+
CODER_VERSION: "latest"
46+
run: |
47+
go test -v ./integration
48+
4149
- name: Run integration test (mainline)
4250
timeout-minutes: 10
4351
env:
@@ -54,6 +62,14 @@ jobs:
5462
source <(go run ./scripts/coderversion)
5563
CODER_VERSION="${CODER_STABLE_VERSION}" go test -v ./integration
5664
65+
- name: Run integration test (oldstable)
66+
timeout-minutes: 10
67+
env:
68+
CODER_IMAGE: "ghcr.io/coder/coder"
69+
run: |
70+
source <(go run ./scripts/coderversion)
71+
CODER_VERSION="${CODER_OLDSTABLE_VERSION}" go test -v ./integration
72+
5773
# run acceptance tests in a matrix with Terraform core versions
5874
test:
5975
name: Matrix Test

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ To run these integration tests locally:
7070
1. Pull the version of the Coder image you wish to test:
7171

7272
```console
73-
docker pull ghcr.io/coder/coder:main-x.y.z-devel-abcd1234
73+
docker pull ghcr.io/coder/coder-preview:main-x.y.z-devel-abcd1234
7474
```
7575

76-
1. Run `CODER_VERSION=main-x.y.z-devel-abcd1234 make test-integration`.
76+
1. Run `CODER_IMAGE=ghcr.io/coder/coder-preview CODER_VERSION=main-x.y.z-devel-abcd1234 make test-integration`.
7777

7878
> **Note:** you can specify `CODER_IMAGE` if the Coder image you wish to test is hosted somewhere other than `ghcr.io/coder/coder`.
7979
> For example, `CODER_IMAGE=example.com/repo/coder CODER_VERSION=foobar make test-integration`.

integration/integration_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,34 @@ func TestIntegration(t *testing.T) {
115115
"workspace_owner.login_type": ``,
116116
},
117117
},
118+
{
119+
name: "workspace-owner-filled",
120+
minVersion: "v2.18.0",
121+
expectedOutput: map[string]string{
122+
"provisioner.arch": runtime.GOARCH,
123+
"provisioner.id": `[a-zA-Z0-9-]+`,
124+
"provisioner.os": runtime.GOOS,
125+
"workspace.access_port": `\d+`,
126+
"workspace.access_url": `https?://\D+:\d+`,
127+
"workspace.id": `[a-zA-z0-9-]+`,
128+
"workspace.name": ``,
129+
"workspace.start_count": `1`,
130+
"workspace.template_id": `[a-zA-Z0-9-]+`,
131+
"workspace.template_name": `workspace-owner`,
132+
"workspace.template_version": `.+`,
133+
"workspace.transition": `start`,
134+
"workspace_owner.email": `testing@coder\.com`,
135+
"workspace_owner.full_name": `default`,
136+
"workspace_owner.groups": `\[(\"Everyone\")?\]`,
137+
"workspace_owner.id": `[a-zA-Z0-9-]+`,
138+
"workspace_owner.name": `testing`,
139+
"workspace_owner.oidc_access_token": `^$`, // TODO: test OIDC integration
140+
"workspace_owner.session_token": `.+`,
141+
"workspace_owner.ssh_private_key": `(?s)^.+?BEGIN OPENSSH PRIVATE KEY.+?END OPENSSH PRIVATE KEY.+?$`,
142+
"workspace_owner.ssh_public_key": `(?s)^ssh-ed25519.+$`,
143+
"workspace_owner.login_type": `password`,
144+
},
145+
},
118146
{
119147
name: "coder-app-hidden",
120148
minVersion: "v0.0.0",
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
terraform {
2+
required_providers {
3+
coder = {
4+
source = "coder/coder"
5+
}
6+
local = {
7+
source = "hashicorp/local"
8+
}
9+
}
10+
}
11+
12+
// TODO: test coder_external_auth
13+
// data coder_external_auth "me" {}
14+
data "coder_provisioner" "me" {}
15+
data "coder_workspace" "me" {}
16+
data "coder_workspace_owner" "me" {}
17+
18+
locals {
19+
# NOTE: these must all be strings in the output
20+
output = {
21+
"provisioner.arch" : data.coder_provisioner.me.arch,
22+
"provisioner.id" : data.coder_provisioner.me.id,
23+
"provisioner.os" : data.coder_provisioner.me.os,
24+
"workspace.access_port" : tostring(data.coder_workspace.me.access_port),
25+
"workspace.access_url" : data.coder_workspace.me.access_url,
26+
"workspace.id" : data.coder_workspace.me.id,
27+
"workspace.name" : data.coder_workspace.me.name,
28+
"workspace.start_count" : tostring(data.coder_workspace.me.start_count),
29+
"workspace.template_id" : data.coder_workspace.me.template_id,
30+
"workspace.template_name" : data.coder_workspace.me.template_name,
31+
"workspace.template_version" : data.coder_workspace.me.template_version,
32+
"workspace.transition" : data.coder_workspace.me.transition,
33+
"workspace_owner.email" : data.coder_workspace_owner.me.email,
34+
"workspace_owner.full_name" : data.coder_workspace_owner.me.full_name,
35+
"workspace_owner.groups" : jsonencode(data.coder_workspace_owner.me.groups),
36+
"workspace_owner.id" : data.coder_workspace_owner.me.id,
37+
"workspace_owner.name" : data.coder_workspace_owner.me.name,
38+
"workspace_owner.oidc_access_token" : data.coder_workspace_owner.me.oidc_access_token,
39+
"workspace_owner.session_token" : data.coder_workspace_owner.me.session_token,
40+
"workspace_owner.ssh_private_key" : data.coder_workspace_owner.me.ssh_private_key,
41+
"workspace_owner.ssh_public_key" : data.coder_workspace_owner.me.ssh_public_key,
42+
"workspace_owner.login_type" : data.coder_workspace_owner.me.login_type,
43+
}
44+
}
45+
46+
variable "output_path" {
47+
type = string
48+
}
49+
50+
resource "local_file" "output" {
51+
filename = var.output_path
52+
content = jsonencode(local.output)
53+
}
54+
55+
output "output" {
56+
value = local.output
57+
sensitive = true
58+
}

scripts/coderversion/main.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,38 @@ func main() {
6464

6565
stable := fmt.Sprintf("v%d.%d.%d", stableVer.Major(), stableVer.Minor(), stableVer.Patch())
6666
_, _ = fmt.Fprintf(os.Stdout, "CODER_STABLE_VERSION=%q\n", stable)
67+
68+
expectedOldStableMinor := mainlineVer.Minor() - 2
69+
if expectedOldStableMinor < 0 {
70+
expectedOldStableMinor = 0
71+
}
72+
debug("expected old stable minor: %d\n", expectedStableMinor)
73+
oldStableVer := semver.MustParse("v0.0.0")
74+
for _, rel := range releases {
75+
debug("check version %s\n", rel)
76+
if rel == "" {
77+
debug("ignoring untagged version %s\n", rel)
78+
continue
79+
}
80+
81+
ver, err := semver.NewVersion(rel)
82+
if err != nil {
83+
debug("skipping invalid version %s\n", rel)
84+
}
85+
86+
if ver.Minor() != expectedOldStableMinor {
87+
debug("skipping version %s\n", rel)
88+
continue
89+
}
90+
91+
if ver.Compare(oldStableVer) > 0 {
92+
oldStableVer = ver
93+
continue
94+
}
95+
}
96+
97+
oldStable := fmt.Sprintf("v%d.%d.%d", oldStableVer.Major(), oldStableVer.Minor(), oldStableVer.Patch())
98+
_, _ = fmt.Fprintf(os.Stdout, "CODER_OLDSTABLE_VERSION=%q\n", oldStable)
6799
}
68100

69101
type release struct {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy