Skip to content

Commit e58ae12

Browse files
authored
Add new module verification CI (#6173)
* Add new module verification * Add new module verification
1 parent f1d5362 commit e58ae12

File tree

1 file changed

+191
-0
lines changed

1 file changed

+191
-0
lines changed
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
name: New Module Verification
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, labeled, unlabeled]
6+
branches:
7+
- master
8+
- feature/master/*
9+
paths:
10+
- '**/*.xml'
11+
- '.brazil.json'
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
new-module-verification:
18+
name: Verify New Modules
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 10
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Check for new module additions
29+
id: check-new-modules
30+
shell: bash
31+
run: |
32+
set -euo pipefail
33+
34+
echo "::group::Detecting new modules"
35+
git fetch origin ${{ github.base_ref }} --depth 1
36+
37+
# Find new pom.xml files in the diff
38+
NEW_POM_FILES=$(git diff --name-only remotes/origin/${{ github.base_ref }} | grep -E '.*pom\.xml$' | grep -v "target/" || echo "")
39+
40+
if [ -z "$NEW_POM_FILES" ]; then
41+
echo "No new modules detected."
42+
echo "new_modules_found=false" >> $GITHUB_OUTPUT
43+
exit 0
44+
fi
45+
46+
echo "Potential new modules detected:"
47+
echo "$NEW_POM_FILES"
48+
echo "new_modules_found=true" >> $GITHUB_OUTPUT
49+
50+
# Save the list of new pom files for later steps
51+
echo "$NEW_POM_FILES" > new_pom_files.txt
52+
echo "::endgroup::"
53+
54+
- name: Verify new modules
55+
if: steps.check-new-modules.outputs.new_modules_found == 'true'
56+
shell: bash
57+
run: |
58+
set -euo pipefail
59+
60+
NEW_POM_FILES=$(cat new_pom_files.txt)
61+
62+
# Initialize counters and error flag
63+
TEST_MODULES=0
64+
NON_TEST_MODULES=0
65+
HAS_ERRORS=0
66+
67+
echo "::group::Analyzing new modules"
68+
69+
for POM_FILE in $NEW_POM_FILES; do
70+
MODULE_DIR=$(dirname "$POM_FILE")
71+
MODULE_NAME=$(basename "$MODULE_DIR")
72+
73+
# Check if this is a new module (not just an updated pom.xml)
74+
if git show remotes/origin/${{ github.base_ref }}:"$POM_FILE" &>/dev/null; then
75+
echo "Skipping $POM_FILE - file already exists in base branch"
76+
continue
77+
fi
78+
79+
echo "New module detected: $MODULE_DIR"
80+
81+
# Check if it's a test module
82+
if [[ "$MODULE_DIR" == *"/test/"* || "$MODULE_DIR" == *"/it/"* || "$MODULE_DIR" == *"-test"* || "$MODULE_DIR" == *"-tests"* ]]; then
83+
echo "::group::Test module: $MODULE_DIR"
84+
TEST_MODULES=$((TEST_MODULES + 1))
85+
86+
echo "Verifying test module requirements..."
87+
88+
# 1. Check if excluded from maven deploy command
89+
if ! grep -q "$MODULE_NAME" buildspecs/release-to-maven.yml 2>/dev/null; then
90+
echo "::error::Module $MODULE_NAME is not excluded from maven deploy command in buildspecs/release-to-maven.yml"
91+
HAS_ERRORS=1
92+
else
93+
echo "✅ Module is excluded from maven deploy command"
94+
fi
95+
96+
# 2. Check if excluded from javadoc generation
97+
if ! grep -q "$MODULE_NAME" buildspecs/release-javadoc.yml 2>/dev/null; then
98+
echo "::error::Module $MODULE_NAME is not excluded from javadoc generation in buildspecs/release-javadoc.yml"
99+
HAS_ERRORS=1
100+
else
101+
echo "✅ Module is excluded from javadoc generation"
102+
fi
103+
104+
# 3. Check if Brazil import is skipped
105+
if ! grep -q "\"$MODULE_NAME\".*\"skip\".*true" .brazil.json 2>/dev/null; then
106+
echo "::error::Module $MODULE_NAME is not configured to skip Brazil import in .brazil.json"
107+
HAS_ERRORS=1
108+
else
109+
echo "✅ Brazil import is skipped for this module"
110+
fi
111+
echo "::endgroup::"
112+
113+
else
114+
echo "::group::Non-test module: $MODULE_DIR"
115+
NON_TEST_MODULES=$((NON_TEST_MODULES + 1))
116+
117+
echo "Verifying non-test module requirements..."
118+
119+
# 1. Check for Automatic-Module-Name in pom.xml
120+
if ! grep -q "Automatic-Module-Name" "$POM_FILE" 2>/dev/null; then
121+
echo "::error::Automatic-Module-Name is not specified in $POM_FILE"
122+
HAS_ERRORS=1
123+
else
124+
echo "✅ Automatic-Module-Name is specified"
125+
fi
126+
127+
# 2. Check if added to tests-coverage-reporting pom.xml
128+
if ! grep -q "<module>.*$MODULE_NAME</module>" test/tests-coverage-reporting/pom.xml 2>/dev/null; then
129+
echo "::error::Module $MODULE_NAME is not added to tests-coverage-reporting pom.xml"
130+
HAS_ERRORS=1
131+
else
132+
echo "✅ Module is added to tests-coverage-reporting"
133+
fi
134+
135+
# 3. Check if added to aws-sdk-java pom.xml
136+
if ! grep -q "<module>.*$MODULE_NAME</module>" aws-sdk-java/pom.xml 2>/dev/null; then
137+
echo "::error::Module $MODULE_NAME is not added to aws-sdk-java pom.xml"
138+
HAS_ERRORS=1
139+
else
140+
echo "✅ Module is added to aws-sdk-java pom.xml"
141+
fi
142+
143+
# 4. Check if added to architecture-tests pom.xml
144+
if ! grep -q "<module>.*$MODULE_NAME</module>" test/architecture-tests/pom.xml 2>/dev/null; then
145+
echo "::error::Module $MODULE_NAME is not added to architecture-tests pom.xml"
146+
HAS_ERRORS=1
147+
else
148+
echo "✅ Module is added to architecture-tests pom.xml"
149+
fi
150+
151+
# 5. Check if added to bom pom.xml
152+
if ! grep -q "<artifactId>$MODULE_NAME</artifactId>" bom/pom.xml 2>/dev/null; then
153+
echo "::error::Module $MODULE_NAME is not added to bom pom.xml"
154+
HAS_ERRORS=1
155+
else
156+
echo "✅ Module is added to bom pom.xml"
157+
fi
158+
159+
# 6. Check if japicmp plugin config is updated
160+
JAPICMP_CHECK=$(grep -A 50 "<artifactId>japicmp-maven-plugin</artifactId>" pom.xml 2>/dev/null | grep -A 50 "<includeModules>" 2>/dev/null | grep -q "<includeModule>$MODULE_NAME</includeModule>" 2>/dev/null || echo "MISSING")
161+
if [ "$JAPICMP_CHECK" = "MISSING" ]; then
162+
echo "::error::Module $MODULE_NAME is not included in japicmp-maven-plugin includeModules section in pom.xml"
163+
HAS_ERRORS=1
164+
else
165+
echo "✅ Module is included in japicmp-maven-plugin configuration"
166+
fi
167+
168+
# 7. Check if package name mapping is added in .brazil.json
169+
if ! grep -q "\"$MODULE_NAME\"" .brazil.json 2>/dev/null; then
170+
echo "::error::Package name mapping for $MODULE_NAME is not added in .brazil.json"
171+
HAS_ERRORS=1
172+
else
173+
echo "✅ Package name mapping is added in .brazil.json"
174+
fi
175+
echo "::endgroup::"
176+
fi
177+
done
178+
echo "::endgroup::"
179+
180+
echo "::group::Verification summary"
181+
echo "Verification complete."
182+
echo "Test modules found: $TEST_MODULES"
183+
echo "Non-test modules found: $NON_TEST_MODULES"
184+
185+
if [ $HAS_ERRORS -eq 1 ]; then
186+
echo "::error::Some verification checks failed. Please review the errors above and fix them."
187+
exit 1
188+
else
189+
echo "✅ All automated verification checks passed!"
190+
fi
191+
echo "::endgroup::"

0 commit comments

Comments
 (0)