-
Notifications
You must be signed in to change notification settings - Fork 982
195 lines (161 loc) · 7.96 KB
/
new-module-verification.yml
File metadata and controls
195 lines (161 loc) · 7.96 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: New Module Verification
on:
merge_group:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
branches:
- master
- feature/master/*
permissions:
contents: read
jobs:
new-module-verification:
name: Verify New Modules
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for new module additions
id: check-new-modules
shell: bash
run: |
set -euo pipefail
echo "::group::Detecting new modules"
git fetch origin ${{ github.base_ref }} --depth 1
# Find new pom.xml files in the diff
NEW_POM_FILES=$(git diff --name-only remotes/origin/${{ github.base_ref }} | grep -E '.*pom\.xml$' | grep -v "target/" || echo "")
if [ -z "$NEW_POM_FILES" ]; then
echo "No new modules detected."
echo "new_modules_found=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "Potential new modules detected:"
echo "$NEW_POM_FILES"
echo "new_modules_found=true" >> $GITHUB_OUTPUT
# Save the list of new pom files for later steps
echo "$NEW_POM_FILES" > new_pom_files.txt
echo "::endgroup::"
- name: Verify new modules
if: steps.check-new-modules.outputs.new_modules_found == 'true'
shell: bash
run: |
set -euo pipefail
NEW_POM_FILES=$(cat new_pom_files.txt)
# Initialize counters and error flag
TEST_MODULES=0
NON_TEST_MODULES=0
HAS_ERRORS=0
echo "::group::Analyzing new modules"
for POM_FILE in $NEW_POM_FILES; do
MODULE_DIR=$(dirname "$POM_FILE")
MODULE_NAME=$(basename "$MODULE_DIR")
# Check if this is a new module (not just an updated pom.xml)
if git show remotes/origin/${{ github.base_ref }}:"$POM_FILE" &>/dev/null; then
echo "Skipping $POM_FILE - file already exists in base branch"
continue
fi
# Skip modules under services directory
if [[ "$MODULE_DIR" == services/* ]]; then
echo "Skipping $MODULE_DIR - modules under services/ are excluded from verification"
continue
fi
echo "New module detected: $MODULE_DIR"
# Check if it's a test module
if [[ "$MODULE_DIR" == *"/test/"* || "$MODULE_DIR" == *"/it/"* || "$MODULE_DIR" == *"-test"* || "$MODULE_DIR" == *"-tests"* ]]; then
echo "::group::Test module: $MODULE_DIR"
TEST_MODULES=$((TEST_MODULES + 1))
echo "Verifying test module requirements..."
# 1. Check if excluded from maven deploy command
if ! grep -q "$MODULE_NAME" buildspecs/release-to-maven.yml 2>/dev/null; then
echo "::error::Module $MODULE_NAME is not excluded from maven deploy command in buildspecs/release-to-maven.yml"
HAS_ERRORS=1
else
echo "✅ Module is excluded from maven deploy command"
fi
# 2. Check if excluded from javadoc generation
if ! grep -q "$MODULE_NAME" buildspecs/release-javadoc.yml 2>/dev/null; then
echo "::error::Module $MODULE_NAME is not excluded from javadoc generation in buildspecs/release-javadoc.yml"
HAS_ERRORS=1
else
echo "✅ Module is excluded from javadoc generation"
fi
# 3. Check if Brazil import is skipped
if ! grep -q "\"$MODULE_NAME\".*\"skip\".*true" .brazil.json 2>/dev/null; then
echo "::error::Module $MODULE_NAME is not configured to skip Brazil import in .brazil.json"
HAS_ERRORS=1
else
echo "✅ Brazil import is skipped for this module"
fi
echo "::endgroup::"
else
echo "::group::Non-test module: $MODULE_DIR"
NON_TEST_MODULES=$((NON_TEST_MODULES + 1))
echo "Verifying non-test module requirements..."
# 1. Check for Automatic-Module-Name in pom.xml
if ! grep -q "Automatic-Module-Name" "$POM_FILE" 2>/dev/null; then
echo "::error::Automatic-Module-Name is not specified in $POM_FILE"
HAS_ERRORS=1
else
echo "✅ Automatic-Module-Name is specified"
fi
# 2. Check if added to tests-coverage-reporting pom.xml
if ! grep -q "<module>.*$MODULE_NAME</module>" test/tests-coverage-reporting/pom.xml 2>/dev/null; then
echo "::error::Module $MODULE_NAME is not added to tests-coverage-reporting pom.xml"
HAS_ERRORS=1
else
echo "✅ Module is added to tests-coverage-reporting"
fi
# 3. Check if added to aws-sdk-java pom.xml
if ! grep -q "<module>.*$MODULE_NAME</module>" aws-sdk-java/pom.xml 2>/dev/null; then
echo "::error::Module $MODULE_NAME is not added to aws-sdk-java pom.xml"
HAS_ERRORS=1
else
echo "✅ Module is added to aws-sdk-java pom.xml"
fi
# 4. Check if added to architecture-tests pom.xml
if ! grep -q "<module>.*$MODULE_NAME</module>" test/architecture-tests/pom.xml 2>/dev/null; then
echo "::error::Module $MODULE_NAME is not added to architecture-tests pom.xml"
HAS_ERRORS=1
else
echo "✅ Module is added to architecture-tests pom.xml"
fi
# 5. Check if added to bom pom.xml
if ! grep -q "<artifactId>$MODULE_NAME</artifactId>" bom/pom.xml 2>/dev/null; then
echo "::error::Module $MODULE_NAME is not added to bom pom.xml"
HAS_ERRORS=1
else
echo "✅ Module is added to bom pom.xml"
fi
# 6. Check if japicmp plugin config is updated
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")
if [ "$JAPICMP_CHECK" = "MISSING" ]; then
echo "::error::Module $MODULE_NAME is not included in japicmp-maven-plugin includeModules section in pom.xml"
HAS_ERRORS=1
else
echo "✅ Module is included in japicmp-maven-plugin configuration"
fi
# 7. Check if package name mapping is added in .brazil.json
if ! grep -q "\"$MODULE_NAME\"" .brazil.json 2>/dev/null; then
echo "::error::Package name mapping for $MODULE_NAME is not added in .brazil.json"
HAS_ERRORS=1
else
echo "✅ Package name mapping is added in .brazil.json"
fi
echo "::endgroup::"
fi
done
echo "::endgroup::"
echo "::group::Verification summary"
echo "Verification complete."
echo "Test modules found: $TEST_MODULES"
echo "Non-test modules found: $NON_TEST_MODULES"
if [ $HAS_ERRORS -eq 1 ]; then
echo "::error::Some verification checks failed. Please review the errors above and fix them."
exit 1
else
echo "✅ All automated verification checks passed!"
fi
echo "::endgroup::"