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

scripts.set_copyright_year: Add a CI check to ensure the copyright is updated #344

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,20 @@ jobs:
run: |
python -m build

sdk-check-copyright:
# This job checks that the copyright year in the header of all files is up to date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install required dependencies
run: |
sudo apt-get update
sudo apt-get install -y bash git
- name: Run copyright check
run: |
chmod +x ./etc/scripts/set_copyright_year.sh
./etc/scripts/set_copyright_year.sh --check

server-package:
# This job checks if we can build our server package
runs-on: ubuntu-latest
Expand Down Expand Up @@ -212,3 +226,4 @@ jobs:
- name: Stop and remove the container
run: |
docker stop basyx-python-server && docker rm basyx-python-server

31 changes: 30 additions & 1 deletion etc/scripts/set_copyright_year.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,36 @@
#
# The script will check the first two lines for a copyright
# notice (in case the first line is a shebang).
#
# Run this script with --check to have it raise an error if it
# change anything.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# change anything.
# would change anything.



# Set CHECK_MODE based on whether --check is passed
CHECK_MODE=false
if [[ "$1" == "--check" ]]; then
CHECK_MODE=true
shift # Remove --check from the arguments
fi

while read -rd $'\0' year file; do
sed -i "1,2s/^\(# Copyright (c) \)[[:digit:]]\{4,\}/\1$year/" "$file"

# Extract the first year from the copyright notice
current_year=$(sed -n '1,2s/^\(# Copyright (c) \)\([[:digit:]]\{4,\}\).*/\2/p' "$file")

# Skip the file if no year is found
if [[ -z "$current_year" ]]; then
continue
fi

if $CHECK_MODE && [[ "$current_year" != "$year" ]]; then
echo "Error: Copyright year mismatch in file $file. Expected $year, found $current_year."
exit 1
Frosty2500 marked this conversation as resolved.
Show resolved Hide resolved
fi

if ! $CHECK_MODE && [[ "$current_year" != "$year" ]]; then
sed -i "1,2s/^\(# Copyright (c) \)[[:digit:]]\{4,\}/\1$year/" "$file"
echo "Updated copyright year in $file"
fi
done < <(git ls-files -z "$@" | xargs -0I{} git log -1 -z --format="%ad {}" --date="format:%Y" "{}")

2 changes: 1 addition & 1 deletion sdk/basyx/aas/adapter/_generic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/adapter/json/json_deserialization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/adapter/json/json_serialization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/adapter/xml/xml_deserialization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/adapter/xml/xml_serialization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/backend/backends.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/backend/couchdb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/backend/local_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/examples/data/_helper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/examples/data/example_aas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/examples/data/example_submodel_template.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/model/_string_constraints.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/model/aas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/model/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/model/concept.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/model/datatypes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/model/provider.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/util/identification.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/basyx/aas/util/traversal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/_helper/setup_testdb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/adapter/aasx/test_aasx.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/adapter/json/test_json_deserialization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/adapter/json/test_json_serialization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/adapter/xml/test_xml_deserialization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/adapter/xml/test_xml_serialization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/backend/test_backends.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/backend/test_couchdb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/backend/test_local_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/examples/test_examples.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/examples/test_helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/examples/test_tutorials.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/model/test_aas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/model/test_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/model/test_concept.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/model/test_datatypes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/model/test_provider.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/model/test_string_constraints.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/model/test_submodel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/util/test_identification.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022 the Eclipse BaSyx Authors
# Copyright (c) 2024 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
Expand Down
Loading