This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-python-extensions.git


The following commit(s) were added to refs/heads/main by this push:
     new 5fa9099  NIFI-13455 Added Apache RAT License Checking (#2)
5fa9099 is described below

commit 5fa9099f07be473723ff02aa441d4b5b64c04dd6
Author: David Handermann <exceptionfact...@apache.org>
AuthorDate: Wed Jun 26 10:52:36 2024 -0500

    NIFI-13455 Added Apache RAT License Checking (#2)
    
    Signed-off-by: David Handermann <exceptionfact...@apache.org>
---
 .asf.yaml                        | 17 ++----------
 .github/PULL_REQUEST_TEMPLATE.md | 13 +--------
 .github/workflows/build.yml      | 19 +++----------
 .gitignore                       | 16 +----------
 .ratignore                       | 16 +++++++++++
 check-licenses.sh                | 60 ++++++++++++++++++++++++++++++++++++++++
 6 files changed, 84 insertions(+), 57 deletions(-)

diff --git a/.asf.yaml b/.asf.yaml
index 303b006..f63dd9f 100644
--- a/.asf.yaml
+++ b/.asf.yaml
@@ -1,18 +1,5 @@
-# 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.
+# SPDX-License-Identifier: Apache-2.0
+
 github:
   description: "Apache NiFi Python Extensions"
   homepage: https://nifi.apache.org/
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 0be6e99..2a1ef8e 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -1,15 +1,4 @@
-<!-- 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. -->
+<!-- SPDX-License-Identifier: Apache-2.0 -->
 
 # Summary
 
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 747bff9..15b5e4a 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,18 +1,5 @@
-# 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.
+# SPDX-License-Identifier: Apache-2.0
+
 name: build
 
 on:
@@ -46,6 +33,8 @@ jobs:
     steps:
       - name: Checkout Sources
         uses: actions/checkout@v4
+      - name: Check Licenses
+        run: sh check-licenses.sh
       - name: Setup Python ${{ matrix.python }}
         uses: actions/setup-python@v5
         with:
diff --git a/.gitignore b/.gitignore
index e4fde7d..1ea568c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,18 +1,4 @@
-# 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.
+# SPDX-License-Identifier: Apache-2.0
 
 # Byte-compiled / optimized / DLL files
 __pycache__/
diff --git a/.ratignore b/.ratignore
new file mode 100644
index 0000000..af3daed
--- /dev/null
+++ b/.ratignore
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: Apache-2.0
+__pycache__/*
+build/*
+dist/*
+downloads/*
+eggs/*
+lib/*
+lib64/*
+parts/*
+sdist/*
+var/*
+wheels/*
+share/python-wheels/*
+.idea/*
+.git/*
+.cache/*
diff --git a/check-licenses.sh b/check-licenses.sh
new file mode 100755
index 0000000..377efe1
--- /dev/null
+++ b/check-licenses.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+# SPDX-License-Identifier: Apache-2.0
+
+APACHE_RAT_VERSION="0.16.1"
+APACHE_RAT_JAR="apache-rat-$APACHE_RAT_VERSION.jar"
+APACHE_RAT_JAR_URL="https://repo1.maven.org/maven2/org/apache/rat/apache-rat/$APACHE_RAT_VERSION/$APACHE_RAT_JAR";
+CACHE_DIRECTORY=".cache"
+APACHE_RAT_JAR_PATH="$CACHE_DIRECTORY/$APACHE_RAT_JAR"
+APACHE_RAT_EXCLUDE_FILE=".ratignore"
+
+# Set Java command
+if [ -n "${JAVA_HOME-}" ]; then
+  JAVACMD="$JAVA_HOME/bin/java"
+  if [ ! -x "$JAVACMD" ]; then
+    die "Java command [$JAVACMD}] not found"
+  fi
+elif command -v java > /dev/null; then
+  JAVACMD=$(command -v java)
+else
+  die "Environment variable [JAVA_HOME] and command [java] not found"
+fi
+
+# Set curl command
+if command -v curl > /dev/null; then
+  CURLCMD=$(command -v curl)
+else
+  die "Command [curl] not found"
+fi
+
+# Download Apache Rat JAR
+if [ ! -d $CACHE_DIRECTORY ]; then
+  mkdir $CACHE_DIRECTORY
+fi
+if [ ! -f $APACHE_RAT_JAR_PATH ]; then
+  echo "Downloading Apache Rat from [$APACHE_RAT_JAR_URL]"
+  CURL_RESULTS=$(exec $CURLCMD -f --silent --show-error -o 
"$APACHE_RAT_JAR_PATH" "$APACHE_RAT_JAR_URL")
+  if [ $? -ne 0 ]; then
+    echo "Failed to download Apache Rat from [$APACHE_RAT_JAR_URL]"
+    exit $?
+  fi
+fi
+
+# Run Apache Rat
+REPORT_RESULTS=$(exec $JAVACMD -jar $APACHE_RAT_JAR_PATH 
--scan-hidden-directories --exclude-file $APACHE_RAT_EXCLUDE_FILE --dir . 2>&1)
+if [ $? -ne 0 ]; then
+  echo "$REPORT_RESULTS"
+  exit $?
+fi
+
+UNKNOWN_LICENSES_FOUND=$(echo "$REPORT_RESULTS" | grep --count "??")
+echo "Unknown Licenses Found: $UNKNOWN_LICENSES_FOUND"
+
+if [ $UNKNOWN_LICENSES_FOUND -eq 0 ]; then
+  RESULT_CODE=0
+else
+  RESULT_CODE=1
+  echo "$REPORT_RESULTS"
+fi
+
+exit $RESULT_CODE

Reply via email to