Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(Makefile): update golden files as part of make gen#17039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mafredri merged 1 commit intomainfrommafredri/build-update-golden-as-part-of-gen
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions.github/workflows/ci.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -267,18 +267,15 @@ jobs:
popd

- name: make gen
# no `-j` flag as `make` fails with:
# coderd/rbac/object_gen.go:1:1: syntax error: package statement must be first
run: "make --output-sync -B gen"

- name: make update-golden-files
run: |
# Remove golden files to detect discrepancy in generated files.
make clean/golden-files
# Notifications require DB, we could start a DB instance here but
# let's just restore for now.
git checkout -- coderd/notifications/testdata/rendered-templates
# As above, skip `-j` flag.
make --output-sync -B update-golden-files
# no `-j` flag as `make` fails with:
# coderd/rbac/object_gen.go:1:1: syntax error: package statement must be first
make --output-sync -B gen

- name: Check for unstaged files
run: ./scripts/check_unstaged.sh
Expand Down
28 changes: 17 additions & 11 deletionsMakefile
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -568,12 +568,24 @@ GEN_FILES := \
agent/agentcontainers/dcspec/dcspec_gen.go

# all gen targets should be added here and to gen/mark-fresh
gen: gen/db $(GEN_FILES)
gen: gen/dbgen/golden-files$(GEN_FILES)
.PHONY: gen

gen/db: $(DB_GEN_FILES)
.PHONY: gen/db

gen/golden-files: \
cli/testdata/.gen-golden \
coderd/.gen-golden \
coderd/notifications/.gen-golden \
enterprise/cli/testdata/.gen-golden \
enterprise/tailnet/testdata/.gen-golden \
helm/coder/tests/testdata/.gen-golden \
helm/provisioner/tests/testdata/.gen-golden \
provisioner/terraform/testdata/.gen-golden \
tailnet/testdata/.gen-golden
.PHONY: gen/golden-files

# Mark all generated files as fresh so make thinks they're up-to-date. This is
# used during releases so we don't run generation scripts.
gen/mark-fresh:
Expand DownExpand Up@@ -743,16 +755,10 @@ coderd/apidoc/swagger.json: node_modules/.installed site/node_modules/.installed
cd site/
pnpm exec biome format --write ../docs/manifest.json ../coderd/apidoc/swagger.json

update-golden-files: \
cli/testdata/.gen-golden \
coderd/.gen-golden \
coderd/notifications/.gen-golden \
enterprise/cli/testdata/.gen-golden \
enterprise/tailnet/testdata/.gen-golden \
helm/coder/tests/testdata/.gen-golden \
helm/provisioner/tests/testdata/.gen-golden \
provisioner/terraform/testdata/.gen-golden \
tailnet/testdata/.gen-golden
update-golden-files:
echo 'WARNING: This target is deprecated. Use "make gen/golden-files" instead.' 2>&1
echo 'Running "make gen/golden-files"' 2>&1
make gen/golden-files
.PHONY: update-golden-files

clean/golden-files:
Expand Down
6 changes: 3 additions & 3 deletionscli/clitest/golden.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ import (

// UpdateGoldenFiles indicates golden files should be updated.
// To update the golden files:
// makeupdate-golden-files
// makegen/golden-files
var UpdateGoldenFiles = flag.Bool("update", false, "update .golden files")

var timestampRegex = regexp.MustCompile(`(?i)\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(.\d+)?(Z|[+-]\d+:\d+)`)
Expand DownExpand Up@@ -113,12 +113,12 @@ func TestGoldenFile(t *testing.T, fileName string, actual []byte, replacements m
}

expected, err := os.ReadFile(goldenPath)
require.NoError(t, err, "read golden file, run \"makeupdate-golden-files\" and commit the changes")
require.NoError(t, err, "read golden file, run \"makegen/golden-files\" and commit the changes")

expected = normalizeGoldenFile(t, expected)
require.Equal(
t, string(expected), string(actual),
"golden file mismatch: %s, run \"makeupdate-golden-files\", verify and commit the changes",
"golden file mismatch: %s, run \"makegen/golden-files\", verify and commit the changes",
goldenPath,
)
}
Expand Down
8 changes: 4 additions & 4 deletionscoderd/insights_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1295,7 +1295,7 @@ func TestTemplateInsights_Golden(t *testing.T) {
}

f, err := os.Open(goldenFile)
require.NoError(t, err, "open golden file, run \"makeupdate-golden-files\" and commit the changes")
require.NoError(t, err, "open golden file, run \"makegen/golden-files\" and commit the changes")
defer f.Close()
var want codersdk.TemplateInsightsResponse
err = json.NewDecoder(f).Decode(&want)
Expand All@@ -1311,7 +1311,7 @@ func TestTemplateInsights_Golden(t *testing.T) {
}),
}
// Use cmp.Diff here because it produces more readable diffs.
assert.Empty(t, cmp.Diff(want, report, cmpOpts...), "golden file mismatch (-want +got): %s, run \"makeupdate-golden-files\", verify and commit the changes", goldenFile)
assert.Empty(t, cmp.Diff(want, report, cmpOpts...), "golden file mismatch (-want +got): %s, run \"makegen/golden-files\", verify and commit the changes", goldenFile)
})
}
})
Expand DownExpand Up@@ -2076,7 +2076,7 @@ func TestUserActivityInsights_Golden(t *testing.T) {
}

f, err := os.Open(goldenFile)
require.NoError(t, err, "open golden file, run \"makeupdate-golden-files\" and commit the changes")
require.NoError(t, err, "open golden file, run \"makegen/golden-files\" and commit the changes")
defer f.Close()
var want codersdk.UserActivityInsightsResponse
err = json.NewDecoder(f).Decode(&want)
Expand All@@ -2092,7 +2092,7 @@ func TestUserActivityInsights_Golden(t *testing.T) {
}),
}
// Use cmp.Diff here because it produces more readable diffs.
assert.Empty(t, cmp.Diff(want, report, cmpOpts...), "golden file mismatch (-want +got): %s, run \"makeupdate-golden-files\", verify and commit the changes", goldenFile)
assert.Empty(t, cmp.Diff(want, report, cmpOpts...), "golden file mismatch (-want +got): %s, run \"makegen/golden-files\", verify and commit the changes", goldenFile)
})
}
})
Expand Down
2 changes: 1 addition & 1 deletioncoderd/notifications/notifications_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -768,7 +768,7 @@ func TestNotificationTemplates_Golden(t *testing.T) {
hello = "localhost"

from = "system@coder.com"
hint = "run \"DB=ci makeupdate-golden-files\" and commit the changes"
hint = "run \"DB=ci makegen/golden-files\" and commit the changes"
)

tests := []struct {
Expand Down
6 changes: 3 additions & 3 deletionsenterprise/tailnet/pgcoord_internal_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,7 +32,7 @@ import (

// UpdateGoldenFiles indicates golden files should be updated.
// To update the golden files:
// makeupdate-golden-files
// makegen/golden-files
var UpdateGoldenFiles = flag.Bool("update", false, "update .golden files")

// TestHeartbeats_Cleanup tests the cleanup loop
Expand DownExpand Up@@ -316,11 +316,11 @@ func TestDebugTemplate(t *testing.T) {
}

expected, err := os.ReadFile(goldenPath)
require.NoError(t, err, "read golden file, run \"makeupdate-golden-files\" and commit the changes")
require.NoError(t, err, "read golden file, run \"makegen/golden-files\" and commit the changes")

require.Equal(
t, string(expected), string(actual),
"golden file mismatch: %s, run \"makeupdate-golden-files\", verify and commit the changes",
"golden file mismatch: %s, run \"makegen/golden-files\", verify and commit the changes",
goldenPath,
)
}
Expand Down
4 changes: 2 additions & 2 deletionsprovisioner/terraform/cleanup_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -174,8 +174,8 @@ func diffFileSystem(t *testing.T, fs afero.Fs) {
}

want, err := os.ReadFile(goldenFile)
require.NoError(t, err, "open golden file, run \"makeupdate-golden-files\" and commit the changes")
assert.Empty(t, cmp.Diff(want, actual), "golden file mismatch (-want +got): %s, run \"makeupdate-golden-files\", verify and commit the changes", goldenFile)
require.NoError(t, err, "open golden file, run \"makegen/golden-files\" and commit the changes")
assert.Empty(t, cmp.Diff(want, actual), "golden file mismatch (-want +got): %s, run \"makegen/golden-files\", verify and commit the changes", goldenFile)
}

func dumpFileSystem(t *testing.T, fs afero.Fs) []byte {
Expand Down
6 changes: 3 additions & 3 deletionstailnet/coordinator_internal_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@ import (

// UpdateGoldenFiles indicates golden files should be updated.
// To update the golden files:
// makeupdate-golden-files
// makegen/golden-files
var UpdateGoldenFiles = flag.Bool("update", false, "update .golden files")

func TestDebugTemplate(t *testing.T) {
Expand DownExpand Up@@ -64,11 +64,11 @@ func TestDebugTemplate(t *testing.T) {
}

expected, err := os.ReadFile(goldenPath)
require.NoError(t, err, "read golden file, run \"makeupdate-golden-files\" and commit the changes")
require.NoError(t, err, "read golden file, run \"makegen/golden-files\" and commit the changes")

require.Equal(
t, string(expected), string(actual),
"golden file mismatch: %s, run \"makeupdate-golden-files\", verify and commit the changes",
"golden file mismatch: %s, run \"makegen/golden-files\", verify and commit the changes",
goldenPath,
)
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp