Skip to content

Commit

Permalink
Add license checker
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzelin committed Dec 11, 2024
1 parent 7f6a1d4 commit b0916ec
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/check-licensing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
################################################################################
# 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.
################################################################################

name: Check licensing

on: [push, pull_request]

jobs:
rat-check:
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set JDK
uses: actions/setup-java@v2
with:
java-version: 8
distribution: 'adopt'

- name: Check licensing
run: ./dev/check-licensing.sh
21 changes: 21 additions & 0 deletions dev/.rat-excludes
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
################################################################################
# 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.
################################################################################

paimon-python-java-bridge/*
.gitignore
rat-results.txt
55 changes: 55 additions & 0 deletions dev/check-licensing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
################################################################################
# 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.
################################################################################

download_rat_jar () {
URL="https://repo.maven.apache.org/maven2/org/apache/rat/apache-rat/${RAT_VERSION}/apache-rat-${RAT_VERSION}.jar"
JAR="$rat_jar"

# Download rat launch jar
printf "Attempting to fetch rat\n"
wget --quiet ${URL} -O "$JAR"
}

BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
PROJECT_ROOT="${BASE_DIR}/../"

cd ${PROJECT_ROOT}

mkdir -p ${PROJECT_ROOT}/rat
export RAT_VERSION=0.15
export rat_jar=${PROJECT_ROOT}/rat/apache-rat-${RAT_VERSION}.jar

download_rat_jar

java -jar ${rat_jar} -E ${PROJECT_ROOT}/dev/.rat-excludes -d ${PROJECT_ROOT} > rat/rat-results.txt

if [ $? -ne 0 ]; then
echo "RAT exited abnormally"
exit 1
fi

ERRORS="$(cat rat/rat-results.txt | grep -e "??")"

if [[ -n "${ERRORS}" ]]; then
echo "Could not find Apache license headers in the following files:"
echo ${ERRORS}
exit 1
else
echo -e "RAT checks passed."
fi

0 comments on commit b0916ec

Please sign in to comment.