Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SPDX warning #17

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/check_license.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: spdx

on:
pull_request

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
check-spdx-headers:
runs-on: ubuntu-latest

steps:

- name: Checkout code
uses: actions/checkout@v4
with:
# required to grab the history of the PR
fetch-depth: 0
submodules: 'true'

- name: Get changed files
run: |
echo "files=$(git diff --name-only ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | tr '\n' ',')" >> $GITHUB_ENV

- name: Set license
run: |
echo "licenses=Apache-2.0" >> $GITHUB_ENV

- uses: ./spdx
with:
files: "${{ env.files }}"
licenses: "${{ env.licenses }}"
24 changes: 24 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: pre-commit

on: [pull_request]

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
pre-commit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
# required to grab the history of the PR
fetch-depth: 0
submodules: 'true'
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: pre-commit/[email protected]
with:
extra_args: --color=always --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude_types: ["dbc"]
- id: end-of-file-fixer
exclude_types: ["dbc", "json"]
exclude: \.token$
- id: check-yaml
- id: check-added-large-files
4 changes: 2 additions & 2 deletions spdx/verify-spdx-headers
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import os
import re

SLUG = re.compile('[a-zA-Z0-9.-]+')
SPDX = re.compile(f'SPDX-License-Identifier:\s+({SLUG.pattern})')
SPDX = re.compile(rf'SPDX-License-Identifier:\s+({SLUG.pattern})')

class Language:
def __init__(self, *comments, shebang=False):
Expand All @@ -21,7 +21,7 @@ class Language:
if isinstance(comment, tuple):
(init, fini) = comment

pattern = f"^{init}\s*{SPDX.pattern}\s*{fini}\s*$"
pattern = rf"^{init}\s*{SPDX.pattern}\s*{fini}\s*$"
self.__match.append(re.compile(pattern))

def license(self, path):
Expand Down
Loading