Skip to content

Commit 6d367ca

Browse files
committed
CI: add Apache RAT audit workflow for license checks
This commit introduces a new GitHub workflow that: - Runs Apache Rat to verify license compliance on all files - Executes automatically on PR submissions and merges to main branch - Uploads check results as artifacts for debugging purposes - Provides a clear job summary with appropriate status indicators This workflow can help us ensure all files comply with ASF requirements, catching potential licensing issues before they're merged into the codebase.
1 parent 8b563fb commit 6d367ca

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

.asf.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ github:
8585
# Actions workflows. They do not include the workflow name as a
8686
# prefix
8787
contexts:
88+
- rat-check
8889
- check-skip
8990
- Build Apache Cloudberry RPM
9091
- RPM Install Test Apache Cloudberry
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# --------------------------------------------------------------------
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed
5+
# with this work for additional information regarding copyright
6+
# ownership. The ASF licenses this file to You under the Apache
7+
# License, Version 2.0 (the "License"); you may not use this file
8+
# except in compliance with the License. You may obtain a copy of the
9+
# 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
16+
# implied. See the License for the specific language governing
17+
# permissions and limitations under the License.
18+
#
19+
# --------------------------------------------------------------------
20+
# Apache Rat Audit Workflow
21+
# Checks if all files comply with Apache licensing requirements
22+
# This workflow is based on the Apache Rat tool, you can run it locally
23+
# using the command: `mvn clean verify -Drat.consoleOutput=true`
24+
# --------------------------------------------------------------------
25+
26+
name: Apache Rat Audit
27+
28+
on:
29+
push:
30+
branches: [main]
31+
pull_request:
32+
branches: [main]
33+
types: [opened, synchronize, reopened, edited]
34+
workflow_dispatch:
35+
36+
permissions:
37+
contents: read
38+
39+
concurrency:
40+
group: ${{ github.workflow }}-${{ github.ref }}
41+
cancel-in-progress: true
42+
43+
jobs:
44+
rat-check:
45+
name: Apache Rat License Check
46+
runs-on: ubuntu-latest
47+
timeout-minutes: 10
48+
49+
steps:
50+
- name: Check out repository
51+
uses: actions/checkout@v4
52+
with:
53+
fetch-depth: 1
54+
55+
- name: Set up Java and Maven
56+
uses: actions/setup-java@v3
57+
with:
58+
distribution: 'temurin'
59+
java-version: '11'
60+
cache: maven
61+
62+
- name: Run Apache Rat check
63+
id: rat-check
64+
run: |
65+
echo "Running Apache Rat license check..."
66+
mvn clean verify -Drat.consoleOutput=true | tee rat-output.log
67+
68+
# Check for build failure
69+
if grep -q "\[INFO\] BUILD FAILURE" rat-output.log; then
70+
echo "rat_failed=true" >> $GITHUB_OUTPUT
71+
echo "::error::Apache Rat check failed - build failure detected"
72+
exit 1
73+
fi
74+
75+
# If we got here, the check passed
76+
echo "rat_failed=false" >> $GITHUB_OUTPUT
77+
echo "Apache Rat check passed successfully"
78+
79+
- name: Upload Rat check results
80+
if: always()
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: rat-check-results
84+
path: rat-output.log
85+
retention-days: 7
86+
87+
- name: Generate Job Summary
88+
if: always()
89+
run: |
90+
{
91+
echo "## Apache Rat Audit Results"
92+
echo "- Run Time: $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
93+
94+
if [[ -f rat-output.log ]]; then
95+
if grep -q "\[INFO\] BUILD FAILURE" rat-output.log; then
96+
echo "### ❌ Check Failed - License Compliance Issues Detected"
97+
echo "```"
98+
grep -B 5 -A 20 "\[INFO\] BUILD FAILURE" rat-output.log
99+
echo "```"
100+
elif grep -q "\[INFO\] BUILD SUCCESS" rat-output.log; then
101+
echo "### ✅ Check Passed - All Files Comply with Apache License Requirements"
102+
else
103+
echo "### ⚠️ Indeterminate result - check log for details"
104+
fi
105+
else
106+
echo "### ⚠️ No output log found"
107+
fi
108+
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)