Skip to content

Commit db15c67

Browse files
committed
Merge branch 'main' into 8782-build-option
2 parents 17bc078 + 31b7de6 commit db15c67

Some content is hidden

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

41 files changed

+398
-158
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: |
44
inputs:
55
version:
66
description: "The Go version to use."
7-
default: "1.20.6"
7+
default: "1.20.7"
88
runs:
99
using: "composite"
1010
steps:

.github/workflows/ci.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
138138
# Check for any typos
139139
- name: Check for typos
140-
uses: crate-ci/typos@v1.16.1
140+
uses: crate-ci/typos@v1.16.2
141141
with:
142142
config: .github/workflows/typos.toml
143143

@@ -224,7 +224,7 @@ jobs:
224224
with:
225225
# This doesn't need caching. It's super fast anyways!
226226
cache: false
227-
go-version: 1.20.6
227+
go-version: 1.20.7
228228

229229
- name: Install shfmt
230230
run: go install mvdan.cc/sh/v3/cmd/shfmt@v3.5.0
@@ -701,7 +701,6 @@ jobs:
701701
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
702702
env:
703703
DOCKER_CLI_EXPERIMENTAL: "enabled"
704-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
705704
steps:
706705
- name: Checkout
707706
uses: actions/checkout@v3
@@ -741,12 +740,10 @@ jobs:
741740
--push \
742741
build/coder_linux_amd64
743742
744-
# Get commit sha to be used as package tag
745-
new_package_tag=$(gh api repos/coder/coder/commits/main | jq -r '.sha[0:7]')
746-
747743
# Tag image with new package tag and push
748-
docker tag ghcr.io/coder/coder-preview:main ghcr.io/coder/coder-preview:main-$new_package_tag
749-
docker push ghcr.io/coder/coder-preview:main-$new_package_tag
744+
tag=$(echo "$version" | sed 's/+/-/g')
745+
docker tag ghcr.io/coder/coder-preview:main ghcr.io/coder/coder-preview:main-$tag
746+
docker push ghcr.io/coder/coder-preview:main-$tag
750747
751748
- name: Prune old images
752749
uses: vlaurin/action-ghcr-prune@v0.5.0

.github/workflows/release.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ env:
2828
# https://github.blog/changelog/2022-06-10-github-actions-inputs-unified-across-manual-and-reusable-workflows/
2929
CODER_RELEASE: ${{ !inputs.dry_run }}
3030
CODER_DRY_RUN: ${{ inputs.dry_run }}
31-
# For some reason, setup-go won't actually pick up a new patch version if
32-
# it has an old one cached. We need to manually specify the versions so we
33-
# can get the latest release. Never use "~1.xx" here!
34-
CODER_GO_VERSION: "1.20.6"
3531

3632
jobs:
3733
release:

.github/workflows/security.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ concurrency:
2121
group: ${{ github.workflow }}-${{ github.ref }}-security
2222
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
2323

24-
env:
25-
CODER_GO_VERSION: "1.20.6"
26-
2724
jobs:
2825
codeql:
2926
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}

cli/root_internal_test.go

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

33
import (
4+
"os"
5+
"runtime"
46
"testing"
57

68
"github.com/stretchr/testify/require"
@@ -67,6 +69,11 @@ func Test_formatExamples(t *testing.T) {
6769
}
6870

6971
func TestMain(m *testing.M) {
72+
if runtime.GOOS == "windows" {
73+
// Don't run goleak on windows tests, they're super flaky right now.
74+
// See: https://github.com/coder/coder/issues/8954
75+
os.Exit(m.Run())
76+
}
7077
goleak.VerifyTestMain(m,
7178
// The lumberjack library is used by by agent and seems to leave
7279
// goroutines after Close(), fails TestGitSSH tests.

cli/stat.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,16 @@ func (*RootCmd) statDisk(s *clistat.Statter) *clibase.Cmd {
233233
},
234234
Handler: func(inv *clibase.Invocation) error {
235235
pfx := clistat.ParsePrefix(prefixArg)
236+
// Users may also call `coder stat disk <path>`.
237+
if len(inv.Args) > 0 {
238+
pathArg = inv.Args[0]
239+
}
236240
ds, err := s.Disk(pfx, pathArg)
237241
if err != nil {
242+
if os.IsNotExist(err) {
243+
// fmt.Errorf produces a more concise error.
244+
return fmt.Errorf("not found: %q", pathArg)
245+
}
238246
return err
239247
}
240248

cli/stat_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,16 @@ func TestStatDiskCmd(t *testing.T) {
170170
require.NotZero(t, *tmp.Total)
171171
require.Equal(t, "B", tmp.Unit)
172172
})
173+
174+
t.Run("PosArg", func(t *testing.T) {
175+
t.Parallel()
176+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
177+
t.Cleanup(cancel)
178+
inv, _ := clitest.New(t, "stat", "disk", "/this/path/does/not/exist", "--output=text")
179+
buf := new(bytes.Buffer)
180+
inv.Stdout = buf
181+
err := inv.WithContext(ctx).Run()
182+
require.Error(t, err)
183+
require.Contains(t, err.Error(), `not found: "/this/path/does/not/exist"`)
184+
})
173185
}

coderd/apidoc/docs.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/batchstats/batcher.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313

1414
"cdr.dev/slog"
1515
"cdr.dev/slog/sloggers/sloghuman"
16-
1716
"github.com/coder/coder/coderd/database"
1817
"github.com/coder/coder/coderd/database/dbauthz"
1918
"github.com/coder/coder/codersdk/agentsdk"
@@ -126,6 +125,7 @@ func New(ctx context.Context, opts ...Option) (*Batcher, func(), error) {
126125

127126
// Add adds a stat to the batcher for the given workspace and agent.
128127
func (b *Batcher) Add(
128+
now time.Time,
129129
agentID uuid.UUID,
130130
templateID uuid.UUID,
131131
userID uuid.UUID,
@@ -135,7 +135,7 @@ func (b *Batcher) Add(
135135
b.mu.Lock()
136136
defer b.mu.Unlock()
137137

138-
now := database.Now()
138+
now = database.Time(now)
139139

140140
b.buf.ID = append(b.buf.ID, uuid.New())
141141
b.buf.CreatedAt = append(b.buf.CreatedAt, now)
@@ -199,15 +199,6 @@ func (b *Batcher) flush(ctx context.Context, forced bool, reason string) {
199199
defer func() {
200200
b.flushForced.Store(false)
201201
b.mu.Unlock()
202-
// Notify that a flush has completed. This only happens in tests.
203-
if b.flushed != nil {
204-
select {
205-
case <-ctx.Done():
206-
close(b.flushed)
207-
default:
208-
b.flushed <- count
209-
}
210-
}
211202
if count > 0 {
212203
elapsed := time.Since(start)
213204
b.log.Debug(ctx, "flush complete",
@@ -217,6 +208,15 @@ func (b *Batcher) flush(ctx context.Context, forced bool, reason string) {
217208
slog.F("reason", reason),
218209
)
219210
}
211+
// Notify that a flush has completed. This only happens in tests.
212+
if b.flushed != nil {
213+
select {
214+
case <-ctx.Done():
215+
close(b.flushed)
216+
default:
217+
b.flushed <- count
218+
}
219+
}
220220
}()
221221

222222
if len(b.buf.ID) == 0 {

0 commit comments

Comments
 (0)