Skip to content

Commit 4946fa6

Browse files
authored
ci: Adds a test case in the CI (#16)
* feat: Adds additional safeguards * ci: Adds test case * fix: Fixed typo
1 parent 83f54bc commit 4946fa6

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

.github/license-notice.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This program is licensed under the Apache License 2.0.
2+
# See LICENSE or go to <https://www.apache.org/licenses/LICENSE-2.0> for full license details.

.github/workflows/tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ jobs:
2222
- name: Build docker
2323
run: docker build . -t header-validator:py3.8.13-alpine
2424
- name: Run action
25-
run: docker run --workdir /github/workspace -v "/home/runner/work/validate-python-headers/validate-python-headers":"/github/workspace" header-validator:py3.8.13-alpine 'François-Guillaume Fernandez' 2022 Apache-2.0 src/ __init__.py .github/ ''
25+
run: |
26+
docker run --workdir /github/workspace -v "/home/runner/work/validate-python-headers/validate-python-headers":"/github/workspace" header-validator:py3.8.13-alpine 'François-Guillaume Fernandez' 2022 Apache-2.0 src/ __init__.py .github/ ''
27+
docker run --workdir /github/workspace -v "/home/runner/work/validate-python-headers/validate-python-headers":"/github/workspace" header-validator:py3.8.13-alpine 'François-Guillaume Fernandez' 2022 '' src/ __init__.py .github/ .github/license-notice.txt

src/validate_headers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_header_options(
3434

3535
# License check
3636
license_notices = []
37-
if isinstance(license_id, str):
37+
if isinstance(license_id, str) and len(license_id) > 0:
3838
license_info = LICENSES.get(license_id)
3939
if not isinstance(license_info, dict):
4040
raise KeyError(f"Invalid license identifier: {license_id}")
@@ -48,7 +48,7 @@ def get_header_options(
4848
]
4949
for url in license_info["urls"]
5050
]
51-
elif isinstance(license_notice, str):
51+
elif isinstance(license_notice, str) and len(license_notice) > 0:
5252
if not Path(license_notice).is_file():
5353
raise FileNotFoundError("Unable to locate the text of the license notice.")
5454
with open(license_notice, "r") as f:

0 commit comments

Comments
 (0)