Skip to content

Commit 5c97bd8

Browse files
Move the license-header tool out of the Go Server module (#1018)
1 parent 740fd31 commit 5c97bd8

11 files changed

Lines changed: 66 additions & 7 deletions

File tree

‎.dockerignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ sdk-go/coverage/
4141
server/coverage/
4242
server/coverage-raw/
4343
server/all-in-one/bin/
44+
script/licenseheaders/copyright/copyright

‎.github/workflows/copyright-ci.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ jobs:
6666
fetch-depth: 0
6767
- uses: actions/setup-go@v7
6868
with:
69-
go-version-file: server/go.mod
69+
go-version-file: script/licenseheaders/copyright/go.mod
7070
cache: false
71+
- name: Test license header tool
72+
run: make copyright-test
7173
- name: Verify license headers
7274
run: make copyright-check

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,4 @@ sdk-typescript/coverage/
6868
*.log
6969
test.log
7070
server/all-in-one/bin/
71+
script/licenseheaders/copyright/copyright

‎CONTRIBUTING.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,12 @@ make copyright-check # verify classifications, body hashes, and headers
149149

150150
Skip generated trees (`**/gen/**`, `*.pb.go`, `*_pb.go`, `*.gen.*`). Prefer
151151
`make copyright` over hand-copying when adding files. It upgrades a modified
152-
`legacy-only` file to `mixed` without replacing its legacy notice. CI runs
153-
`make copyright-check` via [`.github/workflows/copyright-ci.yml`](.github/workflows/copyright-ci.yml).
152+
`legacy-only` file to `mixed` without replacing its legacy notice.
153+
154+
The standalone Go tool lives in
155+
[`script/licenseheaders/copyright/`](script/licenseheaders/copyright/).
156+
Run `make copyright-test` to test its classification and rendering behavior.
157+
CI runs `make copyright-check` via [`.github/workflows/copyright-ci.yml`](.github/workflows/copyright-ci.yml).
154158

155159
Files absent from the cutoff manifest use the new header. File-level renames
156160
and copies with at least 20% similarity retain source lineage; non-new copies

‎Makefile‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ GENERATED_CODE_PATHS := \
88
sdk-python/dex/dexpb \
99
sdk-typescript/src/gen
1010

11-
.PHONY: help ci-runner-check copyright copyright-check generated-code generated-code-check githooks docs-prose-check docs-prose-fix release-tooling-test
11+
.PHONY: help ci-runner-check copyright copyright-check copyright-test generated-code generated-code-check githooks docs-prose-check docs-prose-fix release-tooling-test
1212

1313
release-tooling-test: ## Verify changed-component selection and release preflight
1414
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s script/release -p '*_test.py'
@@ -33,10 +33,13 @@ ci-runner-check: ## Verify CI workflows use GitHub-hosted runners
3333
bash .github/scripts/check-ci-runners.sh
3434

3535
copyright: ## Add or upgrade license headers using the legacy manifest
36-
cd server && GOWORK=off go run ./cmd/tools/copyright -rootDir "$(ROOT_DIR)"
36+
cd script/licenseheaders/copyright && GOWORK=off go run . -rootDir "$(ROOT_DIR)"
3737

3838
copyright-check: ## Verify license classifications, body hashes, and headers
39-
cd server && GOWORK=off go run ./cmd/tools/copyright -rootDir "$(ROOT_DIR)" -verifyOnly
39+
cd script/licenseheaders/copyright && GOWORK=off go run . -rootDir "$(ROOT_DIR)" -verifyOnly
40+
41+
copyright-test: ## Test license header classification and rendering
42+
cd script/licenseheaders/copyright && GOWORK=off go test ./...
4043

4144
generated-code: ## Regenerate all checked-in code derived from protos
4245
$(MAKE) -C protos proto
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# License header tool
2+
3+
Adds and verifies repository license headers using the policy, templates, and
4+
legacy manifest in the parent directory. This standalone Go module does not
5+
depend on the Dex Server.
6+
7+
From the repository root:
8+
9+
```bash
10+
make copyright
11+
make copyright-check
12+
make copyright-test
13+
```
14+
15+
To process selected files, pass repository-relative paths from this directory:
16+
17+
```bash
18+
GOWORK=off go run . -rootDir ../../.. -filePaths path/to/file.go
19+
GOWORK=off go run . -rootDir ../../.. -verifyOnly
20+
```
21+
22+
The implementation and license classifications are preserved from the original
23+
Server tool. Git history supplies rename and copy lineage from the legacy cutoff,
24+
so CI must fetch the full repository history. The tool's own `main.go` keeps its
25+
`mixed` classification through `reviewed_mixed_paths` in `../policy.json`,
26+
because the repository-wide diff exceeds Git's default rename limit.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module github.com/superdurable/dex/script/licenseheaders/copyright
2+
3+
go 1.26.0
4+
5+
require github.com/stretchr/testify v1.11.1
6+
7+
require (
8+
github.com/davecgh/go-spew v1.1.1 // indirect
9+
github.com/pmezard/go-difflib v1.0.0 // indirect
10+
gopkg.in/yaml.v3 v3.0.1 // indirect
11+
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
6+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
7+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
8+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
9+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
10+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

server/cmd/tools/copyright/main_test.go renamed to script/licenseheaders/copyright/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestHeaderTaskUpgradesLegacyAndCreatesNewHeader(t *testing.T) {
108108
func copyTestTemplates(t *testing.T, repositoryRoot string) {
109109
_, currentFile, _, ok := runtime.Caller(0)
110110
require.True(t, ok)
111-
sourceDir := filepath.Join(filepath.Dir(currentFile), "..", "..", "..", "..", "script", "licenseheaders")
111+
sourceDir := filepath.Join(filepath.Dir(currentFile), "..")
112112
destinationDir := filepath.Join(repositoryRoot, "script", "licenseheaders")
113113
require.NoError(t, os.MkdirAll(destinationDir, 0o755))
114114
for _, fileName := range []string{

0 commit comments

Comments
 (0)