Skip to content

Commit 76f94a1

Browse files
authored
Add license detection (#84)
* Checkpoint * Add scanning * Add inline cache load test * Cleanup * Enable LFS checkout * Sigh lfs * wtf github * Idiot * Use single job for CI pass * Fixup docs * More docs * Update CHANGELOG * Format * Fix clippy lint
1 parent 57ba17a commit 76f94a1

22 files changed

Lines changed: 2646 additions & 42 deletions

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
src/text/** linguist-vendored
2+
src/detection/cache.bin.zstd filter=lfs diff=lfs merge=lfs -text

.github/workflows/ci.yaml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ name: CI
1212
jobs:
1313
lint:
1414
name: Lint
15-
runs-on: ubuntu-22.04
15+
runs-on: ubuntu-24.04
1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v6
1818
- uses: dtolnay/rust-toolchain@stable
1919
with:
2020
components: "rustfmt,clippy"
@@ -30,16 +30,16 @@ jobs:
3030

3131
deny-check:
3232
name: cargo-deny check
33-
runs-on: ubuntu-22.04
33+
runs-on: ubuntu-24.04
3434
steps:
35-
- uses: actions/checkout@v4
35+
- uses: actions/checkout@v6
3636
- uses: EmbarkStudios/cargo-deny-action@v2
3737

3838
msrv-check:
3939
name: Minimum Stable Rust Version Check
40-
runs-on: ubuntu-22.04
40+
runs-on: ubuntu-24.04
4141
steps:
42-
- uses: actions/checkout@v4
42+
- uses: actions/checkout@v6
4343
- uses: dtolnay/rust-toolchain@1.85.0
4444
- run: cargo fetch
4545
- name: cargo check
@@ -49,12 +49,21 @@ jobs:
4949
name: Test
5050
strategy:
5151
matrix:
52-
os: [ubuntu-22.04]
52+
os: [ubuntu-24.04]
5353
runs-on: ${{ matrix.os }}
5454
steps:
55-
- uses: actions/checkout@v4
55+
- uses: actions/checkout@v6
56+
with:
57+
lfs: true
58+
- run: git lfs checkout
5659
- uses: dtolnay/rust-toolchain@stable
5760
- run: cargo fetch
5861
- name: cargo build
5962
run: cargo build --tests --all-features
6063
- run: cargo test --all-features
64+
65+
test_success:
66+
runs-on: ubuntu-24.04
67+
needs: [lint, test, deny-check, msrv-check]
68+
steps:
69+
- run: echo "All test jobs passed"

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
<!-- next-header -->
1010
## [Unreleased] - ReleaseDate
11+
### Added
12+
- [PR#84](https://github.com/EmbarkStudios/spdx/pull/84) resolved [#67](https://github.com/EmbarkStudios/spdx/issues/67) by inling the `askalono` crate to allow detection of license texts or headers from arbitrary text data. There are multiple features flags associated with this new feature.
13+
1114
## [0.12.0] - 2025-08-19
1215
### Added
1316
- [PR#81](https://github.com/EmbarkStudios/spdx/pull/81) resolved [#68](https://github.com/EmbarkStudios/spdx/issues/68) by adding support for the ` WITH [%s"DocumentRef-"(idstring)":"]%s"AdditionRef-"(idstring)` syntax. Thanks [@weihanglo](https://github.com/weihanglo)!

Cargo.lock

Lines changed: 180 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,23 @@ include = [
2626
[features]
2727
# Includes the full canonical text of each license
2828
text = []
29+
# Allows analysis of text to determine if it might be an SPDX license text
30+
detection = ["regex", "unicode-normalization"]
31+
# Allows de/serialization of a spdx::detection::Store for quicker loading
32+
detection-cache = ["detection", "zstd"]
33+
# Inlines a cache into this crate, which contains all of the licenses from the
34+
# SPDX crate that the crate version was packaged with
35+
detection-inline-cache = ["detection-cache"]
36+
# Performs license detection in parallel within the same text
37+
detection-parallel = ["detection", "rayon"]
2938

3039
[dependencies]
40+
rayon = { version = "1.11", optional = true }
41+
regex = { version = "1.12", optional = true }
3142
# In most cases expressions are quite small so we can avoid heap allocations
3243
smallvec = "1.15"
44+
unicode-normalization = { version = "0.1", optional = true }
45+
zstd = { version = "0.13", optional = true }
3346

3447
[dev-dependencies]
3548
# Used to print colored diffs in case of test failures

0 commit comments

Comments
 (0)