Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4770ad8

Browse files
authored
Merge branch 'coder:main' into GraphQL-code-scanning
2 parents 2f3d512 + ca0374b commit 4770ad8

File tree

167 files changed

+3407
-1111
lines changed

Some content is hidden

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

167 files changed

+3407
-1111
lines changed

.github/workflows/coder.yaml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Checkout
3535
uses: actions/checkout@v2
3636
- name: typos-action
37-
uses: crate-ci/typos@v1.12.12
37+
uses: crate-ci/typos@v1.13.3
3838
with:
3939
config: .github/workflows/typos.toml
4040
- name: Fix Helper
@@ -274,6 +274,9 @@ jobs:
274274
export PATH=${PATH}:$(go env GOPATH)/bin
275275
make --output-sync -j -B fmt
276276
277+
- name: Check for unstaged files
278+
run: ./scripts/check_unstaged.sh
279+
277280
test-go:
278281
name: "test/go"
279282
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'windows-latest-8-cores'|| matrix.os }}
@@ -336,7 +339,14 @@ jobs:
336339
echo ::set-output name=cover::false
337340
fi
338341
set -x
339-
gotestsum --junitfile="gotests.xml" --packages="./..." --debug -- -parallel=8 -timeout=3m -short -failfast $COVERAGE_FLAGS
342+
gotestsum --junitfile="gotests.xml" --jsonfile="gotestsum.json" --packages="./..." --debug -- -parallel=8 -timeout=3m -short -failfast $COVERAGE_FLAGS
343+
344+
- uses: actions/upload-artifact@v3
345+
if: success() || failure()
346+
with:
347+
name: gotestsum-debug-${{ matrix.os }}.json
348+
path: ./gotestsum.json
349+
retention-days: 7
340350

341351
- uses: codecov/codecov-action@v3
342352
# This action has a tendency to error out unexpectedly, it has
@@ -399,6 +409,13 @@ jobs:
399409
- name: Test with PostgreSQL Database
400410
run: make test-postgres
401411

412+
- uses: actions/upload-artifact@v3
413+
if: success() || failure()
414+
with:
415+
name: gotestsum-debug-postgres.json
416+
path: ./gotestsum.json
417+
retention-days: 7
418+
402419
- uses: codecov/codecov-action@v3
403420
# This action has a tendency to error out unexpectedly, it has
404421
# the `fail_ci_if_error` option that defaults to `false`, but
@@ -674,6 +691,19 @@ jobs:
674691
runs-on: ubuntu-latest
675692
steps:
676693
- uses: actions/checkout@master
677-
- uses: gaurav-nelson/github-action-markdown-link-check@v1
694+
# For the main branch:
695+
- if: github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
696+
uses: gaurav-nelson/github-action-markdown-link-check@v1
697+
with:
698+
use-quiet-mode: yes
699+
use-verbose-mode: yes
700+
config-file: .github/workflows/mlc_config.json
701+
# For pull requests:
702+
- if: github.ref != 'refs/heads/main' || github.event.pull_request.head.repo.fork
703+
uses: gaurav-nelson/github-action-markdown-link-check@v1
678704
with:
705+
use-quiet-mode: yes
706+
use-verbose-mode: yes
707+
check-modified-files-only: yes
708+
base-branch: main
679709
config-file: .github/workflows/mlc_config.json

.github/workflows/packages.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ jobs:
3535
3636
echo "Installer URL: $installer_url"
3737
38-
# version should be extracted from the installer
39-
wingetcreate update Coder.Coder `
38+
.\wingetcreate.exe update Coder.Coder `
4039
--submit `
4140
--version "${{ steps.version.outputs.version }}" `
4241
--urls "$installer_url" `

.github/workflows/typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ doas = "doas"
1010
darcula = "darcula"
1111
Hashi = "Hashi"
1212
trialer = "trialer"
13+
encrypter = "encrypter"
1314

1415
[files]
1516
extend-exclude = [

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ vendor
1515
yarn-error.log
1616
gotests.coverage
1717
gotests.xml
18+
gotestsum.json
1819
.idea
1920
.gitpod.yml
2021
.DS_Store

ADOPTERS.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Adopters
1+
# Adopters
2+
23
[!["Join us on
34
Discord"](https://img.shields.io/badge/join-us%20on%20Discord-gray.svg?longCache=true&logo=discord&colorB=green)](https://coder.com/chat?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=adopters.md) [![Twitter
45
Follow](https://img.shields.io/twitter/follow/coderhq?label=%40coderhq&style=social)](https://twitter.com/coderhq)
@@ -7,6 +8,6 @@ Follow](https://img.shields.io/twitter/follow/coderhq?label=%40coderhq&style=soc
78

89
> 👋 _If you are considering using Coder in your organization please introduce yourself via https://coder.com/demo_ 🙇🏻‍♂️
910
10-
| Organization | Contact | Description of Use |
11-
| --------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
12-
| [Coder](https://www.coder.com) | [@coderhq](https://twitter.com/coderhq) | Coder builds coder with Coder. |
11+
| Organization | Contact | Description of Use |
12+
| ------------------------------ | --------------------------------------- | ------------------------------ |
13+
| [Coder](https://www.coder.com) | [@coderhq](https://twitter.com/coderhq) | Coder builds coder with Coder. |

Makefile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,9 @@ fmt/prettier:
359359
cd site
360360
# Avoid writing files in CI to reduce file write activity
361361
ifdef CI
362-
yarn run format:check
362+
yarn run format:check . ../*.md ../docs
363363
else
364-
yarn run format:write
364+
yarn run format:write . ../*.md ../docs
365365
endif
366366
.PHONY: fmt/prettier
367367

@@ -452,11 +452,7 @@ site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find codersdk
452452
docs/admin/prometheus.md: scripts/metricsdocgen/main.go scripts/metricsdocgen/metrics
453453
go run scripts/metricsdocgen/main.go
454454
cd site
455-
ifdef CI
456-
yarn run format:check
457-
else
458-
yarn run format:write
459-
endif
455+
yarn run format:write ../docs/admin/prometheus.md
460456

461457
update-golden-files: cli/testdata/.gen-golden
462458
.PHONY: update-golden-files
@@ -475,7 +471,10 @@ test: test-clean
475471
test-postgres: test-clean test-postgres-docker
476472
# The postgres test is prone to failure, so we limit parallelism for
477473
# more consistent execution.
478-
DB=ci DB_FROM=$(shell go run scripts/migrate-ci/main.go) gotestsum --junitfile="gotests.xml" --packages="./..." -- \
474+
DB=ci DB_FROM=$(shell go run scripts/migrate-ci/main.go) gotestsum \
475+
--junitfile="gotests.xml" \
476+
--jsonfile="gotestsum.json" \
477+
--packages="./..." -- \
479478
-covermode=atomic -coverprofile="gotests.coverage" -timeout=20m \
480479
-parallel=4 \
481480
-coverpkg=./... \

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Software development on your infrastructure. Offload your team's development fro
1111

1212
> "By leveraging Terraform, Coder lets developers run any IDE on any compute platform including on-prem, AWS, Azure, GCP, DigitalOcean, Kubernetes, Docker, and more, with workspaces running on Linux, Windows, or Mac." - **Kevin Fishner Chief of Staff at [HashiCorp](https://hashicorp.com/)**
1313
14-
1514
<p align="center">
1615
<img src="./docs/images/hero-image.png">
1716
</p>
@@ -83,6 +82,10 @@ Use `coder --help` to get a complete list of flags and environment variables. Us
8382

8483
Visit our docs [here](https://coder.com/docs/coder-oss).
8584

85+
## Templates
86+
87+
Find our templates [here](./examples/templates).
88+
8689
## Comparison
8790

8891
Please file [an issue](https://github.com/coder/coder/issues/new) if any information is out of date. Also refer to: [What Coder is not](https://coder.com/docs/coder-oss/latest/index#what-coder-is-not).
@@ -92,7 +95,7 @@ Please file [an issue](https://github.com/coder/coder/issues/new) if any informa
9295
| [Coder](https://github.com/coder/coder) | Platform | OSS + Self-Managed | Pay your cloud | All [Terraform](https://www.terraform.io/registry/providers) resources, all clouds, multi-architecture: Linux, Mac, Windows, containers, VMs, amd64, arm64 |
9396
| [code-server](https://github.com/cdr/code-server) | Web IDE | OSS + Self-Managed | Pay your cloud | Linux, Mac, Windows, containers, VMs, amd64, arm64 |
9497
| [Coder (Classic)](https://coder.com/docs) | Platform | Self-Managed | Pay your cloud + license fees | Kubernetes Linux Containers |
95-
| [GitHub Codespaces](https://github.com/features/codespaces) | Platform | SaaS | 2x Azure Compute | Linux Virtual Machines |
98+
| [GitHub Codespaces](https://github.com/features/codespaces) | Platform | SaaS | 2x Azure Compute | Linux Virtual Machines |
9699

97100
---
98101

agent/agent.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,13 @@ func (a *agent) trackConnGoroutine(fn func()) error {
245245
return nil
246246
}
247247

248-
func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (network *tailnet.Conn, err error) {
248+
func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_ *tailnet.Conn, err error) {
249249
a.closeMutex.Lock()
250250
if a.isClosed() {
251251
a.closeMutex.Unlock()
252252
return nil, xerrors.New("closed")
253253
}
254-
network, err = tailnet.NewConn(&tailnet.Options{
254+
network, err := tailnet.NewConn(&tailnet.Options{
255255
Addresses: []netip.Prefix{netip.PrefixFrom(codersdk.TailnetIP, 128)},
256256
DERPMap: derpMap,
257257
Logger: a.logger.Named("tailnet"),
@@ -266,7 +266,6 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (ne
266266
network.Close()
267267
}
268268
}()
269-
a.network = network
270269
a.closeMutex.Unlock()
271270

272271
sshListener, err := network.Listen("tcp", ":"+strconv.Itoa(codersdk.TailnetSSHPort))

agent/agent_test.go

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ func TestAgent(t *testing.T) {
153153
err := session.RequestPty("xterm", 128, 128, ssh.TerminalModes{})
154154
require.NoError(t, err)
155155
ptty := ptytest.New(t)
156-
require.NoError(t, err)
157156
session.Stdout = ptty.Output()
158157
session.Stderr = ptty.Output()
159158
session.Stdin = ptty.Input()
@@ -178,7 +177,6 @@ func TestAgent(t *testing.T) {
178177
err := session.RequestPty("xterm", 128, 128, ssh.TerminalModes{})
179178
require.NoError(t, err)
180179
ptty := ptytest.New(t)
181-
require.NoError(t, err)
182180
session.Stdout = ptty.Output()
183181
session.Stderr = ptty.Output()
184182
session.Stdin = ptty.Input()
@@ -280,8 +278,8 @@ func TestAgent(t *testing.T) {
280278
require.NotContains(t, stdout.String(), wantNotMOTD, "should not show motd")
281279
})
282280

281+
//nolint:paralleltest // This test reserves a port.
283282
t.Run("LocalForwarding", func(t *testing.T) {
284-
t.Parallel()
285283
random, err := net.Listen("tcp", "127.0.0.1:0")
286284
require.NoError(t, err)
287285
_ = random.Close()
@@ -330,6 +328,7 @@ func TestAgent(t *testing.T) {
330328
defer sshClient.Close()
331329
client, err := sftp.NewClient(sshClient)
332330
require.NoError(t, err)
331+
defer client.Close()
333332
wd, err := client.Getwd()
334333
require.NoError(t, err, "get working directory")
335334
require.Equal(t, home, wd, "working directory should be home user home")
@@ -360,6 +359,7 @@ func TestAgent(t *testing.T) {
360359
defer sshClient.Close()
361360
scpClient, err := scp.NewClientBySSH(sshClient)
362361
require.NoError(t, err)
362+
defer scpClient.Close()
363363
tempFile := filepath.Join(t.TempDir(), "scp")
364364
content := "hello world"
365365
err = scpClient.CopyFile(context.Background(), strings.NewReader(content), tempFile, "0755")
@@ -501,6 +501,8 @@ func TestAgent(t *testing.T) {
501501
id := uuid.New()
502502
netConn, err := conn.ReconnectingPTY(ctx, id, 100, 100, "/bin/bash")
503503
require.NoError(t, err)
504+
defer netConn.Close()
505+
504506
bufRead := bufio.NewReader(netConn)
505507

506508
// Brief pause to reduce the likelihood that we send keystrokes while
@@ -539,6 +541,8 @@ func TestAgent(t *testing.T) {
539541
_ = netConn.Close()
540542
netConn, err = conn.ReconnectingPTY(ctx, id, 100, 100, "/bin/bash")
541543
require.NoError(t, err)
544+
defer netConn.Close()
545+
542546
bufRead = bufio.NewReader(netConn)
543547

544548
// Same output again!
@@ -629,6 +633,8 @@ func TestAgent(t *testing.T) {
629633
// After the agent is disconnected from a coordinator, it's supposed
630634
// to reconnect!
631635
coordinator := tailnet.NewCoordinator()
636+
defer coordinator.Close()
637+
632638
agentID := uuid.New()
633639
statsCh := make(chan *codersdk.AgentStats)
634640
derpMap := tailnettest.RunDERPAndSTUN(t)
@@ -650,9 +656,7 @@ func TestAgent(t *testing.T) {
650656
Client: client,
651657
Logger: slogtest.Make(t, nil).Leveled(slog.LevelInfo),
652658
})
653-
t.Cleanup(func() {
654-
_ = closer.Close()
655-
})
659+
defer closer.Close()
656660

657661
require.Eventually(t, func() bool {
658662
return coordinator.Node(agentID) != nil
@@ -665,6 +669,10 @@ func TestAgent(t *testing.T) {
665669

666670
t.Run("WriteVSCodeConfigs", func(t *testing.T) {
667671
t.Parallel()
672+
673+
coordinator := tailnet.NewCoordinator()
674+
defer coordinator.Close()
675+
668676
client := &client{
669677
t: t,
670678
agentID: uuid.New(),
@@ -673,7 +681,7 @@ func TestAgent(t *testing.T) {
673681
DERPMap: &tailcfg.DERPMap{},
674682
},
675683
statsChan: make(chan *codersdk.AgentStats),
676-
coordinator: tailnet.NewCoordinator(),
684+
coordinator: coordinator,
677685
}
678686
filesystem := afero.NewMemMapFs()
679687
closer := agent.New(agent.Options{
@@ -684,9 +692,8 @@ func TestAgent(t *testing.T) {
684692
Logger: slogtest.Make(t, nil).Leveled(slog.LevelInfo),
685693
Filesystem: filesystem,
686694
})
687-
t.Cleanup(func() {
688-
_ = closer.Close()
689-
})
695+
defer closer.Close()
696+
690697
home, err := os.UserHomeDir()
691698
require.NoError(t, err)
692699
path := filepath.Join(home, ".vscode-server", "data", "Machine", "settings.json")
@@ -749,6 +756,9 @@ func setupSSHSession(t *testing.T, options codersdk.WorkspaceAgentMetadata) *ssh
749756
})
750757
session, err := sshClient.NewSession()
751758
require.NoError(t, err)
759+
t.Cleanup(func() {
760+
_ = session.Close()
761+
})
752762
return session
753763
}
754764

@@ -767,6 +777,9 @@ func setupAgent(t *testing.T, metadata codersdk.WorkspaceAgentMetadata, ptyTimeo
767777
metadata.DERPMap = tailnettest.RunDERPAndSTUN(t)
768778
}
769779
coordinator := tailnet.NewCoordinator()
780+
t.Cleanup(func() {
781+
_ = coordinator.Close()
782+
})
770783
agentID := uuid.New()
771784
statsCh := make(chan *codersdk.AgentStats, 50)
772785
fs := afero.NewMemMapFs()

cli/deployment/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ func newConfig() *codersdk.DeploymentConfig {
216216
Flag: "oidc-client-secret",
217217
Secret: true,
218218
},
219-
EmailDomain: &codersdk.DeploymentConfigField[string]{
219+
EmailDomain: &codersdk.DeploymentConfigField[[]string]{
220220
Name: "OIDC Email Domain",
221-
Usage: "Email domain that clients logging in with OIDC must match.",
221+
Usage: "Email domains that clients logging in with OIDC must match.",
222222
Flag: "oidc-email-domain",
223223
},
224224
IssuerURL: &codersdk.DeploymentConfigField[string]{

cli/deployment/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func TestConfig(t *testing.T) {
154154
},
155155
Valid: func(config *codersdk.DeploymentConfig) {
156156
require.Equal(t, config.OIDC.IssuerURL.Value, "https://accounts.google.com")
157-
require.Equal(t, config.OIDC.EmailDomain.Value, "coder.com")
157+
require.Equal(t, config.OIDC.EmailDomain.Value, []string{"coder.com"})
158158
require.Equal(t, config.OIDC.ClientID.Value, "client")
159159
require.Equal(t, config.OIDC.ClientSecret.Value, "secret")
160160
require.False(t, config.OIDC.AllowSignups.Value)

0 commit comments

Comments
 (0)