Skip to content

Commit 7b619d4

Browse files
authored
chore: Use rust-license-tool for license file (#741)
# Motivation The license check often fails, which requires extra engineering time to fix. # This PR Switch to using Datadog's `rust-license-tool` to manage the license file. https://github.com/DataDog/rust-license-tool This replaces `bottlecap/LICENSE-3rdparty.yml` with `bottlecap/LICENSE-3rdparty.csv`. # Testing ## Success case Run this workflow on `yiming.luo/csv-license` branch, which was successful https://github.com/DataDog/datadog-lambda-extension/actions/runs/16274305134 ## Failure case Delete a line in the license file then run the workflow, which failed as expected https://github.com/DataDog/datadog-lambda-extension/actions/runs/16274444263
1 parent 4ecce69 commit 7b619d4

3 files changed

Lines changed: 268 additions & 33353 deletions

File tree

.github/workflows/rs_ci.yml

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -157,62 +157,13 @@ jobs:
157157
- working-directory: bottlecap
158158
run: cargo fmt --all -- --check
159159

160-
# todo: fix upstream warnings; from the readme:
161-
# The most common cause of missing licenses seems to be workspaces that
162-
# don't include forward their license files. Go to the repo for the
163-
# workspace and copy the relevant files from there.
164-
# A package license may receive a confidence warning stating that
165-
# cargo-bundle-licenses is "unsure" or "semi" confident. This means that
166-
# when the found license was compared to a template license it was found to
167-
# have diverged in more than a few words. You should verify that the licence
168-
# text is in fact correct in these cases.
169-
#
170-
# If this job fails, you probably need to regenerate the license, e.g.
171-
# CARGO_HOME=/tmp/dd-cargo cargo bundle-licenses --format yaml --output LICENSE-3rdparty.yml
160+
# If this fails, run `dd-rust-license-tool write` in bottlecap/
172161
license-3rdparty:
173162
runs-on: ubuntu-22.04
174-
name: "Valid LICENSE-3rdparty.yml"
163+
name: "Valid LICENSE-3rdparty.csv"
175164
steps:
176165
- name: Checkout sources
177166
uses: actions/checkout@v4
178-
- run: stat LICENSE-3rdparty.yml
167+
- run: cargo install dd-rust-license-tool --locked
168+
- run: dd-rust-license-tool check
179169
working-directory: bottlecap
180-
- name: Cache
181-
uses: actions/cache@v4
182-
with:
183-
path: |
184-
~/.cargo/registry/
185-
~/.cargo/git/db/
186-
~/.cargo/bin/
187-
~/.cargo/.crates.toml
188-
# cache key contains current version of cargo-bundle-licenses
189-
# when upstream version is updated we can bump the cache key version,
190-
# to cache the latest version of the tool
191-
key: "v1-2.2.0"
192-
# cargo-bundle-licenses v2.0 doesn't understand path differences due to
193-
# sparse vs git index, so force git.
194-
- run: sudo apt-get update && sudo apt-get upgrade
195-
- run: mkdir -p .cargo && printf "[registries.crates-io]\nprotocol = \"git\"\n" > .cargo/config.toml
196-
working-directory: bottlecap
197-
- run: cargo install cargo-bundle-licenses
198-
- name: "Generate new LICENSE-3rdparty.yml and check against the previous"
199-
working-directory: bottlecap
200-
env:
201-
CARGO_HOME: "/tmp/dd-cargo"
202-
run: |
203-
# Run cargo bundle-licenses without directly checking against a previous snapshot
204-
cargo bundle-licenses \
205-
--format yaml \
206-
--output /tmp/CI.yaml
207-
208-
# Normalize the paths in both files to ignore registry differences
209-
sed -E 's/(registry\/src\/)[^\/]+/\1normalized_path/g' /tmp/CI.yaml > /tmp/CI_normalized.yaml
210-
sed -E 's/(registry\/src\/)[^\/]+/\1normalized_path/g' LICENSE-3rdparty.yml > /tmp/LICENSE-3rdparty_normalized.yml
211-
212-
# Now perform the diff on the normalized files
213-
if ! diff /tmp/CI_normalized.yaml /tmp/LICENSE-3rdparty_normalized.yml; then
214-
echo "Differences detected."
215-
exit 1
216-
fi
217-
218-
echo "No differences found."

0 commit comments

Comments
 (0)