Skip to content

Commit 06a7207

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/site/eslint-plugin-jest-26.6.0
2 parents e589775 + 3f2cbc9 commit 06a7207

File tree

44 files changed

+779
-273
lines changed

Some content is hidden

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

44 files changed

+779
-273
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ trim_trailing_whitespace = true
77
insert_final_newline = true
88
indent_style = tab
99

10-
[*.{md,json,yaml,tf,tfvars}]
10+
[*.{md,json,yaml,yml,tf,tfvars}]
1111
indent_style = space
1212
indent_size = 2
1313

.github/codecov.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ ignore:
3434
- scripts
3535
- site/.storybook
3636
- rules.go
37+
# Packages used for writing tests.
38+
- cli/clitest
39+
- coderd/coderdtest
40+
- pty/ptytest

.github/workflows/coder.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ jobs:
8585
env:
8686
GITHUB_CONTEXT: ${{ toJSON(github) }}
8787
run: |
88-
go run github.com/coder/coder/.github/workflows/prcontext
88+
(cd .github/workflows/prcontext && go build)
89+
./.github/workflows/prcontext/prcontext
8990
9091
style-lint-golangci:
9192
name: style/lint/golangci
@@ -148,7 +149,7 @@ jobs:
148149

149150
gen:
150151
name: "style/gen"
151-
timeout-minutes: 5
152+
timeout-minutes: 8
152153
runs-on: ubuntu-latest
153154
needs: changes
154155
if: needs.changes.outputs.docs-only == 'false'
@@ -297,7 +298,7 @@ jobs:
297298
# systems.
298299
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
299300
echo ::set-output name=cover::true
300-
export COVERAGE_FLAGS='-covermode=atomic -coverprofile="gotests.coverage" -coverpkg=./...,github.com/coder/coder/codersdk'
301+
export COVERAGE_FLAGS='-covermode=atomic -coverprofile="gotests.coverage" -coverpkg=./...'
301302
else
302303
echo ::set-output name=cover::false
303304
fi

.github/workflows/prcontext/go.mod

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module github.com/coder/coder/.github/workflows/prcontext
2+
3+
go 1.18
4+
5+
require github.com/coder/flog v1.0.0
6+
7+
require (
8+
github.com/fatih/color v1.13.0 // indirect
9+
github.com/mattn/go-colorable v0.1.12 // indirect
10+
github.com/mattn/go-isatty v0.0.14 // indirect
11+
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 // indirect
12+
)

.github/workflows/prcontext/go.sum

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
github.com/coder/flog v1.0.0 h1:gqr4jYDQWYmsvFD0RV6Vs+SAj1Kbn0HGlV7UghfxP+8=
2+
github.com/coder/flog v1.0.0/go.mod h1:UQlQvrkJBvnRGo69Le8E24Tcl5SJleAAR7gYEHzAmdQ=
3+
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
4+
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
5+
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
6+
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
7+
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
8+
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
9+
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
10+
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
11+
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12+
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
13+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
14+
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
15+
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo=
16+
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@
117117
"go.coverOnSave": true,
118118
// The codersdk is used by coderd another other packages extensively.
119119
// To reduce redundancy in tests, it's covered by other packages.
120-
"go.testFlags": ["-short", "-coverpkg=./.,github.com/coder/coder/codersdk"],
120+
// Since package coverage pairing can't be defined, all packages cover
121+
// all other packages.
122+
"go.testFlags": ["-short", "-coverpkg=./..."],
121123
"go.coverageDecorator": {
122124
"type": "gutter",
123125
"coveredHighlightColor": "rgba(64,128,128,0.5)",

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ test: test-clean
176176
test-postgres: test-clean test-postgres-docker
177177
DB=ci DB_FROM=$(shell go run scripts/migrate-ci/main.go) gotestsum --junitfile="gotests.xml" --packages="./..." -- \
178178
-covermode=atomic -coverprofile="gotests.coverage" -timeout=20m \
179-
-coverpkg=./...,github.com/coder/coder/codersdk \
179+
-coverpkg=./... \
180180
-count=1 -race -failfast
181181
.PHONY: test-postgres
182182

agent/agent_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,12 @@ func TestAgent(t *testing.T) {
120120
localPort := tcpAddr.Port
121121
done := make(chan struct{})
122122
go func() {
123+
defer close(done)
123124
conn, err := local.Accept()
124-
assert.NoError(t, err)
125+
if !assert.NoError(t, err) {
126+
return
127+
}
125128
_ = conn.Close()
126-
close(done)
127129
}()
128130

129131
err = setupSSHCommand(t, []string{"-L", fmt.Sprintf("%d:127.0.0.1:%d", randomPort, localPort)}, []string{"echo", "test"}).Start()
@@ -399,15 +401,18 @@ func setupSSHCommand(t *testing.T, beforeArgs []string, afterArgs []string) *exe
399401
listener, err := net.Listen("tcp", "127.0.0.1:0")
400402
require.NoError(t, err)
401403
go func() {
404+
defer listener.Close()
402405
for {
403406
conn, err := listener.Accept()
404407
if err != nil {
405408
return
406409
}
407410
ssh, err := agentConn.SSH()
408-
assert.NoError(t, err)
409-
go io.Copy(conn, ssh)
410-
go io.Copy(ssh, conn)
411+
if !assert.NoError(t, err) {
412+
_ = conn.Close()
413+
return
414+
}
415+
go agent.Bicopy(context.Background(), conn, ssh)
411416
}
412417
}()
413418
t.Cleanup(func() {

cli/root.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cli
22

33
import (
4+
"flag"
45
"fmt"
56
"net/url"
67
"os"
@@ -175,6 +176,10 @@ func versionCmd() *cobra.Command {
175176
}
176177
}
177178

179+
func isTest() bool {
180+
return flag.Lookup("test.v") != nil
181+
}
182+
178183
// createClient returns a new client from the command context.
179184
// It reads from global configuration files if flags are not set.
180185
func createClient(cmd *cobra.Command) (*codersdk.Client, error) {

cli/root_internal_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cli
22

33
import (
4+
"os"
45
"testing"
56

67
"github.com/stretchr/testify/require"
@@ -64,3 +65,9 @@ func Test_formatExamples(t *testing.T) {
6465
})
6566
}
6667
}
68+
69+
func TestMain(m *testing.M) {
70+
// Replace with goleak.VerifyTestMain(m) when we enable goleak.
71+
os.Exit(m.Run())
72+
// goleak.VerifyTestMain(m)
73+
}

0 commit comments

Comments
 (0)