Skip to content

Commit c1ce35e

Browse files
committed
Merge branch 'main' into 1416-canonicalize-contributor-list
2 parents 5173dd7 + 4a78bad commit c1ce35e

File tree

77 files changed

+2059
-654
lines changed

Some content is hidden

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

77 files changed

+2059
-654
lines changed

.github/workflows/coder.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,7 @@ jobs:
275275
done
276276
277277
- name: Test with PostgreSQL Database
278-
run: DB=ci gotestsum --junitfile="gotests.xml" --packages="./..." --
279-
-covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
280-
-coverpkg=./...,github.com/coder/coder/codersdk
281-
-count=1 -parallel=2 -race -failfast
278+
run: "make test-postgres"
282279

283280
- name: Upload DataDog Trace
284281
if: always() && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
@@ -366,6 +363,13 @@ jobs:
366363
with:
367364
name: coder_linux_amd64.deb
368365
path: ./dist/coder_*_linux_amd64.deb
366+
retention-period: 7
367+
368+
- uses: actions/upload-artifact@v3
369+
with:
370+
name: coder_linux_amd64.tar.gz
371+
path: ./dist/coder_*_linux_amd64.tar.gz
372+
retention-period: 7
369373

370374
- name: Install Release
371375
run: |

.goreleaser.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,14 @@ archives:
22
- id: coder-linux
33
builds: [coder-linux]
44
format: tar.gz
5-
files:
6-
- src: docs/README.md
7-
dst: README.md
85

96
- id: coder-darwin
107
builds: [coder-darwin]
118
format: zip
12-
files:
13-
- src: docs/README.md
14-
dst: README.md
159

1610
- id: coder-windows
1711
builds: [coder-windows]
1812
format: zip
19-
files:
20-
- src: docs/README.md
21-
dst: README.md
2213

2314
before:
2415
hooks:

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"coderd",
88
"coderdtest",
99
"codersdk",
10+
"cronstrue",
1011
"devel",
1112
"drpc",
1213
"drpcconn",

Makefile

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,33 @@ site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find codersdk
9191
go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts
9292
cd site && yarn run format:types
9393

94-
test:
94+
.PHONY: test
95+
test: test-clean
9596
gotestsum -- -v -short ./...
97+
98+
.PHONY: test-postgres
99+
test-postgres: test-clean
100+
DB=ci gotestsum --junitfile="gotests.xml" --packages="./..." -- \
101+
-covermode=atomic -coverprofile="gotests.coverage" -timeout=5m \
102+
-coverpkg=./...,github.com/coder/coder/codersdk \
103+
-count=1 -parallel=1 -race -failfast
104+
105+
106+
.PHONY: test-postgres-docker
107+
test-postgres-docker:
108+
docker run \
109+
--env POSTGRES_PASSWORD=postgres \
110+
--env POSTGRES_USER=postgres \
111+
--env POSTGRES_DB=postgres \
112+
--env PGDATA=/tmp \
113+
--publish 5432:5432 \
114+
--name test-postgres-docker \
115+
--restart unless-stopped \
116+
--detach \
117+
postgres:11 \
118+
-c shared_buffers=1GB \
119+
-c max_connections=1000
120+
121+
.PHONY: test-clean
122+
test-clean:
123+
go clean -testcache

docs/README.md renamed to README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ Follow](https://img.shields.io/twitter/follow/CoderHQ?label=%40CoderHQ&style=soc
1010

1111
Provision remote development environments with Terraform.
1212

13-
![Kubernetes workspace in Coder v2](./screenshot.png)
13+
![Kubernetes workspace in Coder v2](./docs/screenshot.png)
1414

1515
## Highlights
1616

1717
- Automate development environments for Linux, Windows, and macOS
1818
- Start writing code with a single command
19-
- Get started quickly using one of the [examples](../examples) provided
19+
- Get started quickly using one of the [examples](./examples) provided
2020

2121
## Installing Coder
2222

@@ -34,7 +34,7 @@ CPU core and 2 GB RAM:
3434
You can set up a temporary deployment, a production deployment, or a system service:
3535

3636
- To set up a **temporary deployment**, start with dev mode (all data is in-memory and is
37-
destroyed on exit):
37+
destroyed on exit):
3838

3939
```bash
4040
coder server --dev
@@ -48,7 +48,7 @@ destroyed on exit):
4848
```
4949

5050
- To run as a **system service**, install with `.deb` (Debian, Ubuntu) or `.rpm`
51-
(Fedora, CentOS, RHEL, SUSE):
51+
(Fedora, CentOS, RHEL, SUSE):
5252

5353
```bash
5454
# Edit the configuration!
@@ -57,7 +57,7 @@ destroyed on exit):
5757
```
5858

5959
> Use `coder --help` to get a complete list of flags and environment
60-
variables.
60+
> variables.
6161
6262
## Creating your first template and workspace
6363

@@ -95,26 +95,26 @@ coder templates update gcp-linux
9595

9696
## Documentation
9797

98-
- [About Coder](./about.md#about-coder)
99-
- [Why remote development](about.md#why-remote-development)
100-
- [Why Coder](about.md#why-coder)
101-
- [What Coder is not](about.md#what-coder-is-not)
102-
- [Comparison: Coder vs. [product]](about.md#comparison)
103-
- [Templates](./templates.md)
104-
- [Manage templates](./templates.md#manage-templates)
98+
- [About Coder](./docs/about.md#about-coder)
99+
- [Why remote development](./docs/about.md#why-remote-development)
100+
- [Why Coder](./docs/about.md#why-coder)
101+
- [What Coder is not](./docs/about.md#what-coder-is-not)
102+
- [Comparison: Coder vs. [product]](./docs/about.md#comparison)
103+
- [Templates](./docs/templates.md)
104+
- [Manage templates](./docs/templates.md#manage-templates)
105105
- [Persistent and ephemeral
106-
resources](./templates.md#persistent-and-ephemeral-resources)
107-
- [Parameters](./templates.md#parameters)
108-
- [Workspaces](./workspaces.md)
109-
- [Create workspaces](./workspaces.md#create-workspaces)
110-
- [Connect with SSH](./workspaces.md#connect-with-ssh)
111-
- [Editors and IDEs](./workspaces.md#editors-and-ides)
112-
- [Workspace lifecycle](./workspaces.md#workspace-lifecycle)
113-
- [Updating workspaces](./workspaces.md#updating-workspaces)
106+
resources](./docs/templates.md#persistent-and-ephemeral-resources)
107+
- [Parameters](./docs/templates.md#parameters)
108+
- [Workspaces](./docs/workspaces.md)
109+
- [Create workspaces](./docs/workspaces.md#create-workspaces)
110+
- [Connect with SSH](./docs/workspaces.md#connect-with-ssh)
111+
- [Editors and IDEs](./docs/workspaces.md#editors-and-ides)
112+
- [Workspace lifecycle](./docs/workspaces.md#workspace-lifecycle)
113+
- [Updating workspaces](./docs/workspaces.md#updating-workspaces)
114114

115115
## Contributing
116116

117-
Read the [contributing docs](./CONTRIBUTING.md).
117+
Read the [contributing docs](./docs/CONTRIBUTING.md).
118118

119119
## Contributors
120120

cli/agent_test.go

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,12 @@ func TestWorkspaceAgent(t *testing.T) {
4949
cmd, _ := clitest.New(t, "agent", "--auth", "azure-instance-identity", "--agent-url", client.URL.String())
5050
ctx, cancelFunc := context.WithCancel(context.Background())
5151
defer cancelFunc()
52+
errC := make(chan error)
5253
go func() {
53-
// A linting error occurs for weakly typing the context value here,
54-
// but it seems reasonable for a one-off test.
55-
// nolint
56-
ctx = context.WithValue(ctx, "azure-client", metadataClient)
57-
err := cmd.ExecuteContext(ctx)
58-
require.NoError(t, err)
54+
// A linting error occurs for weakly typing the context value here.
55+
//nolint // The above seems reasonable for a one-off test.
56+
ctx := context.WithValue(ctx, "azure-client", metadataClient)
57+
errC <- cmd.ExecuteContext(ctx)
5958
}()
6059
coderdtest.AwaitWorkspaceAgents(t, client, workspace.LatestBuild.ID)
6160
resources, err := client.WorkspaceResourcesByBuild(ctx, workspace.LatestBuild.ID)
@@ -66,6 +65,8 @@ func TestWorkspaceAgent(t *testing.T) {
6665
_, err = dialer.Ping()
6766
require.NoError(t, err)
6867
cancelFunc()
68+
err = <-errC
69+
require.NoError(t, err)
6970
})
7071

7172
t.Run("AWS", func(t *testing.T) {
@@ -103,13 +104,12 @@ func TestWorkspaceAgent(t *testing.T) {
103104
cmd, _ := clitest.New(t, "agent", "--auth", "aws-instance-identity", "--agent-url", client.URL.String())
104105
ctx, cancelFunc := context.WithCancel(context.Background())
105106
defer cancelFunc()
107+
errC := make(chan error)
106108
go func() {
107-
// A linting error occurs for weakly typing the context value here,
108-
// but it seems reasonable for a one-off test.
109-
// nolint
110-
ctx = context.WithValue(ctx, "aws-client", metadataClient)
111-
err := cmd.ExecuteContext(ctx)
112-
require.NoError(t, err)
109+
// A linting error occurs for weakly typing the context value here.
110+
//nolint // The above seems reasonable for a one-off test.
111+
ctx := context.WithValue(ctx, "aws-client", metadataClient)
112+
errC <- cmd.ExecuteContext(ctx)
113113
}()
114114
coderdtest.AwaitWorkspaceAgents(t, client, workspace.LatestBuild.ID)
115115
resources, err := client.WorkspaceResourcesByBuild(ctx, workspace.LatestBuild.ID)
@@ -120,6 +120,8 @@ func TestWorkspaceAgent(t *testing.T) {
120120
_, err = dialer.Ping()
121121
require.NoError(t, err)
122122
cancelFunc()
123+
err = <-errC
124+
require.NoError(t, err)
123125
})
124126

125127
t.Run("GoogleCloud", func(t *testing.T) {
@@ -157,13 +159,12 @@ func TestWorkspaceAgent(t *testing.T) {
157159
cmd, _ := clitest.New(t, "agent", "--auth", "google-instance-identity", "--agent-url", client.URL.String())
158160
ctx, cancelFunc := context.WithCancel(context.Background())
159161
defer cancelFunc()
162+
errC := make(chan error)
160163
go func() {
161-
// A linting error occurs for weakly typing the context value here,
162-
// but it seems reasonable for a one-off test.
163-
// nolint
164-
ctx = context.WithValue(ctx, "gcp-client", metadata)
165-
err := cmd.ExecuteContext(ctx)
166-
require.NoError(t, err)
164+
// A linting error occurs for weakly typing the context value here.
165+
//nolint // The above seems reasonable for a one-off test.
166+
ctx := context.WithValue(ctx, "gcp-client", metadata)
167+
errC <- cmd.ExecuteContext(ctx)
167168
}()
168169
coderdtest.AwaitWorkspaceAgents(t, client, workspace.LatestBuild.ID)
169170
resources, err := client.WorkspaceResourcesByBuild(ctx, workspace.LatestBuild.ID)
@@ -174,5 +175,7 @@ func TestWorkspaceAgent(t *testing.T) {
174175
_, err = dialer.Ping()
175176
require.NoError(t, err)
176177
cancelFunc()
178+
err = <-errC
179+
require.NoError(t, err)
177180
})
178181
}

cli/clitest/clitest_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package clitest_test
33
import (
44
"testing"
55

6-
"github.com/stretchr/testify/require"
76
"go.uber.org/goleak"
87

98
"github.com/coder/coder/cli/clitest"
@@ -25,8 +24,7 @@ func TestCli(t *testing.T) {
2524
cmd.SetIn(pty.Input())
2625
cmd.SetOut(pty.Output())
2726
go func() {
28-
err := cmd.Execute()
29-
require.NoError(t, err)
27+
_ = cmd.Execute()
3028
}()
3129
pty.ExpectMatch("coder")
3230
}

cli/cliui/prompt.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,21 @@ type PromptOptions struct {
2424
Validate func(string) error
2525
}
2626

27+
func AllowSkipPrompt(cmd *cobra.Command) {
28+
cmd.Flags().BoolP("yes", "y", false, "Bypass prompts")
29+
}
30+
2731
// Prompt asks the user for input.
2832
func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) {
33+
// If the cmd has a "yes" flag for skipping confirm prompts, honor it.
34+
// If it's not a "Confirm" prompt, then don't skip. As the default value of
35+
// "yes" makes no sense.
36+
if opts.IsConfirm && cmd.Flags().Lookup("yes") != nil {
37+
if skip, _ := cmd.Flags().GetBool("yes"); skip {
38+
return "yes", nil
39+
}
40+
}
41+
2942
_, _ = fmt.Fprint(cmd.OutOrStdout(), Styles.FocusedPrompt.String()+opts.Text+" ")
3043
if opts.IsConfirm {
3144
opts.Default = "yes"

0 commit comments

Comments
 (0)