diff --git a/.github/workflows/update-licenses.yml b/.github/workflows/update-licenses.yml index 146e07d..0d3ab21 100644 --- a/.github/workflows/update-licenses.yml +++ b/.github/workflows/update-licenses.yml @@ -83,3 +83,28 @@ jobs: branch: update-license-db delete-branch: true labels: dependencies + + report: + needs: update + if: ${{ !cancelled() }} + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Open, update or close the failure issue + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + FAILED: ${{ contains(needs.*.result, 'failure') }} + TITLE: ${{ github.workflow }} workflow is failing + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + issue=$(gh issue list --state open --search "in:title \"$TITLE\"" --json number,title \ + --jq '.[] | select(.title == env.TITLE) | .number' | head -n1) + if [ "$FAILED" != true ]; then + if [ -n "$issue" ]; then gh issue close "$issue" --comment "Passing again: $RUN_URL"; fi + elif [ -n "$issue" ]; then + gh issue comment "$issue" --body "Failed again: $RUN_URL" + else + gh issue create --title "$TITLE" --body "Scheduled run failed: $RUN_URL" + fi diff --git a/licensedb_test.go b/licensedb_test.go index 79cc404..c7c2edb 100644 --- a/licensedb_test.go +++ b/licensedb_test.go @@ -29,7 +29,8 @@ func TestLicenseDataParses(t *testing.T) { continue } expression := key - if entry.IsException && lookupLicense(key) == "" { + // ScanCode and SPDX can disagree on whether a key is an exception. + if lookupLicense(key) == "" && (entry.IsException || lookupException(key) != "") { expression = "GPL-2.0-only WITH " + key } if _, err := ParseSyntax(expression); err != nil { diff --git a/normalize.go b/normalize.go index 60ff827..a0cd0a2 100644 --- a/normalize.go +++ b/normalize.go @@ -68,11 +68,6 @@ func lookupException(s string) string { return lookupFolded(s, exceptionMap, exceptionFoldMap) } -// isValidLicenseOrException checks if the string is a valid license or exception. -func isValidLicenseOrException(s string) bool { - return lookupLicense(s) != "" || lookupException(s) != "" -} - func makeFoldMap(source map[string]string) map[uint64][]string { result := make(map[uint64][]string, len(source)) for _, canonical := range source { diff --git a/spdx.test b/spdx.test deleted file mode 100755 index e7f8f83..0000000 Binary files a/spdx.test and /dev/null differ