Skip to content

Commit 0b3aefc

Browse files
Merge branch 'main' into fix-d2d-config-bugs
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
2 parents ebacb9f + e4ba158 commit 0b3aefc

30 files changed

+301
-179
lines changed

.github/workflows/publish-docker.yml renamed to .github/workflows/publish-docker-image.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish Docker image on GHCR
1+
name: Publish Docker image on GitHub Container Registry
22
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions
33

44
on:
@@ -15,8 +15,8 @@ env:
1515
IMAGE_NAME: ${{ github.repository }}
1616

1717
jobs:
18-
build-and-push-image:
19-
runs-on: ubuntu-22.04
18+
build-and-publish-image:
19+
runs-on: ubuntu-24.04
2020

2121
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
2222
permissions:

.github/workflows/pypi-release-aboutcode-pipeline.yml renamed to .github/workflows/publish-pypi-release-aboutcode-pipeline.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ name: Build aboutcode.pipeline Python distributions and publish on PyPI
33
on:
44
workflow_dispatch:
55
push:
6-
tags:
7-
- "aboutcode.pipeline/*"
6+
tags:
7+
- "aboutcode.pipeline/*"
88

99
jobs:
1010
build-and-publish:
1111
name: Build and publish library to PyPI
12-
runs-on: ubuntu-22.04
12+
runs-on: ubuntu-24.04
1313

1414
steps:
1515
- uses: actions/checkout@v4

.github/workflows/pypi-release.yml renamed to .github/workflows/publish-pypi-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
build-and-publish:
1111
name: Build and publish library to PyPI
12-
runs-on: ubuntu-22.04
12+
runs-on: ubuntu-24.04
1313

1414
steps:
1515
- uses: actions/checkout@v4

.github/workflows/ci-docker.yml renamed to .github/workflows/run-unit-tests-docker.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
name: Test on Docker CI
1+
name: Run unit tests on Docker container
22

3-
on: [push, pull_request]
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
permissions:
11+
contents: read
412

513
jobs:
6-
build:
7-
runs-on: ubuntu-22.04
14+
run-unit-tests:
15+
runs-on: ubuntu-24.04
816

917
steps:
1018
- name: Checkout code
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Run unit tests on macOS
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
permissions:
11+
contents: read
12+
13+
env:
14+
POSTGRES_DB: scancodeio
15+
POSTGRES_USER: scancodeio
16+
POSTGRES_PASSWORD: scancodeio
17+
18+
jobs:
19+
run-unit-tests:
20+
runs-on: macos-13
21+
22+
strategy:
23+
matrix:
24+
python-version: ["3.10", "3.11", "3.12", "3.13"]
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
30+
- name: Set up Python ${{ matrix.python-version }}
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
35+
- name: Set up Python ${{ matrix.python-version }}
36+
uses: ikalnytskyi/action-setup-postgres@v7
37+
id: postgres
38+
with:
39+
postgres-version: "14" # 13 is not supported.
40+
database: ${{ env.POSTGRES_DB }}
41+
username: ${{ env.POSTGRES_USER }}
42+
password: ${{ env.POSTGRES_PASSWORD }}
43+
port: 5432
44+
45+
- name: Install Python dependencies
46+
run: make dev envfile
47+
48+
- name: Run Django tests
49+
run: .venv/bin/python manage.py test --verbosity=2 --noinput
50+
env:
51+
SCANCODEIO_DB_NAME: ${{ env.POSTGRES_DB }}
52+
SCANCODEIO_DB_USER: ${{ env.POSTGRES_USER }}
53+
SCANCODEIO_DB_PASSWORD: ${{ env.POSTGRES_PASSWORD }}

.github/workflows/ci.yml renamed to .github/workflows/run-unit-tests.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
name: Test CI
1+
name: Run unit tests
22

3-
on: [push, pull_request]
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
permissions:
11+
contents: read
412

513
env:
614
POSTGRES_DB: scancodeio
@@ -9,8 +17,8 @@ env:
917
POSTGRES_INITDB_ARGS: --encoding=UTF-8 --lc-collate=en_US.UTF-8 --lc-ctype=en_US.UTF-8
1018

1119
jobs:
12-
build:
13-
runs-on: ubuntu-22.04
20+
run-unit-tests:
21+
runs-on: ubuntu-24.04
1422

1523
services:
1624
postgres:

CHANGELOG.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ Changelog
44
v35.2.0 (unreleased)
55
--------------------
66

7+
- Refactor policies implementation to support more than licenses.
8+
The entire ``policies`` data is now stored on the ``ScanPipeConfig`` in place of the
9+
``license_policy_index``.
10+
Also, a new method ``get_policies_dict`` methods is now available on the ``Project``
11+
model to easily retrieve all the policies data as a dictionary.
12+
Renamed for clarity:
13+
* ``policy_index`` to ``license_policy_index``
14+
* ``policies_enabled`` to ``license_policies_enabled``
15+
https://github.com/aboutcode-org/scancode.io/pull/1718
16+
717
- Add support for SPDX license identifiers as ``license_key`` in license policies
818
``policies.yml`` file.
919
https://github.com/aboutcode-org/scancode.io/issues/1348

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,12 @@ select = [
164164
"D", # pydocstyle
165165
"F", # Pyflakes
166166
"UP", # pyupgrade
167+
"DJ", # flake8-django
167168
"S", # flake8-bandit
168169
"I", # isort
169170
"C9", # McCabe complexity
171+
"FIX", # flake8-fix
172+
"FURB", # refurb
170173
]
171174
ignore = ["D1", "D203", "D205", "D212", "D400", "D415"]
172175

@@ -188,6 +191,5 @@ max-complexity = 10
188191
[tool.ruff.lint.per-file-ignores]
189192
# Allow the usage of assert in the test_spdx file.
190193
"**/test_spdx.py*" = ["S101"]
191-
"scanpipe/pipes/spdx.py" = ["UP006", "UP035"]
192194
# Allow complexity in management commands
193195
"scanpipe/management/commands/*" = ["C901"]

scancodeio/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@
292292
SCANCODEIO_WORKSPACE_LOCATION = tempfile.mkdtemp()
293293
SCANCODEIO_REQUIRE_AUTHENTICATION = True
294294
SCANCODEIO_SCAN_FILE_TIMEOUT = 120
295+
SCANCODEIO_POLICIES_FILE = None
295296
# The default password hasher is rather slow by design.
296297
# Using a faster hashing algorithm in the testing context to speed up the run.
297298
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]

scanpipe/apps.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
from licensedcode.models import load_licenses
4040

4141
from scanpipe.policies import load_policies_file
42-
from scanpipe.policies import make_license_policy_index
4342

4443
try:
4544
from importlib import metadata as importlib_metadata
@@ -61,7 +60,7 @@ def __init__(self, app_name, app_module):
6160

6261
# Mapping of registered pipeline names to pipeline classes.
6362
self._pipelines = {}
64-
self.license_policies_index = {}
63+
self.policies = {}
6564

6665
workspace_location = settings.SCANCODEIO_WORKSPACE_LOCATION
6766
self.workspace_path = Path(workspace_location).expanduser().resolve()
@@ -226,7 +225,7 @@ def get_scancode_licenses(self):
226225

227226
def set_policies(self):
228227
"""
229-
Compute and sets the `license_policies` on the app instance.
228+
Set the global app policies on the app instance.
230229
231230
If the policies file is available but not formatted properly or doesn't
232231
include the proper content, we want to raise an exception while the app
@@ -240,7 +239,7 @@ def set_policies(self):
240239
if policies_file.exists():
241240
policies = load_policies_file(policies_file)
242241
logger.debug(style.SUCCESS(f"Loaded policies from {policies_file}"))
243-
self.license_policies_index = make_license_policy_index(policies)
242+
self.policies = policies
244243
else:
245244
logger.debug(style.WARNING("Policies file not found."))
246245

0 commit comments

Comments
 (0)