Skip to content

Commit dc9b1e2

Browse files
authored
ops: add files required to generate THIRD_PARTY_NOTICES (#964)
* ops: add `THIRD_PARTY_NOTICES` * ops: delete the hardcoded notices, will generate on release time * ops: reorder `about.toml` * ops: generate `THIRD_PARTY_NOTICES.html` in the `release` workflow * ops: add a Rust cache for `generate-3p-notices` * ops: validate `about.toml` covers all 3p licenses in testing * fix: unquote `/about.toml` in bash command
1 parent da0d649 commit dc9b1e2

File tree

6 files changed

+132
-2
lines changed

6 files changed

+132
-2
lines changed

.github/workflows/_test.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,25 @@ jobs:
6262
if: ${{ startsWith(matrix.platform.runner, 'windows') }}
6363
shell: cmd # Use `cmd` to run test for Windows, as PowerShell doesn't detect exit code by `os._exit(0)` correctly.
6464
run: |
65-
${{ matrix.platform.python_exec }} -m pytest --capture=no python/cocoindex/tests
65+
${{ matrix.platform.python_exec }} -m pytest --capture=no python/cocoindex/tests
66+
67+
validate-3p-notices:
68+
runs-on: ubuntu-latest
69+
steps:
70+
- uses: actions/checkout@v4
71+
- name: Rust Cache
72+
uses: Swatinem/rust-cache@v2
73+
- name: Install Rust toolchain
74+
uses: dtolnay/rust-toolchain@stable
75+
- name: Install cargo-about
76+
run: cargo install --locked cargo-about
77+
- name: Validate third-party notices (dry-run)
78+
shell: bash
79+
run: |
80+
set +e
81+
cargo about generate about.hbs > /dev/null
82+
status=$?
83+
if [ $status -ne 0 ]; then
84+
echo "::error::Third-party notices validation failed. Please update /about.toml and rerun."
85+
exit $status
86+
fi

.github/workflows/release.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,32 @@ jobs:
9494
name: wheels-sdist
9595
path: dist
9696

97+
generate-3p-notices:
98+
runs-on: ubuntu-latest
99+
needs: [create-versioned-toml]
100+
steps:
101+
- uses: actions/checkout@v4
102+
- uses: actions/download-artifact@v4
103+
with:
104+
name: Cargo.toml
105+
- name: Rust Cache
106+
uses: Swatinem/rust-cache@v2
107+
- name: Install Rust toolchain
108+
uses: dtolnay/rust-toolchain@stable
109+
- name: Install cargo-about
110+
run: cargo install --locked cargo-about
111+
- name: Generate THIRD_PARTY_NOTICES.html
112+
run: cargo about generate -o THIRD_PARTY_NOTICES.html about.hbs
113+
- name: Upload THIRD_PARTY_NOTICES.html artifact
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: THIRD_PARTY_NOTICES.html
117+
path: THIRD_PARTY_NOTICES.html
118+
97119
release:
98120
name: Release
99121
runs-on: ubuntu-latest
100-
needs: [create-versioned-toml, build, test-abi3, sdist]
122+
needs: [create-versioned-toml, build, test-abi3, sdist, generate-3p-notices]
101123
permissions:
102124
# Use to sign the release artifacts
103125
id-token: write
@@ -111,6 +133,9 @@ jobs:
111133
- uses: actions/download-artifact@v4
112134
with:
113135
name: Cargo.toml
136+
- uses: actions/download-artifact@v4
137+
with:
138+
name: THIRD_PARTY_NOTICES.html
114139
- uses: actions/download-artifact@v4
115140
with:
116141
pattern: wheels-*

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ name = "cocoindex"
55
version = "999.0.0"
66
edition = "2024"
77
rust-version = "1.88"
8+
license = "Apache-2.0"
89

910
[profile.release]
1011
codegen-units = 1

about.hbs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<html>
2+
3+
<head>
4+
<style>
5+
@media (prefers-color-scheme: dark) {
6+
body {
7+
background: #333;
8+
color: white;
9+
}
10+
a {
11+
color: skyblue;
12+
}
13+
}
14+
.container {
15+
font-family: sans-serif;
16+
max-width: 800px;
17+
margin: 0 auto;
18+
}
19+
.intro {
20+
text-align: center;
21+
}
22+
.licenses-list {
23+
list-style-type: none;
24+
margin: 0;
25+
padding: 0;
26+
}
27+
.license-used-by {
28+
margin-top: -10px;
29+
}
30+
.license-text {
31+
max-height: 200px;
32+
overflow-y: scroll;
33+
white-space: pre-wrap;
34+
}
35+
</style>
36+
</head>
37+
38+
<body>
39+
<main class="container">
40+
<div class="intro">
41+
<h1>Third Party Licenses</h1>
42+
<p>This page lists the licenses of the projects used in cargo-about.</p>
43+
</div>
44+
45+
<h2>Overview of licenses:</h2>
46+
<ul class="licenses-overview">
47+
{{#each overview}}
48+
<li><a href="#{{id}}">{{name}}</a> ({{count}})</li>
49+
{{/each}}
50+
</ul>
51+
52+
<h2>All license text:</h2>
53+
<ul class="licenses-list">
54+
{{#each licenses}}
55+
<li class="license">
56+
<h3 id="{{id}}">{{name}}</h3>
57+
<h4>Used by:</h4>
58+
<ul class="license-used-by">
59+
{{#each used_by}}
60+
<li><a href="{{#if crate.repository}} {{crate.repository}} {{else}} https://crates.io/crates/{{crate.name}} {{/if}}">{{crate.name}} {{crate.version}}</a></li>
61+
{{/each}}
62+
</ul>
63+
<pre class="license-text">{{text}}</pre>
64+
</li>
65+
{{/each}}
66+
</ul>
67+
</main>
68+
</body>
69+
70+
</html>

about.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
accepted = [
2+
"Apache-2.0",
3+
"Apache-2.0 WITH LLVM-exception",
4+
"BSD-2-Clause",
5+
"BSD-3-Clause",
6+
"CDLA-Permissive-2.0",
7+
"ISC",
8+
"MIT",
9+
"OpenSSL",
10+
"Unicode-3.0",
11+
"Zlib",
12+
]

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies = [
1717
"numpy>=1.23.2",
1818
]
1919
license = "Apache-2.0"
20+
license-files = ["THIRD_PARTY_NOTICES.html"]
2021
urls = { Homepage = "https://cocoindex.io/" }
2122
classifiers = [
2223
"Development Status :: 3 - Alpha",

0 commit comments

Comments
 (0)