Skip to content

Commit b0916ec

Browse files
author
yuzelin
committed
Add license checker
1 parent 7f6a1d4 commit b0916ec

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed

.github/workflows/check-licensing.yml

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: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
printf "Attempting to fetch rat\n"
26+
wget --quiet ${URL} -O "$JAR"
27+
}
28+
29+
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
30+
PROJECT_ROOT="${BASE_DIR}/../"
31+
32+
cd ${PROJECT_ROOT}
33+
34+
mkdir -p ${PROJECT_ROOT}/rat
35+
export RAT_VERSION=0.15
36+
export rat_jar=${PROJECT_ROOT}/rat/apache-rat-${RAT_VERSION}.jar
37+
38+
download_rat_jar
39+
40+
java -jar ${rat_jar} -E ${PROJECT_ROOT}/dev/.rat-excludes -d ${PROJECT_ROOT} > rat/rat-results.txt
41+
42+
if [ $? -ne 0 ]; then
43+
echo "RAT exited abnormally"
44+
exit 1
45+
fi
46+
47+
ERRORS="$(cat rat/rat-results.txt | grep -e "??")"
48+
49+
if [[ -n "${ERRORS}" ]]; then
50+
echo "Could not find Apache license headers in the following files:"
51+
echo ${ERRORS}
52+
exit 1
53+
else
54+
echo -e "RAT checks passed."
55+
fi

0 commit comments

Comments
 (0)