-
Notifications
You must be signed in to change notification settings - Fork 21
57 lines (52 loc) · 2.01 KB
/
Copy pathlicense-check.yml
File metadata and controls
57 lines (52 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Copyright (c) 2026 Santander Group
# SPDX-License-Identifier: Apache-2.0
#
# License compliance. genetic-algorithm has no third-party runtime dependencies
# (stdlib-only), so there is no dependency-license allowlist to enforce; this
# workflow verifies that every Python source file declares an
# SPDX-License-Identifier and that no runtime dependency creeps in.
# Replace action references with SHA digests before publishing.
name: License check
on:
push:
branches: [main, development]
pull_request:
permissions:
contents: read
jobs:
no-runtime-deps:
name: Assert no runtime dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Fail if a dependency manifest is introduced
run: |
set -euo pipefail
if [ -f requirements.txt ] || grep -qE '^\s*dependencies\s*=' pyproject.toml 2>/dev/null; then
echo "FAIL: a runtime dependency manifest was introduced."
echo "genetic-algorithm must remain stdlib-only. If this is intentional,"
echo "add a dependency-license allowlist job to this workflow."
exit 1
fi
echo "OK: no runtime dependency manifest present."
spdx-headers:
name: SPDX headers
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Verify every Python file declares SPDX-License-Identifier
run: |
missing=0
while IFS= read -r f; do
if ! head -n 5 "$f" | grep -q "SPDX-License-Identifier:"; then
echo "MISSING SPDX header: $f"
missing=$((missing + 1))
fi
done < <(find genetic_algorithm tests examples -type f -name "*.py")
if [ "$missing" -gt 0 ]; then
echo "Found $missing files without SPDX header."
exit 1
fi
echo "OK: all Python files have SPDX headers."