Skip to content

Commit e0a30af

Browse files
committed
Introduce a stand-alone Kotlin script to check license classifications
Replace the check via the ORT helper-cli command with a custom stand-alone Kotlin script that uses ORT programmatically. This offers more flexibility going forward, like checking that all classified licenses are valid SPDX IDs. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 7f24316 commit e0a30af

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

.github/workflows/check.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ on:
1212
branches:
1313
- "main"
1414

15-
env:
16-
ORT_VERSION: 9.0.0
17-
1815
jobs:
1916
Check:
2017
runs-on: ubuntu-latest
@@ -27,12 +24,8 @@ jobs:
2724
with:
2825
distribution: 'temurin'
2926
java-version: '17'
30-
- name: Setup ORT helper-cli
31-
run: |
32-
wget https://github.com/oss-review-toolkit/ort/releases/download/$ORT_VERSION/orth-$ORT_VERSION.zip
33-
unzip orth-$ORT_VERSION.zip -d /opt
34-
- name: Check license-classifications.yml
35-
run: /opt/orth-$ORT_VERSION/bin/orth list-license-categories -i license-classifications.yml
27+
- name: Check license classifications
28+
run: ./scripts/check-license-classifications.main.kts
3629

3730
Lint:
3831
runs-on: ubuntu-latest
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env kotlin
2+
3+
// SPDX-FileCopyrightText: 2023 Double Open Oy <[email protected]>
4+
// SPDX-License-Identifier: CC0-1.0
5+
6+
@file:CompilerOptions("-jvm-target", "17")
7+
@file:DependsOn("org.ossreviewtoolkit:model:10.0.0")
8+
9+
import java.io.File
10+
11+
import kotlin.system.exitProcess
12+
13+
import org.ossreviewtoolkit.model.licenses.LicenseClassifications
14+
import org.ossreviewtoolkit.model.readValue
15+
16+
val scriptsDir = __FILE__.parentFile
17+
val licenseClassificationsFile = scriptsDir.resolve("../license-classifications.yml").canonicalFile
18+
19+
val licenseClassifications = runCatching {
20+
licenseClassificationsFile.readValue<LicenseClassifications>()
21+
}.onFailure {
22+
println("Unable to read '$licenseClassificationsFile': ${it.message}")
23+
}.getOrElse {
24+
exitProcess(1)
25+
}
26+
27+
println("Check passed for '$licenseClassificationsFile'.")

0 commit comments

Comments
 (0)