Skip to content

Commit 5efb63a

Browse files
authored
Merge pull request #4 from DataDog/thieman/cargo-deny-licenses
Add cargo-deny license policy check
2 parents 5174929 + 0507787 commit 5efb63a

3 files changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ jobs:
3131
- name: Check third-party license inventory
3232
run: make check-licenses
3333

34+
license-policy:
35+
name: License Policy
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Check out repository
39+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
40+
- name: Install toolchain
41+
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
42+
with:
43+
toolchain: stable
44+
- name: Cache build artifacts
45+
uses: Swatinem/rust-cache@42dc69e1aa15d09112580998cf2ef0119e2e91ae # v2
46+
- name: Check dependency license policy
47+
run: make check-deny
48+
3449
test:
3550
name: Test
3651
runs-on: windows-2022

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
.DEFAULT_GOAL := help
77

88
export CARGO_TOOL_VERSION_dd-rust-license-tool ?= 1.0.6
9+
export CARGO_TOOL_VERSION_cargo-deny ?= 0.18.9
910
export CARGO_BIN_DIR := $(shell echo "$${HOME}/.cargo/bin")
1011
DD_RUST_LICENSE_TOOL := $(CARGO_BIN_DIR)/dd-rust-license-tool
12+
CARGO_DENY := $(CARGO_BIN_DIR)/cargo-deny
1113

1214
.PHONY: help
1315
help:
@@ -17,6 +19,7 @@ help:
1719
@printf " %-20s %s\n" "test" "Run the test suite"
1820
@printf " %-20s %s\n" "sync-licenses" "Regenerate LICENSE-3rdparty.csv"
1921
@printf " %-20s %s\n" "check-licenses" "Verify LICENSE-3rdparty.csv is up to date"
22+
@printf " %-20s %s\n" "check-deny" "Check dependency licenses with cargo-deny"
2023

2124
.PHONY: cargo-install-dd-rust-license-tool
2225
cargo-install-dd-rust-license-tool:
@@ -25,6 +28,13 @@ cargo-install-dd-rust-license-tool:
2528
cargo install "dd-rust-license-tool@$(CARGO_TOOL_VERSION_dd-rust-license-tool)"; \
2629
fi
2730

31+
.PHONY: cargo-install-cargo-deny
32+
cargo-install-cargo-deny:
33+
@if [ ! -x "$(CARGO_DENY)" ] || ! "$(CARGO_DENY)" --version 2>/dev/null | grep -q "$(CARGO_TOOL_VERSION_cargo-deny)"; then \
34+
echo "[*] Installing cargo-deny $(CARGO_TOOL_VERSION_cargo-deny)..."; \
35+
cargo install "cargo-deny@$(CARGO_TOOL_VERSION_cargo-deny)"; \
36+
fi
37+
2838
.PHONY: fmt
2939
fmt:
3040
@echo "[*] Checking Rust source code formatting..."
@@ -49,3 +59,8 @@ sync-licenses: cargo-install-dd-rust-license-tool
4959
check-licenses: cargo-install-dd-rust-license-tool
5060
@echo "[*] Checking if third-party license file is up to date..."
5161
@"$(DD_RUST_LICENSE_TOOL)" check
62+
63+
.PHONY: check-deny
64+
check-deny: cargo-install-cargo-deny
65+
@echo "[*] Checking dependency licenses with cargo-deny..."
66+
@"$(CARGO_DENY)" check licenses

deny.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the MIT License.
2+
#
3+
# This product includes software developed at Datadog (https://www.datadoghq.com/)
4+
# Copyright 2026 Datadog, Inc.
5+
6+
[licenses]
7+
version = 2
8+
allow = [
9+
"Apache-2.0",
10+
"Apache-2.0 WITH LLVM-exception",
11+
"BSD-3-Clause",
12+
"ISC",
13+
"MIT",
14+
"MIT-0",
15+
"Unicode-3.0",
16+
]
17+
18+
[bans]
19+
multiple-versions = "allow"
20+
21+
[sources]
22+
unknown-registry = "deny"
23+
unknown-git = "deny"

0 commit comments

Comments
 (0)