Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit fc7f3c7

Browse files
authored
NOTICE.MD generation improvements (#1281)
In my upcoming SQL lexer/parser code I plan to use snippets of lexing logic taken from other existing projects. Since such usage is not adding a new Go dependency, this wouldn't get reflected in our top-level `NOTICE.MD`. Therefore, I implemented some improvements/cleaned up our generation of `NOTICE.MD` file: - Dependencies are taken from all `go.sum` files, not only `quesma/go.sum` (important if we introduce new Go packages) - Some of the logic is extracted to `collect-go-dependencies.sh` - `collect-manual-notices.sh` appends manually created `NOTICE.MD` entries from subdirectories (I will use that in my lexer PR) - a few smaller improvements, cleanups
1 parent 9a8e8ae commit fc7f3c7

File tree

7 files changed

+33
-64
lines changed

7 files changed

+33
-64
lines changed

.github/go-licence-detector/templates/dependencies.asciidoc.tmpl

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash -e
2+
3+
for gomod in **/go.mod ; do
4+
pushd "$(dirname "$gomod")" 1>&2
5+
echo "Processing $gomod" 1>&2
6+
7+
go mod tidy 1>&2
8+
go mod download all 1>&2
9+
go list -m -json all | jq -c
10+
11+
popd 1>&2
12+
done
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash -e
2+
3+
# Collect manually created notices we might have in the repository
4+
# (for example if we use code from a project, but that project isn't
5+
# a Go dependency of our project)
6+
7+
for notice in **/NOTICE.MD ; do
8+
if [ -f "$notice" ]; then
9+
echo "" # newline between added notices
10+
cat "$notice"
11+
fi
12+
done

.github/workflows/generate-notice.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ on:
55
branches:
66
- main
77
paths:
8-
- 'quesma/go.mod'
9-
- 'quesma/go.sum'
8+
- '**/go.mod'
9+
- '**/go.sum'
10+
- '**/NOTICE.MD'
11+
- '.github/notice-generator/**'
1012
workflow_dispatch:
1113

1214
jobs:
1315
generate-notice-file:
14-
strategy:
15-
matrix:
16-
module: [ "quesma" ]
1716
runs-on: ubuntu-latest
1817
permissions:
1918
contents: write
@@ -25,20 +24,17 @@ jobs:
2524
- name: Set up Go
2625
uses: actions/setup-go@v5
2726
with:
28-
cache-dependency-path: ${{ matrix.module }}/go.sum
27+
cache-dependency-path: '**/go.sum'
2928
go-version: '1.24'
3029

3130
- name: Install go-licence-detector
32-
working-directory: ${{ matrix.module }}
33-
run: go get go.elastic.co/go-licence-detector && go install go.elastic.co/go-licence-detector
31+
run: go install go.elastic.co/[email protected]
3432

3533
- name: Generate NOTICE.MD
36-
working-directory: ${{ matrix.module }}
3734
run: |
38-
go mod tidy
39-
go mod download all
40-
go list -m -json all | jq 'select(.Path != "quesma_v2")' | go-licence-detector -includeIndirect -noticeTemplate=../.github/go-licence-detector/templates/NOTICE.MD.tmpl -noticeOut=../NOTICE.MD -depsTemplate=../.github/go-licence-detector/templates/dependencies.asciidoc.tmpl -depsOut=dependencies.asciidoc -overrides=../.github/go-licence-detector/overrides.ndjson -rules=../.github/go-licence-detector/rules.json
41-
rm dependencies.asciidoc
35+
rm NOTICE.MD
36+
.github/notice-generator/collect-go-dependencies.sh | sort | uniq | go-licence-detector -includeIndirect -noticeTemplate=.github/notice-generator/go-licence-detector/NOTICE.MD.tmpl -noticeOut=NOTICE.MD -overrides=.github/notice-generator/go-licence-detector/overrides.ndjson -rules=.github/notice-generator/go-licence-detector/rules.json
37+
.github/notice-generator/collect-manual-notices.sh >> NOTICE.MD
4238
4339
- name: Print NOTICE.MD
4440
run: cat NOTICE.MD

0 commit comments

Comments
 (0)