-
Notifications
You must be signed in to change notification settings - Fork 7
229 lines (194 loc) · 7.23 KB
/
workflow-validation.yml
File metadata and controls
229 lines (194 loc) · 7.23 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
---
name: Workflow Validation
on:
workflow_dispatch:
inputs:
test_type:
description: 'Type of validation test to run'
required: true
default: 'all'
type: choice
options:
- all
- matrix-builds
- artifact-generation
- deployment-test
java_versions:
description: 'Java versions to test (comma-separated)'
required: false
default: '21,22,23'
type: string
env:
MAVEN_OPTS: >-
-Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false
-Dmaven.wagon.http.retryHandler.class=standard
-Dmaven.wagon.http.retryHandler.count=3
MAVEN_SETTINGS: ${{ github.workspace }}/settings.xml
jobs:
validation-setup:
name: Validation Setup
runs-on: ubuntu-latest
outputs:
java-versions: ${{ steps.setup.outputs.java-versions }}
test-matrix-builds: ${{ steps.setup.outputs.test-matrix-builds }}
test-artifact-generation: >-
${{ steps.setup.outputs.test-artifact-generation }}
test-deployment: ${{ steps.setup.outputs.test-deployment }}
steps:
- name: Setup test configuration
id: setup
run: |
# Parse Java versions
JAVA_VERSIONS="${{ github.event.inputs.java_versions || '21,22,23' }}"
JAVA_ARRAY=$(echo $JAVA_VERSIONS | jq -R -s -c \
'split(",") | map(select(length > 0))')
echo "java-versions=$JAVA_ARRAY" >> $GITHUB_OUTPUT
# Determine which tests to run
TEST_TYPE="${{ github.event.inputs.test_type || 'all' }}"
if [[ "$TEST_TYPE" == "all" || "$TEST_TYPE" == "matrix-builds" ]]; then
echo "test-matrix-builds=true" >> $GITHUB_OUTPUT
else
echo "test-matrix-builds=false" >> $GITHUB_OUTPUT
fi
if [[ "$TEST_TYPE" == "all" || "$TEST_TYPE" == "artifact-generation" ]]; then
echo "test-artifact-generation=true" >> $GITHUB_OUTPUT
else
echo "test-artifact-generation=false" >> $GITHUB_OUTPUT
fi
if [[ "$TEST_TYPE" == "all" || "$TEST_TYPE" == "deployment-test" ]]; then
echo "test-deployment=true" >> $GITHUB_OUTPUT
else
echo "test-deployment=false" >> $GITHUB_OUTPUT
fi
echo "Configuration:"
echo "- Java versions: $JAVA_ARRAY"
matrix-build-validation:
name: Matrix Build Validation (Java ${{ matrix.java-version }})
runs-on: ubuntu-latest
needs: validation-setup
if: needs.validation-setup.outputs.test-matrix-builds == 'true'
strategy:
matrix:
java-version: ${{ fromJson(needs.validation-setup.outputs.java-versions) }}
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: >-
validation-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
validation-${{ runner.os }}-maven-
- name: Validate Maven project
run: |
echo "=== Validating project with Java ${{ matrix.java-version }} ==="
mvn validate -s settings.xml
- name: Compile project
run: |
echo "=== Compiling project with Java ${{ matrix.java-version }} ==="
mvn clean compile -s settings.xml
- name: Run unit tests
run: |
echo "=== Running unit tests with Java ${{ matrix.java-version }} ==="
mvn test -s settings.xml
- name: Upload validation results
uses: actions/upload-artifact@v4
if: always()
with:
name: matrix-validation-java-${{ matrix.java-version }}
path: |
target/surefire-reports/
target/baseline-results/
retention-days: 7
artifact-generation-validation:
name: Artifact Generation Validation
runs-on: ubuntu-latest
needs: validation-setup
if: needs.validation-setup.outputs.test-artifact-generation == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: >-
validation-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
validation-${{ runner.os }}-maven-
- name: Build and package
run: |
echo "=== Building and packaging project ==="
mvn clean package -DskipTests -s settings.xml
- name: Validate main JAR artifact
run: |
echo "=== Validating main JAR artifact ==="
# Check if main JAR exists
if [ ! -f "target/javamail4ews.jar" ]; then
echo "ERROR: Main JAR file not found"
exit 1
fi
# Check JAR size (should be reasonable)
JAR_SIZE=$(stat -f%z target/javamail4ews.jar 2>/dev/null || \
stat -c%s target/javamail4ews.jar)
echo "Main JAR size: $JAR_SIZE bytes"
if [ $JAR_SIZE -lt 1000 ]; then
echo "ERROR: JAR file seems too small"
exit 1
fi
echo "SUCCESS: Main JAR validation passed"
- name: Upload artifact validation results
uses: actions/upload-artifact@v4
with:
name: artifact-validation-results
path: |
target/javamail4ews.jar
target/lib/
retention-days: 7
validation-summary:
name: Validation Summary
runs-on: ubuntu-latest
needs: [validation-setup, matrix-build-validation, artifact-generation-validation]
if: always()
steps:
- name: Generate validation report
run: |
echo "# GitHub Actions Workflow Validation Report" > validation-report.md
echo "" >> validation-report.md
echo "**Validation Date:** $(date)" >> validation-report.md
echo "**Test Type:** ${{ github.event.inputs.test_type || 'all' }}" \
>> validation-report.md
echo "" >> validation-report.md
echo "## Test Results" >> validation-report.md
echo "" >> validation-report.md
# Matrix build validation
if [ "${{ needs.validation-setup.outputs.test-matrix-builds }}" == "true" ]; then
if [ "${{ needs.matrix-build-validation.result }}" == "success" ]; then
echo "✅ **Matrix Build Validation:** PASSED" >> validation-report.md
else
echo "❌ **Matrix Build Validation:** FAILED" >> validation-report.md
fi
else
echo "⏭️ **Matrix Build Validation:** SKIPPED" >> validation-report.md
fi
echo "Validation report generated:"
cat validation-report.md
- name: Upload validation report
uses: actions/upload-artifact@v4
with:
name: validation-report
path: validation-report.md
retention-days: 30