Skip to content

Commit df11b49

Browse files
authored
Add license checker (#34)
1 parent 7f6a1d4 commit df11b49

File tree

3 files changed

+139
-0
lines changed

3 files changed

+139
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
################################################################################
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
################################################################################
18+
19+
name: Check licensing
20+
21+
on: [push, pull_request]
22+
23+
jobs:
24+
rat-check:
25+
runs-on: ubuntu-22.04
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v2
30+
31+
- name: Set JDK
32+
uses: actions/setup-java@v2
33+
with:
34+
java-version: 8
35+
distribution: 'adopt'
36+
37+
- name: Check licensing
38+
run: ./dev/check-licensing.sh

dev/.rat-excludes

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
################################################################################
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
################################################################################
18+
19+
paimon-python-java-bridge/*
20+
.gitignore
21+
rat-results.txt

dev/check-licensing.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env bash
2+
################################################################################
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
################################################################################
19+
20+
download_rat_jar () {
21+
URL="https://repo.maven.apache.org/maven2/org/apache/rat/apache-rat/${RAT_VERSION}/apache-rat-${RAT_VERSION}.jar"
22+
JAR="$rat_jar"
23+
24+
# Download rat launch jar
25+
echo "Attempting to fetch rat"
26+
wget --quiet ${URL} -O "$JAR"
27+
}
28+
29+
CURR_DIR=`pwd`
30+
SOURCE_PACKAGE=${SOURCE_PACKAGE}
31+
32+
export RAT_VERSION=0.15
33+
export rat_jar=rat/apache-rat-${RAT_VERSION}.jar
34+
35+
if [ -z "${SOURCE_PACKAGE}" ]; then
36+
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
37+
PROJECT_ROOT="${BASE_DIR}/../"
38+
cd ${PROJECT_ROOT}
39+
40+
# Sanity check to ensure that resolved paths are valid; a LICENSE file should always exist in project root
41+
if [ ! -f ${PROJECT_ROOT}/LICENSE ]; then
42+
echo "Project root path ${PROJECT_ROOT} is not valid; script may be in the wrong directory."
43+
exit 1
44+
fi
45+
46+
RUN_RAT="java -jar ${rat_jar} -E ${PROJECT_ROOT}/dev/.rat-excludes -d ${PROJECT_ROOT}"
47+
else
48+
EXTENSION='.tar.gz'
49+
# get unzipped directory
50+
PACKAGE_DIR="${SOURCE_PACKAGE:0:$((${#SOURCE_PACKAGE} - ${#EXTENSION}))}"
51+
tar -xf ${SOURCE_PACKAGE}
52+
53+
RUN_RAT="java -jar ${rat_jar} -e PKG-INFO -e setup.cfg -e pypaimon.egg-info/* -d ${PACKAGE_DIR}"
54+
fi
55+
56+
mkdir -p rat
57+
download_rat_jar
58+
59+
$RUN_RAT > rat/rat-results.txt
60+
61+
if [ $? -ne 0 ]; then
62+
echo "RAT exited abnormally"
63+
exit 1
64+
fi
65+
66+
ERRORS="$(cat rat/rat-results.txt | grep -e "??")"
67+
68+
# clean
69+
rm -rf rat
70+
if [ -d "$PACKAGE_DIR" ]; then
71+
rm -rf $PACKAGE_DIR
72+
fi
73+
74+
if [[ -n "${ERRORS}" ]]; then
75+
echo "Could not find Apache license headers in the following files:"
76+
echo ${ERRORS}
77+
exit 1
78+
else
79+
echo -e "RAT checks passed."
80+
fi

0 commit comments

Comments
 (0)