From 5c0b30f4f4588262d329676a545e48ed403905ba Mon Sep 17 00:00:00 2001 From: kezhenxu94 Date: Wed, 6 Jul 2022 17:21:29 +0800 Subject: [PATCH] Migrate license checker to license-eye (#220) --- .licenserc.yaml | 1 + Makefile | 4 +-- tools/check-license-header.py | 68 ----------------------------------- 3 files changed, 3 insertions(+), 70 deletions(-) delete mode 100755 tools/check-license-header.py diff --git a/.licenserc.yaml b/.licenserc.yaml index ff1069f6..f0dc9641 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -30,5 +30,6 @@ header: - '.github/PULL_REQUEST_TEMPLATE' - '.gitignore' - '**/*.json' + - 'venv' comment: on-failure diff --git a/Makefile b/Makefile index 5ffbc4fe..4e905017 100644 --- a/Makefile +++ b/Makefile @@ -68,7 +68,7 @@ check-doc-gen: dev-setup doc-gen fi license: clean - $(VENV)/python tools/check-license-header.py skywalking tests tools + docker run -it --rm -v $(shell pwd):/github/workspace ghcr.io/apache/skywalking-eyes/license-eye:f461a46e74e5fa22e9f9599a355ab4f0ac265469 header check test: gen setup-test $(VENV)/python -m pytest -v tests @@ -103,6 +103,6 @@ clean: find . -name "*.pyc" -exec rm -r {} + release: clean lint license - -tar -zcvf skywalking-python-src-$(VERSION).tgz * + -tar -zcvf skywalking-python-src-$(VERSION).tgz --exclude venv * gpg --batch --yes --armor --detach-sig skywalking-python-src-$(VERSION).tgz shasum -a 512 skywalking-python-src-$(VERSION).tgz > skywalking-python-src-$(VERSION).tgz.sha512 diff --git a/tools/check-license-header.py b/tools/check-license-header.py deleted file mode 100755 index 9e71b10d..00000000 --- a/tools/check-license-header.py +++ /dev/null @@ -1,68 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://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. -# - -import os -import sys - -ignored_chars = '#\n \t:' - -license_header = ' '.join( - [ - line.strip(ignored_chars) for line in """ - # - # Licensed to the Apache Software Foundation (ASF) under one or more - # contributor license agreements. See the NOTICE file distributed with - # this work for additional information regarding copyright ownership. - # The ASF licenses this file to You under the Apache License, Version 2.0 - # (the "License"); you may not use this file except in compliance with - # the License. You may obtain a copy of the License at - # - # http://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. - # - """.splitlines() - ] -).strip(ignored_chars) - -comment_leading_chars = ('#', '::') - - -def walk_through_dir(d) -> bool: - checked = True - for root, _sub_dirs, files in os.walk(d): - for filename in files: - file_path = os.path.join(root, filename) - with open(file_path, 'r') as f: - header = ' '.join([ - line.strip(ignored_chars) for line in f.readlines() if line.startswith(comment_leading_chars) - ]).strip() - print(f"{'✅' if license_header in header else '❌'} license header in file: {file_path}") - checked &= license_header in header - return checked - - -if __name__ == '__main__': - checked = True - for _, directory in enumerate(sys.argv): - checked &= walk_through_dir(directory) - if not checked: - sys.exit(1)