Skip to content

Commit 02f17b5

Browse files
authored
Add a "Check compliance" step and related options #12 (#13)
Signed-off-by: tdruez <[email protected]>
1 parent e0a8e53 commit 02f17b5

File tree

4 files changed

+67
-13
lines changed

4 files changed

+67
-13
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
on: [push]
2+
3+
jobs:
4+
scan-codebase:
5+
runs-on: ubuntu-22.04
6+
name: Scan codebase with ScanCode.io
7+
steps:
8+
- uses: actions/checkout@v4
9+
with:
10+
path: scancode-inputs
11+
- uses: nexB/scancode-action@alpha
12+
with:
13+
pipelines: "scan_codebase,find_vulnerabilities"
14+
env:
15+
VULNERABLECODE_URL: https://public.vulnerablecode.io/

.github/workflows/scan-codebase.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ on: [push]
22

33
jobs:
44
scan-codebase:
5-
runs-on: ubuntu-22.04
6-
name: Scan codebase with ScanCode.io
5+
runs-on: ubuntu-24.04
6+
name: Scan codebase and check for compliance issues
77
steps:
88
- uses: actions/checkout@v4
99
with:
1010
path: scancode-inputs
11-
- uses: nexB/scancode-action@alpha
11+
- name: Run scancode-action from current branch
12+
uses: ./scancode-inputs
1213
with:
13-
pipelines: "scan_codebase,find_vulnerabilities"
14-
env:
15-
VULNERABLECODE_URL: https://public.vulnerablecode.io/
14+
pipelines: "scan_codebase"
15+
check-compliance: true
16+
compliance-fail-level: "WARNING"

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Workflows.
2121
- [Choose the output formats](#choose-the-output-formats)
2222
- [Provide download URLs inputs](#provide-download-urls-inputs)
2323
- [Fetch pipelines inputs](#fetch-pipelines-inputs)
24+
- [Check for compliance issues](#check-for-compliance-issues)
2425
- [Define a custom project name](#define-a-custom-project-name)
2526
- [Install ScanCode.io from a repository branch](#install-scancodeio-from-a-repository-branch)
2627
- [Where does the scan results go?](#where-does-the-scan-results-go)
@@ -68,6 +69,15 @@ steps:
6869
# Default is 'scancode-outputs'
6970
outputs-archive-name:
7071

72+
# Check for compliance issues in the project.
73+
# Exits with a non-zero status if compliance issues are detected.
74+
# Default is false
75+
check-compliance:
76+
77+
# Failure level for compliance check. Options: ERROR, WARNING, MISSING.
78+
# Default is 'ERROR'
79+
compliance-fail-level:
80+
7181
# Python version that will be installed to run ScanCode.io
7282
# Default is '3.11'
7383
python-version:
@@ -152,6 +162,20 @@ For details on setting up and configuring your own instance, please refer to the
152162
pipelines: "scan_single_package"
153163
```
154164

165+
### Check for compliance issues
166+
167+
```yaml
168+
- uses: nexB/scancode-action@alpha
169+
with:
170+
check-compliance: true
171+
compliance-fail-level: "WARNING"
172+
```
173+
174+
> [!NOTE]
175+
> This feature requires to provide Project policies.
176+
> For details on setting up and configuring your own instance, please refer to the
177+
> [ScanCode.io Policies documentation](https://scancodeio.readthedocs.io/en/latest/policies.html).
178+
155179
### Define a custom project name
156180

157181
```yaml

action.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,25 @@ inputs:
1111
description: "Relative path within the $GITHUB_WORKSPACE for pipeline inputs"
1212
default: "${{ github.workspace }}/scancode-inputs"
1313
input-urls:
14-
description: 'Provide one or more URLs to download for the pipeline run execution'
14+
description: "Provide one or more URLs to download for the pipeline run execution."
1515
required: false
1616
default: ""
1717
project-name:
18-
description: "Name of the project"
18+
description: "Name of the project."
1919
default: "scancode-action"
2020
outputs-archive-name:
21-
description: "Name of the outputs archive"
21+
description: "Name of the outputs archive."
2222
default: "scancode-outputs"
23+
check-compliance:
24+
description: |
25+
Check for compliance issues in the project.
26+
Exits with a non-zero status if compliance issues are detected.
27+
compliance-fail-level:
28+
description: "Failure level for compliance check. Options: ERROR, WARNING, MISSING."
29+
default: "ERROR"
30+
required: false
2331
python-version:
24-
description: "Python version"
32+
description: "Python version."
2533
default: "3.11"
2634
scancodeio-repo-branch:
2735
description: "Branch to install ScanCode.io from the GitHub repository (optional)"
@@ -64,7 +72,7 @@ runs:
6472
6573
- name: Run migrations to prepare the database
6674
shell: bash
67-
run: scanpipe migrate
75+
run: scanpipe migrate --verbosity 0
6876

6977
- name: Generate `--pipeline` CLI arguments
7078
shell: bash
@@ -117,8 +125,14 @@ runs:
117125
shell: bash
118126
run: scanpipe output
119127
--project ${{ inputs.project-name }}
120-
--format ${{ inputs.output-formats }}
121-
--no-color
128+
--format ${{ inputs.output-formats }}
129+
130+
- name: Check compliance
131+
if: inputs.check-compliance == 'true'
132+
shell: bash
133+
run: scanpipe check-compliance
134+
--project ${{ inputs.project-name }}
135+
--fail-level ${{ inputs.compliance-fail-level }}
122136

123137
- name: Upload outputs
124138
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)