Skip to content

Commit

Permalink
feat: add supporting tools for QGate checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-rm-meyer-ISST committed Jul 26, 2024
1 parent 8a8d518 commit b2ce6c5
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .act/workflow_dispatch_helm_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"inputs": {
"node_image": "kindest/node:v1.28.9",
"upgrade_from": "",
"helm_version": "latest"
}
}
27 changes: 27 additions & 0 deletions docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
111 changes: 111 additions & 0 deletions scripts/license-check.py
Original file line number Diff line number Diff line change
@@ -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.")

0 comments on commit b2ce6c5

Please sign in to comment.