-
Notifications
You must be signed in to change notification settings - Fork 100
147 lines (140 loc) · 4.69 KB
/
check-build.yml
File metadata and controls
147 lines (140 loc) · 4.69 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
# Check Build
#
# Description:
# Runs the build for every java version we support
#
# Triggers:
# - pull_request: when a PR is sent to us
# - push: when code is pushed to a specified branch
#
# Notes:
# Builds against Java 11, 17, and 21 which are the supported versions.
on:
workflow_dispatch:
pull_request:
paths:
- 'powertools-batch/**'
- 'powertools-core/**'
- 'powertools-cloudformation/**'
- 'powertools-common/**'
- 'powertools-e2e-tests/**'
- 'powertools-idempotency/**'
- 'powertools-large-messages/**'
- 'powertools-logging/**'
- 'powertools-metrics/**'
- 'powertools-kafka/**'
- 'powertools-parameters/**'
- 'powertools-serialization/**'
- 'powertools-sqs/**'
- 'powertools-tracing/**'
- 'powertools-tracing/**'
- 'powertools-validation/**'
- 'examples/**'
- 'pom.xml'
- 'examples/pom.xml'
- '.github/workflows/**'
push:
branches:
- main
paths:
- 'powertools-batch/**'
- 'powertools-core/**'
- 'powertools-cloudformation/**'
- 'powertools-common/**'
- 'powertools-e2e-tests/**'
- 'powertools-idempotency/**'
- 'powertools-large-messages/**'
- 'powertools-logging/**'
- 'powertools-metrics/**'
- 'powertools-kafka/**'
- 'powertools-parameters/**'
- 'powertools-serialization/**'
- 'powertools-sqs/**'
- 'powertools-tracing/**'
- 'powertools-tracing/**'
- 'powertools-validation/**'
- 'pom.xml'
- 'examples/**'
- 'examples/pom.xml'
- '.github/workflows/**'
name: Build
permissions:
contents: read
run-name: Build - ${{ github.event_name }}
jobs:
java-build:
runs-on: ubuntu-latest
strategy:
matrix:
java:
- 11
- 17
- 21
- 25
steps:
- id: checkout
name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654
with:
distribution: corretto
java-version: ${{ matrix.java }}
cache: maven
- id: build-maven
name: Build (Maven)
run: |
mvn -B -q install --file pom.xml
graalvm-build:
runs-on: aws-powertools_ubuntu-latest_8-core
steps:
- id: checkout
name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@e0021407031f5be11a464abee9a0776171c79891 # v47.0.1
with:
files: |
powertools-*/**
pom.xml
- name: Setup GraalVM
uses: graalvm/setup-graalvm@54b4f5a65c1a84b2fdfdc2078fe43df32819e4b1 # v1.4.5
with:
java-version: "21"
distribution: "graalvm"
cache: maven
- id: graalvm-native-test
name: GraalVM Native Test
if: steps.changed-files.outputs.any_changed == 'true'
env:
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
# Build the entire project first to ensure test-jar dependencies are available
echo "::group::Building project dependencies"
mvn -B -q install -DskipTests
echo "::endgroup::"
echo "Changes detected in powertools modules: $CHANGED_FILES"
# Find modules with graalvm-native profile and run tests
find . -name "pom.xml" -path "./powertools-*" | while read module; do
if grep -q "<id>graalvm-native</id>" "$module"; then
module_dir=$(dirname "$module")
module_name=$(basename "$module_dir")
# Check if this specific module or common dependencies changed
if echo "$CHANGED_FILES" | grep -q "$module_name/" || \
echo " $CHANGED_FILES " | grep -q " pom.xml " || \
echo "$CHANGED_FILES" | grep -q "powertools-common/"; then
echo "::group::Building $module_name with GraalVM"
echo "Changes detected in $module_name - running GraalVM tests"
echo "Regenerating GraalVM metadata for $module_dir"
mvn -B -q -f "$module" -Pgenerate-graalvm-files clean test
echo "Running GraalVM native tests for $module_dir"
mvn -B -q -f "$module" -Pgraalvm-native test
echo "::endgroup::"
else
echo "No changes detected in $module_name - skipping GraalVM tests"
fi
fi
done