Skip to content

Commit 61d6595

Browse files
committed
Merge branch 'main' of github.com:/coder/coder into dk/old-exps
2 parents 66f7ef4 + 0c99356 commit 61d6595

File tree

34 files changed

+1210
-390
lines changed

34 files changed

+1210
-390
lines changed

.github/workflows/ci.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ jobs:
640640
- test-e2e
641641
- offlinedocs
642642
- sqlc-vet
643+
- dependency-license-review
643644
# Allow this job to run even if the needed jobs fail, are skipped or
644645
# cancelled.
645646
if: always()
@@ -656,6 +657,7 @@ jobs:
656657
echo "- test-js: ${{ needs.test-js.result }}"
657658
echo "- test-e2e: ${{ needs.test-e2e.result }}"
658659
echo "- offlinedocs: ${{ needs.offlinedocs.result }}"
660+
echo "- dependency-license-review: ${{ needs.dependency-license-review.result }}"
659661
echo
660662
661663
# We allow skipped jobs to pass, but not failed or cancelled jobs.
@@ -896,3 +898,42 @@ jobs:
896898
- name: Setup and run sqlc vet
897899
run: |
898900
make sqlc-vet
901+
902+
# dependency-license-review checks that no license-incompatible dependencies have been introduced.
903+
# This action is not intended to do a vulnerability check since that is handled by a separate action.
904+
dependency-license-review:
905+
runs-on: ubuntu-latest
906+
if: github.ref != 'refs/heads/main'
907+
steps:
908+
- name: "Checkout Repository"
909+
uses: actions/checkout@v4
910+
- name: "Dependency Review"
911+
id: review
912+
uses: actions/dependency-review-action@v4
913+
with:
914+
allow-licenses: Apache-2.0, BSD-2-Clause, BSD-3-Clause, CC0-1.0, ISC, MIT, MIT-0, MPL-2.0
915+
license-check: true
916+
vulnerability-check: false
917+
- name: "Report"
918+
# make sure this step runs even if the previous failed
919+
if: always()
920+
shell: bash
921+
env:
922+
VULNERABLE_CHANGES: ${{ steps.review.outputs.invalid-license-changes }}
923+
run: |
924+
fields=( "unlicensed" "unresolved" "forbidden" )
925+
926+
# This is unfortunate that we have to do this but the action does not support failing on
927+
# an unknown license. The unknown dependency could easily have a GPL license which
928+
# would be problematic for us.
929+
# Track https://github.com/actions/dependency-review-action/issues/672 for when
930+
# we can remove this brittle workaround.
931+
for field in "${fields[@]}"; do
932+
# Use jq to check if the array is not empty
933+
if [[ $(echo "$VULNERABLE_CHANGES" | jq ".${field} | length") -ne 0 ]]; then
934+
echo "Invalid or unknown licenses detected, contact @sreya to ensure your added dependency falls under one of our allowed licenses."
935+
echo "$VULNERABLE_CHANGES" | jq
936+
exit 1
937+
fi
938+
done
939+
echo "No incompatible licenses detected"

cli/support.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ func (r *RootCmd) supportBundle() *serpent.Command {
184184
_ = os.Remove(outputPath) // best effort
185185
return xerrors.Errorf("create support bundle: %w", err)
186186
}
187+
docsURL := bun.Deployment.Config.Values.DocsURL.String()
188+
deployHealthSummary := bun.Deployment.HealthReport.Summarize(docsURL)
189+
if len(deployHealthSummary) > 0 {
190+
cliui.Warn(inv.Stdout, "Deployment health issues detected:", deployHealthSummary...)
191+
}
192+
clientNetcheckSummary := bun.Network.Netcheck.Summarize("Client netcheck:", docsURL)
193+
if len(clientNetcheckSummary) > 0 {
194+
cliui.Warn(inv.Stdout, "Networking issues detected:", deployHealthSummary...)
195+
}
196+
187197
bun.CLILogs = cliLogBuf.Bytes()
188198

189199
if err := writeBundle(bun, zwr); err != nil {

coderd/apidoc/docs.go

Lines changed: 22 additions & 3 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: 14 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/azureidentity/azureidentity_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"crypto/x509"
66
"encoding/pem"
7+
"runtime"
78
"testing"
89
"time"
910

@@ -14,6 +15,11 @@ import (
1415

1516
func TestValidate(t *testing.T) {
1617
t.Parallel()
18+
if runtime.GOOS == "darwin" {
19+
// This test fails on MacOS for some reason. See https://github.com/coder/coder/issues/12978
20+
t.Skip()
21+
}
22+
1723
mustTime := func(layout string, value string) time.Time {
1824
ti, err := time.Parse(layout, value)
1925
require.NoError(t, err)

coderd/database/db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (q *sqlQuerier) InTx(function func(Store) error, txOpts *sql.TxOptions) err
103103
// Transaction succeeded.
104104
return nil
105105
}
106-
if err != nil && !IsSerializedError(err) {
106+
if !IsSerializedError(err) {
107107
// We should only retry if the error is a serialization error.
108108
return err
109109
}

coderd/database/dbmem/dbmem.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9089,7 +9089,6 @@ func (q *FakeQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg database.
90899089
params = append(params, param)
90909090
}
90919091

9092-
var innerErr error
90939092
index := slices.IndexFunc(params, func(buildParam database.WorkspaceBuildParameter) bool {
90949093
// If hasParam matches, then we are done. This is a good match.
90959094
if slices.ContainsFunc(arg.HasParam, func(name string) bool {
@@ -9116,9 +9115,6 @@ func (q *FakeQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg database.
91169115

91179116
return match
91189117
})
9119-
if innerErr != nil {
9120-
return nil, xerrors.Errorf("error searching workspace build params: %w", innerErr)
9121-
}
91229118
if index < 0 {
91239119
continue
91249120
}

coderd/database/dbmetrics/dbmetrics.go

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

coderd/healthcheck/derphealth/derp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ func (r *RegionReport) Run(ctx context.Context) {
156156
node = node
157157
nodeReport = NodeReport{
158158
DERPNodeReport: healthsdk.DERPNodeReport{
159-
Node: node,
160159
Healthy: true,
160+
Node: node,
161161
},
162162
}
163163
)

coderd/healthcheck/health/model.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"strings"
66

7+
"github.com/coder/coder/v2/buildinfo"
78
"github.com/coder/coder/v2/coderd/util/ptr"
89
)
910

@@ -44,6 +45,11 @@ const (
4445
CodeProvisionerDaemonAPIMajorVersionDeprecated Code = `EPD03`
4546
)
4647

48+
// Default docs URL
49+
var (
50+
docsURLDefault = "https://coder.com/docs/v2"
51+
)
52+
4753
// @typescript-generate Severity
4854
type Severity string
4955

@@ -72,6 +78,30 @@ func (m Message) String() string {
7278
return sb.String()
7379
}
7480

81+
// URL returns a link to the admin/healthcheck docs page for the given Message.
82+
// NOTE: if using a custom docs URL, specify base.
83+
func (m Message) URL(base string) string {
84+
var codeAnchor string
85+
if m.Code == "" {
86+
codeAnchor = strings.ToLower(string(CodeUnknown))
87+
} else {
88+
codeAnchor = strings.ToLower(string(m.Code))
89+
}
90+
91+
if base == "" {
92+
base = docsURLDefault
93+
versionPath := buildinfo.Version()
94+
if buildinfo.IsDev() {
95+
// for development versions, just use latest
96+
versionPath = "latest"
97+
}
98+
return fmt.Sprintf("%s/%s/admin/healthcheck#%s", base, versionPath, codeAnchor)
99+
}
100+
101+
// We don't assume that custom docs URLs are versioned.
102+
return fmt.Sprintf("%s/admin/healthcheck#%s", base, codeAnchor)
103+
}
104+
75105
// Code is a stable identifier used to link to documentation.
76106
// @typescript-generate Code
77107
type Code string
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package health_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/coder/coder/v2/coderd/healthcheck/health"
7+
8+
"github.com/stretchr/testify/assert"
9+
)
10+
11+
func Test_MessageURL(t *testing.T) {
12+
t.Parallel()
13+
14+
for _, tt := range []struct {
15+
name string
16+
code health.Code
17+
base string
18+
expected string
19+
}{
20+
{"empty", "", "", "https://coder.com/docs/v2/latest/admin/healthcheck#eunknown"},
21+
{"default", health.CodeAccessURLFetch, "", "https://coder.com/docs/v2/latest/admin/healthcheck#eacs03"},
22+
{"custom docs base", health.CodeAccessURLFetch, "https://example.com/docs", "https://example.com/docs/admin/healthcheck#eacs03"},
23+
} {
24+
tt := tt
25+
t.Run(tt.name, func(t *testing.T) {
26+
t.Parallel()
27+
uut := health.Message{Code: tt.code}
28+
actual := uut.URL(tt.base)
29+
assert.Equal(t, tt.expected, actual)
30+
})
31+
}
32+
}

0 commit comments

Comments
 (0)