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

NIFI-13455 Add Apache RAT License Checking #2

Merged
merged 1 commit into from
Jun 26, 2024
Merged
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
17 changes: 2 additions & 15 deletions .asf.yaml
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
13 changes: 1 addition & 12 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
19 changes: 4 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 1 addition & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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__/
Expand Down
16 changes: 16 additions & 0 deletions .ratignore
Original file line number Diff line number Diff line change
@@ -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/*
60 changes: 60 additions & 0 deletions check-licenses.sh
Original file line number Diff line number Diff line change
@@ -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