-
Notifications
You must be signed in to change notification settings - Fork 5
120 lines (105 loc) · 3.39 KB
/
code-compliance.yml
File metadata and controls
120 lines (105 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Licensed 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: Code Compliance
on:
pull_request:
paths:
- 'extensions/**'
- 'pom.xml'
- 'checkstyle.xml'
- 'pmd-ruleset.xml'
push:
branches: [main]
paths:
- 'extensions/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
security-events: write
actions: read
env:
MAVEN_OPTS: >-
-Xmx4g
-Dorg.slf4j.simpleLogger.defaultLogLevel=WARN
jobs:
validate:
runs-on: ubuntu-latest
name: Checkstyle + PMD + RAT
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Java 21
uses: actions/setup-java@v5
with:
distribution: 'corretto'
java-version: '21'
cache: 'maven'
- name: Detect Changed Bundles
id: find-bundles
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
CHANGED_FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD)
else
CHANGED_FILES=$(git diff --name-only HEAD~1)
fi
BUNDLES=()
for file in $CHANGED_FILES; do
if [[ "$file" == extensions/* ]]; then
dir="$file"
while [[ "$dir" != "extensions" && "$dir" != "." ]]; do
if [[ -f "$dir/pom.xml" ]] && grep -q '<packaging>pom</packaging>' "$dir/pom.xml" 2>/dev/null; then
if grep -q '<modules>' "$dir/pom.xml" 2>/dev/null; then
BUNDLES+=("$dir")
break
fi
fi
dir=$(dirname "$dir")
done
fi
done
UNIQUE_BUNDLES=($(printf '%s\n' "${BUNDLES[@]}" | sort -u))
for bundle in "${UNIQUE_BUNDLES[@]}"; do
echo "Validating: $bundle"
./mvnw validate \
-Pcontrib-check \
-f "$bundle/pom.xml" \
--no-snapshot-updates \
--no-transfer-progress
done
codeql:
runs-on: ubuntu-latest
name: CodeQL Analysis
if: github.event_name == 'push' || github.event_name == 'pull_request'
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Set up Java 21
uses: actions/setup-java@v5
with:
distribution: 'corretto'
java-version: '21'
cache: 'maven'
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: java
- name: Build All Bundles
run: |
for pom in $(find extensions -name "pom.xml" -path "*-bundle/pom.xml"); do
./mvnw compile -DskipTests -f "$pom" --no-snapshot-updates --no-transfer-progress || true
done
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4