Skip to content

Commit

Permalink
feat(build) fluidattacks#1099 licensing builtin with reuse
Browse files Browse the repository at this point in the history
- Create `testLicense` builtin with reuse.
- Add job to dev pipeline

Signed-off-by: Robin Hafid Quintero Lopez <rohaquinlop301@gmail.com>
  • Loading branch information
rohaquinlop committed Jun 12, 2023
1 parent d15f787 commit 835af65
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions docs/src/api/builtins/test.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions makes.nix
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
};
};
};
testLicense = {};
testPython = {
example = {
python = "3.11";
Expand Down
1 change: 1 addition & 0 deletions src/args/agnostic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions src/args/test-license/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
__nixpkgs__,
makeScript,
...
}:
makeScript {
name = "test-license";
entrypoint = ./entrypoint.sh;
searchPaths.bin = [
__nixpkgs__.git
__nixpkgs__.reuse
];
}
9 changes: 9 additions & 0 deletions src/args/test-license/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "${@}"
1 change: 1 addition & 0 deletions src/evaluator/modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions src/evaluator/modules/test-license/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
testLicense,
...
}: {
config,
lib,
...
}: {
options = {
testLicense = {};
};
config = {
outputs = {
"/testLicense" = testLicense;
};
};
}

0 comments on commit 835af65

Please sign in to comment.