Skip to content

Commit

Permalink
Introduce a stand-alone Kotlin script to check license classifications
Browse files Browse the repository at this point in the history
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 <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Dec 15, 2023
1 parent 7f24316 commit e0a30af
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ on:
branches:
- "main"

env:
ORT_VERSION: 9.0.0

jobs:
Check:
runs-on: ubuntu-latest
Expand All @@ -27,12 +24,8 @@ jobs:
with:
distribution: 'temurin'
java-version: '17'
- name: Setup ORT helper-cli
run: |
wget https://github.com/oss-review-toolkit/ort/releases/download/$ORT_VERSION/orth-$ORT_VERSION.zip
unzip orth-$ORT_VERSION.zip -d /opt
- name: Check license-classifications.yml
run: /opt/orth-$ORT_VERSION/bin/orth list-license-categories -i license-classifications.yml
- name: Check license classifications
run: ./scripts/check-license-classifications.main.kts

Lint:
runs-on: ubuntu-latest
Expand Down
27 changes: 27 additions & 0 deletions scripts/check-license-classifications.main.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env kotlin

// SPDX-FileCopyrightText: 2023 Double Open Oy <support@doubleopen.org>
// SPDX-License-Identifier: CC0-1.0

@file:CompilerOptions("-jvm-target", "17")
@file:DependsOn("org.ossreviewtoolkit:model:10.0.0")

import java.io.File

import kotlin.system.exitProcess

import org.ossreviewtoolkit.model.licenses.LicenseClassifications
import org.ossreviewtoolkit.model.readValue

val scriptsDir = __FILE__.parentFile
val licenseClassificationsFile = scriptsDir.resolve("../license-classifications.yml").canonicalFile

val licenseClassifications = runCatching {
licenseClassificationsFile.readValue<LicenseClassifications>()
}.onFailure {
println("Unable to read '$licenseClassificationsFile': ${it.message}")
}.getOrElse {
exitProcess(1)
}

println("Check passed for '$licenseClassificationsFile'.")

0 comments on commit e0a30af

Please sign in to comment.