diff --git a/.act/workflow_dispatch_helm_test.json b/.act/workflow_dispatch_helm_test.json new file mode 100644 index 00000000..8a057e89 --- /dev/null +++ b/.act/workflow_dispatch_helm_test.json @@ -0,0 +1,7 @@ +{ + "inputs": { + "node_image": "kindest/node:v1.28.9", + "upgrade_from": "", + "helm_version": "latest" + } +} diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index fcb03b7e..383d2cd6 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -243,6 +243,33 @@ act --list act --job lint-test -e .act/pr-event.json ``` +# Notes on the release + +## Run helm test locally for n kubernetes versions + +Using act, you can run workflows locally. If you want to test how to use the workflow, update the file +`.act/workflow_dispatch_helm_test.json` that contains the input parameters. + +Check for supported kubernetes versions of kind per [release](https://github.com/kubernetes-sigs/kind/releases). + +```shell +# root dir +act workflow_dispatch -j lint-test -e .act/workflow_dispatch_helm_test.json +``` + + +## Check license files + +For easier checks we created a small python script to check license files. + +It searches for the common contributor (Contributors to the EF) and prints files, not containing that + +```shell +cd scripts + +python3 license-check.py +``` + ## NOTICE This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). diff --git a/scripts/license-check.py b/scripts/license-check.py new file mode 100644 index 00000000..c3f57296 --- /dev/null +++ b/scripts/license-check.py @@ -0,0 +1,111 @@ +# +# Copyright (c) 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V. (represented by Fraunhofer ISST) +# Copyright (c) 2024 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License, Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +import os + +# Search above /scripts (root) +directory = "../." +license_header = """Contributors to the Eclipse Foundation""" + +# don't check SE life cycle folders +blacklisted_folders = [ + "node_modules", + ".git", + "build", + "target", + "dist", + ".idea", + ".mvn" +] + +# exclude non_code artifacts +excluded_extensions = [ + ".png", + ".jpg", + ".gif", + ".pdf", + ".md", + ".svg", + ".puml", + ".properties", + ".keys", + ".secret", + ".key", + ".iml", + ".txt", + ".json", + ".ico", + ".jsonld", + ".tgz", + ".cert", + ".pem", + ".conf" +] + +# exclude specific files by name patterns +excluded_file_patterns = [ + "README", + "LICENSE", + "config", + ".gitignore", + ".helmignore", + ".prettierrc", + ".env", + "mvnw", + "DEPENDENCIES" +] + +def file_contains_license(file_path, license_header): + with open(file_path, 'r', encoding='utf-8', errors='ignore') as file: + content = file.read() + return license_header in content + +def find_files_without_license(directory, license_header, blacklisted_folders): + files_without_license = [] + for root, _, files in os.walk(directory): + if any(blacklisted_folder in root for blacklisted_folder in blacklisted_folders): + continue + for file in files: + file_path = os.path.join(root, file) + + # Skip files with excluded extensions + if any(file.endswith(ext) for ext in excluded_extensions): + print(f"Skipping excluded file: {file_path}") + continue + + # Skip specific excluded files by start pattern + if any(file.startswith(pattern) for pattern in excluded_file_patterns): + print(f"Skipping specific excluded file by pattern: {file_path}") + continue + + if not file_contains_license(file_path, license_header): + files_without_license.append(file_path) + return files_without_license + +# Run the script +files_without_license = find_files_without_license(directory, license_header, blacklisted_folders) + +# Print the list of files without the license header +if files_without_license: + print("Files without the license header:") + for file in files_without_license: + print(file) +else: + print("All files contain the license header.")