Skip to content

Commit 80928c6

Browse files
committed
Merge branch 'main' into mes/workspace-button-2
2 parents 1a01127 + 5d5a7da commit 80928c6

File tree

187 files changed

+3684
-2155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+3684
-2155
lines changed

.github/workflows/ci.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ jobs:
234234
run: ./scripts/check_unstaged.sh
235235

236236
test-go:
237-
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'buildjet-4vcpu-ubuntu-2204' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'macos-latest-xl' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'windows-latest-16-cores' || matrix.os }}
237+
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'buildjet-4vcpu-ubuntu-2204' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'macos-latest-xlarge' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'windows-latest-16-cores' || matrix.os }}
238238
needs: changes
239239
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
240240
timeout-minutes: 20
@@ -271,10 +271,22 @@ jobs:
271271
echo "cover=false" >> $GITHUB_OUTPUT
272272
fi
273273
274+
# if macOS, install google-chrome for scaletests. As another concern,
275+
# should we really have this kind of external dependency requirement
276+
# on standard CI?
277+
if [ "${{ matrix.os }}" == "macos-latest" ]; then
278+
brew install google-chrome
279+
fi
280+
274281
# By default Go will use the number of logical CPUs, which
275282
# is a fine default.
276283
PARALLEL_FLAG=""
277284
285+
# macOS will output "The default interactive shell is now zsh"
286+
# intermittently in CI...
287+
if [ "${{ matrix.os }}" == "macos-latest" ]; then
288+
touch ~/.bash_profile && echo "export BASH_SILENCE_DEPRECATION_WARNING=1" >> ~/.bash_profile
289+
fi
278290
export TS_DEBUG_DISCO=true
279291
gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" \
280292
--packages="./..." -- $PARALLEL_FLAG -short -failfast $COVERAGE_FLAGS

cli/agent_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ func TestWorkspaceAgent(t *testing.T) {
3838
ProvisionApply: echo.ProvisionApplyWithAgent(authToken),
3939
})
4040
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
41-
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
41+
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
4242
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
43-
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
43+
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
4444

4545
logDir := t.TempDir()
4646
inv, _ := clitest.New(t,
@@ -92,9 +92,9 @@ func TestWorkspaceAgent(t *testing.T) {
9292
}},
9393
})
9494
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
95-
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
95+
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
9696
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
97-
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
97+
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
9898

9999
inv, _ := clitest.New(t, "agent", "--auth", "azure-instance-identity", "--agent-url", client.URL.String())
100100
inv = inv.WithContext(
@@ -144,9 +144,9 @@ func TestWorkspaceAgent(t *testing.T) {
144144
}},
145145
})
146146
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
147-
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
147+
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
148148
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
149-
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
149+
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
150150

151151
inv, _ := clitest.New(t, "agent", "--auth", "aws-instance-identity", "--agent-url", client.URL.String())
152152
inv = inv.WithContext(
@@ -196,9 +196,9 @@ func TestWorkspaceAgent(t *testing.T) {
196196
}},
197197
})
198198
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
199-
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
199+
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
200200
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
201-
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
201+
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
202202

203203
inv, cfg := clitest.New(t, "agent", "--auth", "google-instance-identity", "--agent-url", client.URL.String())
204204
ptytest.New(t).Attach(inv)
@@ -253,9 +253,9 @@ func TestWorkspaceAgent(t *testing.T) {
253253
ProvisionApply: echo.ProvisionApplyWithAgent(authToken),
254254
})
255255
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
256-
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
256+
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
257257
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
258-
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
258+
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
259259

260260
logDir := t.TempDir()
261261
inv, _ := clitest.New(t,

cli/clibase/option.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,15 @@ func (optSet *OptionSet) ParseEnv(vs []EnvVar) error {
262262
}
263263

264264
envVal, ok := envs[opt.Env]
265+
if !ok {
266+
// Homebrew strips all environment variables that do not start with `HOMEBREW_`.
267+
// This prevented using brew to invoke the Coder agent, because the environment
268+
// variables to not get passed down.
269+
//
270+
// A customer wanted to use their custom tap inside a workspace, which was failing
271+
// because the agent lacked the environment variables to authenticate with Git.
272+
envVal, ok = envs[`HOMEBREW_`+opt.Env]
273+
}
265274
// Currently, empty values are treated as if the environment variable is
266275
// unset. This behavior is technically not correct as there is now no
267276
// way for a user to change a Default value to an empty string from

cli/clibase/option_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,26 @@ func TestOptionSet_ParseEnv(t *testing.T) {
206206
require.NoError(t, err)
207207
require.EqualValues(t, expected, actual.Value)
208208
})
209+
210+
t.Run("Homebrew", func(t *testing.T) {
211+
t.Parallel()
212+
213+
var agentToken clibase.String
214+
215+
os := clibase.OptionSet{
216+
clibase.Option{
217+
Name: "Agent Token",
218+
Value: &agentToken,
219+
Env: "AGENT_TOKEN",
220+
},
221+
}
222+
223+
err := os.ParseEnv([]clibase.EnvVar{
224+
{Name: "HOMEBREW_AGENT_TOKEN", Value: "foo"},
225+
})
226+
require.NoError(t, err)
227+
require.EqualValues(t, "foo", agentToken)
228+
})
209229
}
210230

211231
func TestOptionSet_JsonMarshal(t *testing.T) {

cli/clitest/golden.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ func prepareTestData(t *testing.T) (*codersdk.Client, map[string]string) {
182182
})
183183
require.NoError(t, err)
184184
version := coderdtest.CreateTemplateVersion(t, rootClient, firstUser.OrganizationID, nil)
185-
version = coderdtest.AwaitTemplateVersionJob(t, rootClient, version.ID)
185+
version = coderdtest.AwaitTemplateVersionJobCompleted(t, rootClient, version.ID)
186186
template := coderdtest.CreateTemplate(t, rootClient, firstUser.OrganizationID, version.ID, func(req *codersdk.CreateTemplateRequest) {
187187
req.Name = "test-template"
188188
})
189189
workspace := coderdtest.CreateWorkspace(t, rootClient, firstUser.OrganizationID, template.ID, func(req *codersdk.CreateWorkspaceRequest) {
190190
req.Name = "test-workspace"
191191
})
192-
workspaceBuild := coderdtest.AwaitWorkspaceBuildJob(t, rootClient, workspace.LatestBuild.ID)
192+
workspaceBuild := coderdtest.AwaitWorkspaceBuildJobCompleted(t, rootClient, workspace.LatestBuild.ID)
193193

194194
replacements := map[string]string{
195195
firstUser.UserID.String(): "[first user ID]",

cli/cliui/gitauth.go renamed to cli/cliui/externalauth.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import (
1111
"github.com/coder/coder/v2/codersdk"
1212
)
1313

14-
type GitAuthOptions struct {
14+
type ExternalAuthOptions struct {
1515
Fetch func(context.Context) ([]codersdk.TemplateVersionExternalAuth, error)
1616
FetchInterval time.Duration
1717
}
1818

19-
func GitAuth(ctx context.Context, writer io.Writer, opts GitAuthOptions) error {
19+
func ExternalAuth(ctx context.Context, writer io.Writer, opts ExternalAuthOptions) error {
2020
if opts.FetchInterval == 0 {
2121
opts.FetchInterval = 500 * time.Millisecond
2222
}
@@ -38,7 +38,7 @@ func GitAuth(ctx context.Context, writer io.Writer, opts GitAuthOptions) error {
3838
return nil
3939
}
4040

41-
_, _ = fmt.Fprintf(writer, "You must authenticate with %s to create a workspace with this template. Visit:\n\n\t%s\n\n", auth.Type.Pretty(), auth.AuthenticateURL)
41+
_, _ = fmt.Fprintf(writer, "You must authenticate with %s to create a workspace with this template. Visit:\n\n\t%s\n\n", auth.DisplayName, auth.AuthenticateURL)
4242

4343
ticker.Reset(opts.FetchInterval)
4444
spin.Start()
@@ -66,7 +66,7 @@ func GitAuth(ctx context.Context, writer io.Writer, opts GitAuthOptions) error {
6666
}
6767
}
6868
spin.Stop()
69-
_, _ = fmt.Fprintf(writer, "Successfully authenticated with %s!\n\n", auth.Type.Pretty())
69+
_, _ = fmt.Fprintf(writer, "Successfully authenticated with %s!\n\n", auth.DisplayName)
7070
}
7171
return nil
7272
}

cli/cliui/gitauth_test.go renamed to cli/cliui/externalauth_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/coder/coder/v2/testutil"
1616
)
1717

18-
func TestGitAuth(t *testing.T) {
18+
func TestExternalAuth(t *testing.T) {
1919
t.Parallel()
2020

2121
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
@@ -25,12 +25,13 @@ func TestGitAuth(t *testing.T) {
2525
cmd := &clibase.Cmd{
2626
Handler: func(inv *clibase.Invocation) error {
2727
var fetched atomic.Bool
28-
return cliui.GitAuth(inv.Context(), inv.Stdout, cliui.GitAuthOptions{
28+
return cliui.ExternalAuth(inv.Context(), inv.Stdout, cliui.ExternalAuthOptions{
2929
Fetch: func(ctx context.Context) ([]codersdk.TemplateVersionExternalAuth, error) {
3030
defer fetched.Store(true)
3131
return []codersdk.TemplateVersionExternalAuth{{
3232
ID: "github",
33-
Type: codersdk.ExternalAuthProviderGitHub,
33+
DisplayName: "GitHub",
34+
Type: codersdk.EnhancedExternalAuthProviderGitHub.String(),
3435
Authenticated: fetched.Load(),
3536
AuthenticateURL: "https://example.com/gitauth/github",
3637
}}, nil

cli/configssh_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ func TestConfigSSH(t *testing.T) {
9595
}},
9696
ProvisionApply: echo.ProvisionApplyWithAgent(authToken),
9797
})
98-
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
98+
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
9999
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
100100
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
101-
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
101+
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
102102
_ = agenttest.New(t, client.URL, authToken)
103103
resources := coderdtest.AwaitWorkspaceAgents(t, client, workspace.ID)
104104
agentConn, err := client.DialWorkspaceAgent(context.Background(), resources[0].Agents[0].ID, nil)
@@ -594,10 +594,10 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
594594
client = coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
595595
user = coderdtest.CreateFirstUser(t, client)
596596
version = coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, tt.echoResponse)
597-
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
597+
_ = coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
598598
project = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
599599
workspace = coderdtest.CreateWorkspace(t, client, user.OrganizationID, project.ID)
600-
_ = coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
600+
_ = coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
601601
)
602602

603603
// Prepare ssh config files.
@@ -714,10 +714,10 @@ func TestConfigSSH_Hostnames(t *testing.T) {
714714
// authToken := uuid.NewString()
715715
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID,
716716
echo.WithResources(resources))
717-
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
717+
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
718718
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
719719
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
720-
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
720+
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspace.LatestBuild.ID)
721721

722722
sshConfigFile := sshConfigFileName(t)
723723

cli/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func prepWorkspaceBuild(inv *clibase.Invocation, client *codersdk.Client, args p
265265
return nil, err
266266
}
267267

268-
err = cliui.GitAuth(ctx, inv.Stdout, cliui.GitAuthOptions{
268+
err = cliui.ExternalAuth(ctx, inv.Stdout, cliui.ExternalAuthOptions{
269269
Fetch: func(ctx context.Context) ([]codersdk.TemplateVersionExternalAuth, error) {
270270
return client.TemplateVersionExternalAuth(ctx, templateVersion.ID)
271271
},

0 commit comments

Comments
 (0)