Skip to content

Commit ab31bad

Browse files
committed
Merge branch 'main' into f0ssel/shared-ports-experiment
2 parents d316b31 + c2cb0e9 commit ab31bad

File tree

8 files changed

+38
-112
lines changed

8 files changed

+38
-112
lines changed

.github/actions/setup-go/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ runs:
99
using: "composite"
1010
steps:
1111
- name: Setup Go
12-
uses: buildjet/setup-go@v4
12+
uses: buildjet/setup-go@v5
1313
with:
1414
go-version: ${{ inputs.version }}
1515

.github/actions/setup-node/action.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ runs:
1111
using: "composite"
1212
steps:
1313
- name: Install pnpm
14-
uses: pnpm/action-setup@v2
14+
uses: pnpm/action-setup@v3
1515
with:
1616
version: 8
1717
- name: Setup Node
18-
uses: buildjet/setup-node@v3
18+
uses: buildjet/setup-node@v4.0.1
1919
with:
2020
node-version: 18.19.0
2121
# See https://github.com/actions/setup-node#caching-global-packages-data

.github/codecov.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -269,16 +269,6 @@ jobs:
269269
id: test
270270
shell: bash
271271
run: |
272-
# Code coverage is more computationally expensive and also
273-
# prevents test caching, so we disable it on alternate operating
274-
# systems.
275-
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
276-
echo "cover=true" >> $GITHUB_OUTPUT
277-
export COVERAGE_FLAGS='-covermode=atomic -coverprofile="gotests.coverage" -coverpkg=./...'
278-
else
279-
echo "cover=false" >> $GITHUB_OUTPUT
280-
fi
281-
282272
# if macOS, install google-chrome for scaletests. As another concern,
283273
# should we really have this kind of external dependency requirement
284274
# on standard CI?
@@ -297,7 +287,7 @@ jobs:
297287
fi
298288
export TS_DEBUG_DISCO=true
299289
gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" \
300-
--packages="./..." -- $PARALLEL_FLAG -short -failfast $COVERAGE_FLAGS
290+
--packages="./..." -- $PARALLEL_FLAG -short -failfast
301291
302292
- name: Upload test stats to Datadog
303293
timeout-minutes: 1
@@ -307,19 +297,6 @@ jobs:
307297
with:
308298
api-key: ${{ secrets.DATADOG_API_KEY }}
309299

310-
- name: Check code coverage
311-
uses: codecov/codecov-action@v4
312-
# This action has a tendency to error out unexpectedly, it has
313-
# the `fail_ci_if_error` option that defaults to `false`, but
314-
# that is no guarantee, see:
315-
# https://github.com/codecov/codecov-action/issues/788
316-
continue-on-error: true
317-
if: steps.test.outputs.cover && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
318-
with:
319-
token: ${{ secrets.CODECOV_TOKEN }}
320-
files: ./gotests.coverage
321-
flags: unittest-go-${{ matrix.os }}
322-
323300
test-go-pg:
324301
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
325302
needs:
@@ -355,19 +332,6 @@ jobs:
355332
with:
356333
api-key: ${{ secrets.DATADOG_API_KEY }}
357334

358-
- name: Check code coverage
359-
uses: codecov/codecov-action@v4
360-
# This action has a tendency to error out unexpectedly, it has
361-
# the `fail_ci_if_error` option that defaults to `false`, but
362-
# that is no guarantee, see:
363-
# https://github.com/codecov/codecov-action/issues/788
364-
continue-on-error: true
365-
if: github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
366-
with:
367-
token: ${{ secrets.CODECOV_TOKEN }}
368-
files: ./gotests.coverage
369-
flags: unittest-go-postgres-linux
370-
371335
test-go-race:
372336
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
373337
needs: changes
@@ -414,19 +378,6 @@ jobs:
414378
- run: pnpm test:ci --max-workers $(nproc)
415379
working-directory: site
416380

417-
- name: Check code coverage
418-
uses: codecov/codecov-action@v4
419-
# This action has a tendency to error out unexpectedly, it has
420-
# the `fail_ci_if_error` option that defaults to `false`, but
421-
# that is no guarantee, see:
422-
# https://github.com/codecov/codecov-action/issues/788
423-
continue-on-error: true
424-
if: github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork
425-
with:
426-
token: ${{ secrets.CODECOV_TOKEN }}
427-
files: ./site/coverage/lcov.info
428-
flags: unittest-js
429-
430381
test-e2e:
431382
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-16vcpu-ubuntu-2204' || 'ubuntu-latest' }}
432383
needs: changes

cli/speedtest.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,22 @@ func (r *RootCmd) speedtest() *serpent.Command {
6060
if r.disableDirect {
6161
_, _ = fmt.Fprintln(inv.Stderr, "Direct connections disabled.")
6262
}
63+
opts := &workspacesdk.DialAgentOptions{
64+
Logger: logger,
65+
}
66+
if pcapFile != "" {
67+
s := capture.New()
68+
opts.CaptureHook = s.LogPacket
69+
f, err := os.OpenFile(pcapFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644)
70+
if err != nil {
71+
return err
72+
}
73+
defer f.Close()
74+
unregister := s.RegisterOutput(f)
75+
defer unregister()
76+
}
6377
conn, err := workspacesdk.New(client).
64-
DialAgent(ctx, workspaceAgent.ID, &workspacesdk.DialAgentOptions{
65-
Logger: logger,
66-
})
78+
DialAgent(ctx, workspaceAgent.ID, opts)
6779
if err != nil {
6880
return err
6981
}
@@ -102,18 +114,6 @@ func (r *RootCmd) speedtest() *serpent.Command {
102114
conn.AwaitReachable(ctx)
103115
}
104116

105-
if pcapFile != "" {
106-
s := capture.New()
107-
conn.InstallCaptureHook(s.LogPacket)
108-
f, err := os.OpenFile(pcapFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644)
109-
if err != nil {
110-
return err
111-
}
112-
defer f.Close()
113-
unregister := s.RegisterOutput(f)
114-
defer unregister()
115-
}
116-
117117
var tsDir tsspeedtest.Direction
118118
switch direction {
119119
case "up":

codersdk/workspacesdk/workspacesdk.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"golang.org/x/xerrors"
1717
"nhooyr.io/websocket"
1818
"tailscale.com/tailcfg"
19+
"tailscale.com/wgengine/capture"
1920

2021
"cdr.dev/slog"
2122
"github.com/coder/coder/v2/codersdk"
@@ -176,6 +177,9 @@ type DialAgentOptions struct {
176177
// BlockEndpoints forced a direct connection through DERP. The Client may
177178
// have DisableDirect set which will override this value.
178179
BlockEndpoints bool
180+
// CaptureHook is a callback that captures Disco packets and packets sent
181+
// into the tailnet tunnel.
182+
CaptureHook capture.Callback
179183
}
180184

181185
func (c *Client) DialAgent(dialCtx context.Context, agentID uuid.UUID, options *DialAgentOptions) (agentConn *AgentConn, err error) {
@@ -203,6 +207,7 @@ func (c *Client) DialAgent(dialCtx context.Context, agentID uuid.UUID, options *
203207
DERPForceWebSockets: connInfo.DERPForceWebSockets,
204208
Logger: options.Logger,
205209
BlockEndpoints: c.client.DisableDirectConnections || options.BlockEndpoints,
210+
CaptureHook: options.CaptureHook,
206211
})
207212
if err != nil {
208213
return nil, xerrors.Errorf("create tailnet: %w", err)

scripts/testidp/main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,14 @@ func RunIDP() func(t *testing.T) {
8484
return func(t *testing.T) {
8585
idp := oidctest.NewFakeIDP(t,
8686
oidctest.WithServing(),
87-
oidctest.WithStaticUserInfo(jwt.MapClaims{}),
87+
oidctest.WithStaticUserInfo(jwt.MapClaims{
88+
// This is a static set of auth fields. Might be beneficial to make flags
89+
// to allow different values here. This is only required for using the
90+
// testIDP as primary auth. External auth does not ever fetch these fields.
91+
"email": "oidc_member@coder.com",
92+
"preferred_username": "oidc_member",
93+
"email_verified": true,
94+
}),
8895
oidctest.WithDefaultIDClaims(jwt.MapClaims{}),
8996
oidctest.WithDefaultExpire(*expiry),
9097
oidctest.WithStaticCredentials(*clientID, *clientSecret),
@@ -133,6 +140,8 @@ func RunIDP() func(t *testing.T) {
133140
data, err := json.Marshal([]withClientSecret{cfg})
134141
require.NoError(t, err)
135142
log.Printf(`--external-auth-providers='%s'`, string(data))
143+
log.Println("As primary OIDC auth")
144+
log.Printf(`--oidc-issuer-url=%s --oidc-client-id=%s --oidc-client-secret=%s`, idp.IssuerURL().String(), *clientID, *clientSecret)
136145

137146
log.Println("Press Ctrl+C to exit")
138147
c := make(chan os.Signal, 1)

tailnet/conn.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ type Options struct {
9393
BlockEndpoints bool
9494
Logger slog.Logger
9595
ListenPort uint16
96+
// CaptureHook is a callback that captures Disco packets and packets sent
97+
// into the tailnet tunnel.
98+
CaptureHook capture.Callback
9699
}
97100

98101
// NodeID creates a Tailscale NodeID from the last 8 bytes of a UUID. It ensures
@@ -158,6 +161,7 @@ func NewConn(options *Options) (conn *Conn, err error) {
158161
wireguardEngine.Close()
159162
}
160163
}()
164+
wireguardEngine.InstallCaptureHook(options.CaptureHook)
161165
dialer.UseNetstackForIP = func(ip netip.Addr) bool {
162166
_, ok := wireguardEngine.PeerForIP(ip)
163167
return ok

0 commit comments

Comments
 (0)