This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/arrow-flight-sql-postgresql.git
The following commit(s) were added to refs/heads/main by this push:
new 93cb3da [CI] Add Rat (Release Audit Tool) job (#9)
93cb3da is described below
commit 93cb3da6e4e9086257f1b72819e02b60903c4d60
Author: Sutou Kouhei <[email protected]>
AuthorDate: Mon Feb 6 16:35:53 2023 +0900
[CI] Add Rat (Release Audit Tool) job (#9)
Close GH-7
---
.gitignore => .github/workflows/lint.yaml | 25 ++++++++++-
.gitignore | 4 ++
dev/release/check_rat_report.py | 59 +++++++++++++++++++++++++
.gitignore => dev/release/rat_exclude_files.txt | 6 ++-
dev/release/run_rat.sh | 51 +++++++++++++++++++++
5 files changed, 141 insertions(+), 4 deletions(-)
diff --git a/.gitignore b/.github/workflows/lint.yaml
similarity index 63%
copy from .gitignore
copy to .github/workflows/lint.yaml
index cfe2131..48f6b0e 100644
--- a/.gitignore
+++ b/.github/workflows/lint.yaml
@@ -15,5 +15,26 @@
# specific language governing permissions and limitations
# under the License.
-/.cache/
-/compile_commands.json
+name: Lint
+on:
+ pull_request:
+ push:
+
+concurrency:
+ group: ${{ github.head_ref || github.sha }}-${{ github.workflow }}
+ cancel-in-progress: true
+
+permissions:
+ contents: read
+
+jobs:
+ license:
+ name: Audit licenses
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-python@v4
+ with:
+ python-version: '3.x'
+ - name: Run Release audit tool (Rat)
+ run: dev/release/run_rat.sh .
diff --git a/.gitignore b/.gitignore
index cfe2131..ad54b98 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,7 @@
/.cache/
/compile_commands.json
+/dev/release/apache-rat-0.13.jar
+/dev/release/dist
+/dev/release/filtered_rat.txt
+/dev/release/rat.xml
diff --git a/dev/release/check_rat_report.py b/dev/release/check_rat_report.py
new file mode 100755
index 0000000..c45baa0
--- /dev/null
+++ b/dev/release/check_rat_report.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python3
+#
+# 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.
+
+import fnmatch
+import re
+import sys
+import xml.etree.ElementTree as ET
+
+if len(sys.argv) != 3:
+ sys.stderr.write("Usage: %s exclude_globs.lst rat_report.xml\n" %
+ sys.argv[0])
+ sys.exit(1)
+
+exclude_globs_filename = sys.argv[1]
+xml_filename = sys.argv[2]
+
+globs = [line.strip() for line in open(exclude_globs_filename, "r")]
+
+tree = ET.parse(xml_filename)
+root = tree.getroot()
+resources = root.findall('resource')
+
+all_ok = True
+for r in resources:
+ approvals = r.findall('license-approval')
+ if not approvals or approvals[0].attrib['name'] == 'true':
+ continue
+ clean_name = re.sub('^[^/]+/', '', r.attrib['name'])
+ excluded = False
+ for g in globs:
+ if fnmatch.fnmatch(clean_name, g):
+ excluded = True
+ break
+ if not excluded:
+ sys.stdout.write("NOT APPROVED: %s (%s): %s\n" % (
+ clean_name, r.attrib['name'], approvals[0].attrib['name']))
+ all_ok = False
+
+if not all_ok:
+ sys.exit(1)
+
+print('OK')
+sys.exit(0)
diff --git a/.gitignore b/dev/release/rat_exclude_files.txt
similarity index 88%
copy from .gitignore
copy to dev/release/rat_exclude_files.txt
index cfe2131..bf47194 100644
--- a/.gitignore
+++ b/dev/release/rat_exclude_files.txt
@@ -15,5 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-/.cache/
-/compile_commands.json
+compile_commands.json
+dev/release/apache-rat-*.jar
+dev/release/filtered_rat.txt
+dev/release/rat.xml
diff --git a/dev/release/run_rat.sh b/dev/release/run_rat.sh
new file mode 100755
index 0000000..07c6552
--- /dev/null
+++ b/dev/release/run_rat.sh
@@ -0,0 +1,51 @@
+#!/bin/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.
+
+set -eu
+
+RELEASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+RAT_VERSION=0.13
+
+RAT_JAR="${RELEASE_DIR}/apache-rat-${RAT_VERSION}.jar"
+if [ ! -f "${RAT_JAR}" ]; then
+ curl \
+ --fail \
+ --output "${RAT_JAR}" \
+ --show-error \
+ --silent \
+
https://repo1.maven.org/maven2/org/apache/rat/apache-rat/${RAT_VERSION}/apache-rat-${RAT_VERSION}.jar
+fi
+
+RAT="java -jar ${RAT_JAR} -x "
+RAT_XML="${RELEASE_DIR}/rat.xml"
+$RAT $1 > "${RAT_XML}"
+FILTERED_RAT_TXT="${RELEASE_DIR}/filtered_rat.txt"
+if ${PYTHON:-python3} \
+ "${RELEASE_DIR}/check_rat_report.py" \
+ "${RELEASE_DIR}/rat_exclude_files.txt" \
+ "${RAT_XML}" > \
+ "${FILTERED_RAT_TXT}"; then
+ echo "No unapproved licenses"
+else
+ cat "${FILTERED_RAT_TXT}"
+ N_UNAPPROVED=$(grep "NOT APPROVED" "${FILTERED_RAT_TXT}" | wc -l)
+ echo "${N_UNAPPROVED} unapproved licenses. Check Rat report: ${RAT_XML}"
+ exit 1
+fi