Skip to content

Commit b1a6d9c

Browse files
committed
Merge branch 'main' into oauth
2 parents a63d27b + 6dedd0c commit b1a6d9c

Some content is hidden

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

49 files changed

+974
-188
lines changed

.github/dependabot.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ updates:
3232
timezone: "America/Chicago"
3333
commit-message:
3434
prefix: "chore"
35+
labels:
36+
- "dependencies"
37+
- "go"
3538

3639
- package-ecosystem: "npm"
3740
directory: "/site/"
@@ -50,3 +53,18 @@ updates:
5053
- dependency-name: "@types/node"
5154
update-types:
5255
- version-update:semver-major
56+
57+
- package-ecosystem: "terraform"
58+
directory: "/examples"
59+
schedule:
60+
interval: "weekly"
61+
time: "06:00"
62+
timezone: "America/Chicago"
63+
commit-message:
64+
prefix: "chore"
65+
labels:
66+
- "dependencies"
67+
- "terraform"
68+
ignore:
69+
# We likely want to update this ourselves.
70+
- dependency-name: "coder/coder"

.github/semantic.yaml

+8-12
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,22 @@ types:
2525
# A build of any kind.
2626
- build
2727

28-
# A RELEASED fix that will NOT be back-ported. The originating issue may have
29-
# been discovered internally or externally to Coder.
30-
- fix
31-
32-
# Any code task that is ignored for changelog purposes. Examples include
33-
# devbin scripts and internal-only configurations.
28+
# Any code task that operates outside of CI, docs, or the product. Examples
29+
# include configurations, linters etc.
3430
- chore
3531

3632
# Any work performed on CI.
3733
- ci
38-
39-
# An UNRELEASED correction. For example, features are often built
40-
# incrementally and sometimes introduce minor flaws during a release cycle.
41-
# Corrections address those increments and flaws.
42-
- correct
34+
35+
- example
4336

4437
# Work that directly implements or supports the implementation of a feature.
4538
- feat
4639

47-
# A fix for a RELEASED bug (regression fix) that is intended for patch-release
40+
# A fix for either a released or unrelesed bug.
41+
- fix
42+
43+
# A fix for a released bug (regression fix) that is intended for patch-release
4844
# purposes.
4945
- hotfix
5046

.github/workflows/chromatic.yaml

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66
# SEE: https://www.chromatic.com/docs/ci
77
name: chromatic
88

9-
# Chromatic works best with push events, not pull_request or other event types.
10-
on: push
9+
on:
10+
push:
11+
branches:
12+
- main
13+
tags:
14+
- "*"
15+
16+
pull_request:
1117

1218
jobs:
1319
deploy:

.github/workflows/coder.yaml

+14-12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ name: coder
22

33
on:
44
push:
5+
branches:
6+
- main
7+
tags:
8+
- "*"
9+
10+
pull_request:
511

612
workflow_dispatch:
713

@@ -178,7 +184,7 @@ jobs:
178184
-timeout=3m -count=$GOCOUNT -short -failfast
179185

180186
- name: Upload DataDog Trace
181-
if: (success() || failure()) && github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
187+
if: always() && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
182188
env:
183189
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
184190
DD_DATABASE: fake
@@ -187,7 +193,7 @@ jobs:
187193
run: go run scripts/datadog-cireport/main.go gotests.xml
188194

189195
- uses: codecov/codecov-action@v3
190-
if: github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
196+
if: github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
191197
with:
192198
token: ${{ secrets.CODECOV_TOKEN }}
193199
files: ./gotests.coverage
@@ -265,15 +271,15 @@ jobs:
265271
-count=1 -parallel=2 -race -failfast
266272

267273
- name: Upload DataDog Trace
268-
if: (success() || failure()) && github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
274+
if: always() && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
269275
env:
270276
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
271277
DD_DATABASE: postgresql
272278
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
273279
run: go run scripts/datadog-cireport/main.go gotests.xml
274280

275281
- uses: codecov/codecov-action@v3
276-
if: github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
282+
if: github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
277283
with:
278284
token: ${{ secrets.CODECOV_TOKEN }}
279285
files: ./gotests.coverage
@@ -284,7 +290,7 @@ jobs:
284290
name: "deploy"
285291
runs-on: ubuntu-latest
286292
timeout-minutes: 20
287-
if: github.ref == 'refs/heads/main' && github.repository_owner == 'coder'
293+
if: github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
288294
permissions:
289295
contents: read
290296
id-token: write
@@ -386,23 +392,19 @@ jobs:
386392
- name: Install node_modules
387393
run: ./scripts/yarn_install.sh
388394

389-
- name: Build frontend
390-
run: yarn build
391-
working-directory: site
392-
393395
- run: yarn test:coverage
394396
working-directory: site
395397

396398
- uses: codecov/codecov-action@v3
397-
if: github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
399+
if: github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
398400
with:
399401
token: ${{ secrets.CODECOV_TOKEN }}
400402
files: ./site/coverage/lcov.info
401403
flags: unittest-js
402404
fail_ci_if_error: true
403405

404406
- name: Upload DataDog Trace
405-
if: (success() || failure()) && github.actor != 'dependabot[bot]' && github.repository_owner == 'coder'
407+
if: always() && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
406408
env:
407409
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
408410
DD_CATEGORY: unit
@@ -483,7 +485,7 @@ jobs:
483485
working-directory: site
484486

485487
- name: Upload DataDog Trace
486-
if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux' && github.repository_owner == 'coder'
488+
if: always() && github.actor != 'dependabot[bot]' && runner.os == 'Linux' && !github.event.pull_request.head.repo.fork
487489
env:
488490
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
489491
DD_CATEGORY: e2e

cli/gitssh_test.go

+13-20
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"net"
77
"sync/atomic"
88
"testing"
9-
"time"
109

1110
"github.com/gliderlabs/ssh"
11+
"github.com/google/uuid"
1212
"github.com/spf13/cobra"
1313
"github.com/stretchr/testify/require"
1414
gossh "golang.org/x/crypto/ssh"
@@ -24,34 +24,30 @@ import (
2424
func TestGitSSH(t *testing.T) {
2525
t.Parallel()
2626
t.Run("Dial", func(t *testing.T) {
27-
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
28-
defer cancel()
29-
instanceID := "instanceidentifier"
30-
certificates, metadataClient := coderdtest.NewAWSInstanceIdentity(t, instanceID)
31-
client := coderdtest.New(t, &coderdtest.Options{
32-
AWSInstanceIdentity: certificates,
33-
})
27+
client := coderdtest.New(t, nil)
3428
user := coderdtest.CreateFirstUser(t, client)
3529

3630
// get user public key
37-
keypair, err := client.GitSSHKey(ctx, codersdk.Me)
31+
keypair, err := client.GitSSHKey(context.Background(), codersdk.Me)
3832
require.NoError(t, err)
3933
publicKey, _, _, _, err := gossh.ParseAuthorizedKey([]byte(keypair.PublicKey))
4034
require.NoError(t, err)
4135

4236
// setup provisioner
37+
agentToken := uuid.NewString()
4338
coderdtest.NewProvisionerDaemon(t, client)
4439
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
45-
Parse: echo.ParseComplete,
40+
Parse: echo.ParseComplete,
41+
ProvisionDryRun: echo.ProvisionComplete,
4642
Provision: []*proto.Provision_Response{{
4743
Type: &proto.Provision_Response_Complete{
4844
Complete: &proto.Provision_Complete{
4945
Resources: []*proto.Resource{{
5046
Name: "somename",
5147
Type: "someinstance",
5248
Agents: []*proto.Agent{{
53-
Auth: &proto.Agent_InstanceId{
54-
InstanceId: instanceID,
49+
Auth: &proto.Agent_Token{
50+
Token: agentToken,
5551
},
5652
}},
5753
}},
@@ -65,23 +61,20 @@ func TestGitSSH(t *testing.T) {
6561
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
6662

6763
// start workspace agent
68-
cmd, root := clitest.New(t, "agent", "--auth", "aws-instance-identity", "--url", client.URL.String())
64+
cmd, root := clitest.New(t, "agent", "--token", agentToken, "--url", client.URL.String())
6965
agentClient := &*client
7066
clitest.SetupConfig(t, agentClient, root)
7167
ctx, cancelFunc := context.WithCancel(context.Background())
7268
defer cancelFunc()
7369
go func() {
74-
// A linting error occurs for weakly typing the context value here,
75-
// but it seems reasonable for a one-off test.
76-
// nolint
77-
ctx = context.WithValue(ctx, "aws-client", metadataClient)
7870
err := cmd.ExecuteContext(ctx)
7971
require.NoError(t, err)
8072
}()
73+
8174
coderdtest.AwaitWorkspaceAgents(t, client, workspace.LatestBuild.ID)
82-
resources, err := client.WorkspaceResourcesByBuild(ctx, workspace.LatestBuild.ID)
75+
resources, err := client.WorkspaceResourcesByBuild(context.Background(), workspace.LatestBuild.ID)
8376
require.NoError(t, err)
84-
dialer, err := client.DialWorkspaceAgent(ctx, resources[0].Agents[0].ID, nil, nil)
77+
dialer, err := client.DialWorkspaceAgent(context.Background(), resources[0].Agents[0].ID, nil, nil)
8578
require.NoError(t, err)
8679
defer dialer.Close()
8780
_, err = dialer.Ping()
@@ -113,7 +106,7 @@ func TestGitSSH(t *testing.T) {
113106
cmd, root = clitest.New(t, "gitssh", "--global-config="+string(cfgDir), "--", fmt.Sprintf("-p%d", addr.Port), "-o", "StrictHostKeyChecking=no", "127.0.0.1")
114107
clitest.SetupConfig(t, agentClient, root)
115108

116-
err = cmd.ExecuteContext(ctx)
109+
err = cmd.ExecuteContext(context.Background())
117110
require.NoError(t, err)
118111
require.EqualValues(t, 1, inc)
119112
})

cli/templatecreate.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ func templateCreate() *cobra.Command {
2626
provisioner string
2727
)
2828
cmd := &cobra.Command{
29-
Use: "create <directory> [name]",
29+
Use: "create [name]",
3030
Short: "Create a template from the current directory",
3131
RunE: func(cmd *cobra.Command, args []string) error {
3232
client, err := createClient(cmd)
3333
if err != nil {
3434
return err
3535
}
36+
3637
organization, err := currentOrganization(cmd, client)
3738
if err != nil {
3839
return err
@@ -44,6 +45,7 @@ func templateCreate() *cobra.Command {
4445
} else {
4546
templateName = args[0]
4647
}
48+
4749
_, err = client.TemplateByName(cmd.Context(), organization.ID, templateName)
4850
if err == nil {
4951
return xerrors.Errorf("A template already exists named %q!", templateName)
@@ -113,7 +115,7 @@ func templateCreate() *cobra.Command {
113115
"The "+cliui.Styles.Keyword.Render(templateName)+" template has been created! "+
114116
"Developers can provision a workspace with this template using:")+"\n")
115117

116-
_, _ = fmt.Fprintln(cmd.OutOrStdout(), " "+cliui.Styles.Code.Render("coder workspaces create "+templateName))
118+
_, _ = fmt.Fprintln(cmd.OutOrStdout(), " "+cliui.Styles.Code.Render(fmt.Sprintf("coder workspaces create --template=%q [workspace name]", templateName)))
117119
_, _ = fmt.Fprintln(cmd.OutOrStdout())
118120

119121
return nil
@@ -214,9 +216,15 @@ func createValidTemplateVersion(cmd *cobra.Command, client *codersdk.Client, org
214216
if err != nil {
215217
return nil, nil, err
216218
}
217-
return &version, parameters, cliui.WorkspaceResources(cmd.OutOrStdout(), resources, cliui.WorkspaceResourcesOptions{
219+
220+
err = cliui.WorkspaceResources(cmd.OutOrStdout(), resources, cliui.WorkspaceResourcesOptions{
218221
HideAgentState: true,
219222
HideAccess: true,
220223
Title: "Template Preview",
221224
})
225+
if err != nil {
226+
return nil, nil, xerrors.Errorf("preview template resources: %w", err)
227+
}
228+
229+
return &version, parameters, nil
222230
}

0 commit comments

Comments
 (0)