diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index a406b445..c2e6c521 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -489,6 +489,23 @@ jobs: - uses: cachix/install-nix-action@67e9fd765dbe63fabe0ce2bd72f56f9a417696a0 - name: /taintTerraform/module run: nix-env -if . && m . /taintTerraform/module + + linux_testLicense: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@f095bcc56b7c2baf48f3ac70d6d6782f4f553222 + - uses: docker://docker.io/nixos/nix@sha256:c3db4c484f6b1ee6c9bb8ca90307cfbeca8ef88156840911356a677eeaff4845 + name: /testLicense + with: + set-safe-directory: /github/workspace + args: sh -c "nix-env -if . && m . /testLicense" + macos_testLicense: + runs-on: macos-latest + steps: + - uses: actions/checkout@f095bcc56b7c2baf48f3ac70d6d6782f4f553222 + - uses: cachix/install-nix-action@67e9fd765dbe63fabe0ce2bd72f56f9a417696a0 + - name: /testLicense + run: nix-env -if . && m . /testLicense linux_testPython_cliMain: runs-on: ubuntu-latest diff --git a/docs/src/api/builtins/test.md b/docs/src/api/builtins/test.md index 00edb168..fa26c8e8 100644 --- a/docs/src/api/builtins/test.md +++ b/docs/src/api/builtins/test.md @@ -1,3 +1,28 @@ +## testLicense + +Test the license of a project using [reuse](https://reuse.software/). + +Types: + +- testLicense: Empty attribute set. + +Example: + +=== "makes.nix" + + ```nix + { + testLicense = { + }; + } + ``` + +=== "Invocation" + + ```bash + m . /testLicense + ``` + ## testPullRequest Test a pull request diff --git a/makes.nix b/makes.nix index 89c3b6c2..a5679438 100644 --- a/makes.nix +++ b/makes.nix @@ -251,6 +251,7 @@ }; }; }; + testLicense = {}; testPython = { example = { python = "3.11"; diff --git a/src/args/agnostic.nix b/src/args/agnostic.nix index e0cbaf9e..866b7e5c 100644 --- a/src/args/agnostic.nix +++ b/src/args/agnostic.nix @@ -106,6 +106,7 @@ stringCapitalize = import ./string-capitalize/default.nix self; sublist = import ./sublist/default.nix self; taintTerraform = import ./taint-terraform/default.nix self; + testLicense = import ./test-license/default.nix self; testTerraform = import ./test-terraform/default.nix self; testPullRequest = import ./test-pull-request/default.nix self; testPython = import ./test-python/default.nix self; diff --git a/src/args/test-license/default.nix b/src/args/test-license/default.nix new file mode 100644 index 00000000..a0db5076 --- /dev/null +++ b/src/args/test-license/default.nix @@ -0,0 +1,13 @@ +{ + __nixpkgs__, + makeScript, + ... +}: +makeScript { + name = "test-license"; + entrypoint = ./entrypoint.sh; + searchPaths.bin = [ + __nixpkgs__.git + __nixpkgs__.reuse + ]; +} diff --git a/src/args/test-license/entrypoint.sh b/src/args/test-license/entrypoint.sh new file mode 100644 index 00000000..4e62b5f2 --- /dev/null +++ b/src/args/test-license/entrypoint.sh @@ -0,0 +1,9 @@ +# shellcheck shell=bash + +function main { + if ! reuse lint; then + error "Some files are not properly licensed. Please adapt .reuse/dep5" + fi +} + +main "${@}" diff --git a/src/evaluator/modules/default.nix b/src/evaluator/modules/default.nix index 316a71c1..44c67099 100644 --- a/src/evaluator/modules/default.nix +++ b/src/evaluator/modules/default.nix @@ -50,6 +50,7 @@ (import ./secure-kubernetes-with-rbac-police/default.nix args) (import ./secure-python-with-bandit/default.nix args) (import ./taint-terraform/default.nix args) + (import ./test-license/default.nix args) (import ./test-pull-request/default.nix args) (import ./test-python/default.nix args) (import ./test-terraform/default.nix args) diff --git a/src/evaluator/modules/test-license/default.nix b/src/evaluator/modules/test-license/default.nix new file mode 100644 index 00000000..d420c424 --- /dev/null +++ b/src/evaluator/modules/test-license/default.nix @@ -0,0 +1,17 @@ +{ + testLicense, + ... +}: { + config, + lib, + ... +}: { + options = { + testLicense = {}; + }; + config = { + outputs = { + "/testLicense" = testLicense; + }; + }; +}