Skip to content

Commit 688db72

Browse files
authored
feat: POC of jbang native image compiled (jbangdev#2262)
1 parent 42df95d commit 688db72

File tree

15 files changed

+2324
-230
lines changed

15 files changed

+2324
-230
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Shared Build Setup
2+
description: Setup the build environment for the shared build commands
3+
runs:
4+
using: 'composite'
5+
steps:
6+
- uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4
7+
with:
8+
java-version: 11
9+
distribution: temurin
10+
cache: gradle
11+
- name: setup-gradle
12+
uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 # v4
13+
- name: gradle-wrapper-validation
14+
uses: gradle/actions/wrapper-validation@06832c7b30a0129d7fb559bcc6e43d26f6374244 # v4
15+
- name: Setup tmate session
16+
uses: mxschmitt/action-tmate@7b6a61a73bbb9793cb80ad69b8dd8ac19261834c # v3
17+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
18+
with:
19+
limit-access-to-actor: true
20+
detached: ${{ github.event.inputs.debug_detached }}

.github/workflows/ci-build.yml

Lines changed: 143 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ on:
2020
default: true
2121

2222
jobs:
23-
updatewebsite:
23+
updatewebsite: ## TODO: move to its own workflow just for push to main (or even tags))
2424
runs-on: ubuntu-latest
2525
steps:
2626
- name: Checkout code
@@ -42,69 +42,108 @@ jobs:
4242
workflow: github-pages
4343
repo: jbangdev/jbang.dev
4444
token: ${{ secrets.BREW_GITHUB_TOKEN }}
45-
build:
46-
runs-on: ${{ matrix.os }}
47-
strategy:
48-
matrix:
49-
os: [ubuntu-latest, windows-latest]
50-
name: build-and-testing
45+
format-check:
46+
runs-on: ubuntu-latest
5147
steps:
52-
- name: Rate limit info
53-
run: 'curl -H "Accept: application/vnd.github+json" https://api.github.com/rate_limit'
54-
- name: Setup tmate session
55-
uses: mxschmitt/action-tmate@7b6a61a73bbb9793cb80ad69b8dd8ac19261834c # v3
56-
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
57-
with:
58-
limit-access-to-actor: true
59-
detached: ${{ github.event.inputs.debug_detached }}
6048
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
61-
- uses: gradle/actions/wrapper-validation@06832c7b30a0129d7fb559bcc6e43d26f6374244 # v4
62-
- name: install-java11
63-
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4
64-
with:
65-
java-version: 11
66-
distribution: temurin
67-
cache: gradle
68-
- name: setup-gradle
69-
uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 # v4
70-
49+
- uses: ./.github/actions/shared-build-setup
7150
- name: check formatting and comment on PR if failed
7251
id: check-formatting
7352
run: ./gradlew spotlessCheck
7453

75-
- name: build-gradle
76-
run: ./gradlew --no-daemon clean build installDist publish --build-cache --scan -s
77-
- name: integration-test
54+
build-shared:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
58+
- uses: ./.github/actions/shared-build-setup
59+
- name: build-with-no-tests
60+
run: ./gradlew --no-daemon clean build installDist publish -x test -x integrationTest --build-cache --scan -s
61+
- name: Upload jbang.zip
62+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
63+
if: always()
64+
with:
65+
name: build-shared-jbang-${{ github.sha }}
66+
path: build/install/jbang
67+
- name: Upload build results
68+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
69+
if: always()
70+
with:
71+
name: build-shared-build-${{ github.sha }}
72+
path: build
73+
74+
build-native-image:
75+
needs: build-shared
76+
strategy:
77+
fail-fast: false
78+
matrix:
79+
os: &os_matrix [ubuntu-latest,windows-latest,macos-latest]
80+
runs-on: ${{ matrix.os }}
81+
steps:
82+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
83+
- uses: ./.github/actions/shared-build-setup
84+
- name: setup-graalvm
85+
uses: graalvm/setup-graalvm@v1
86+
with:
87+
java-version: '25'
88+
distribution: 'graalvm-community' # like to use mandrel but using community for now
89+
github-token: ${{ secrets.GITHUB_TOKEN }}
90+
set-java-home: false # we should not use graalvm for java builds (we need java 11)
91+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
92+
with:
93+
name: build-shared-build-${{ github.sha }}
94+
path: build
95+
96+
- name: build-native-image
7897
run: |
79-
./gradlew integrationTest
80-
- name: integration-test-non-windows
81-
if: runner.os != 'Windows'
98+
./gradlew --no-daemon nativeImage
99+
- name: upload-native-image
100+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
101+
with:
102+
name: build-native-image-jbang.bin-${{ matrix.os }}
103+
path: build/native-image/*
104+
if-no-files-found: error
105+
106+
testing:
107+
needs: build-shared
108+
runs-on: ${{ matrix.os }}
109+
strategy:
110+
matrix:
111+
os: *os_matrix
112+
name: tests
113+
steps:
114+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 #
115+
- uses: ./.github/actions/shared-build-setup
116+
117+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
118+
with:
119+
name: build-shared-build-${{ github.sha }}
120+
path: build
121+
- name: test
82122
run: |
83-
export PATH=`pwd`/build/install/jbang/bin:$PATH
84-
cd itests
85-
./test_suite.sh
86-
- name: add-to-path
87-
run: echo "../build/install/jbang/bin" >> $env:GITHUB_PATH
123+
./gradlew --no-daemon test
124+
- name: integration-test
125+
run: |
126+
./gradlew --no-daemon integrationTest
88127
- name: codecoverage-report
89128
run: |
90129
./gradlew --no-daemon jacocoTestReport
91130
- name: allure report
92131
if: always() # always run even if the previous step fails
93132
run: |
94-
./gradlew allureReport --clean
133+
./gradlew --no-daemon allureReport --clean
95134
- name: Upload Allure Test Report
96135
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
97136
if: always() # always run even if the previous step fails
98137
with:
99-
name: allure-report-${{ matrix.os }}
100-
path: '**/build/reports/allure-report/allureReport/index.html'
138+
name: testing-allure-report-${{ matrix.os }}
139+
path: 'build/reports/allure-report/allureReport/index.html'
101140
retention-days: 7
102141
- name: Upload Test Report for pr marking
103142
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
104143
if: always() # always run even if the previous step fails
105144
with:
106-
name: junit-test-results-${{ matrix.os }}
107-
path: '**/build/test-results/test/TEST-*.xml'
145+
name: testing-junit-test-results-${{ matrix.os }}
146+
path: 'build/test-results/test/TEST-*.xml'
108147
retention-days: 1
109148
- uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5
110149
with:
@@ -126,64 +165,102 @@ jobs:
126165
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
127166
if: always()
128167
with:
129-
name: ${{ runner.os }}-build-${{ github.sha }}
168+
name: testing-build-${{ runner.os }}-${{ github.sha }}
130169
path: build
131-
- name: Upload jbang.zip
132-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
133-
if: always() && runner.os != 'Windows'
134-
with:
135-
name: jbang-${{ github.sha }}
136-
path: build/install/jbang
137170
- name: Write out Unit Test report annotation for forked repo
138171
if: always()
139172
uses: mikepenz/action-junit-report@3585e9575db828022551b4231f165eb59a0e74e3 # v5
140173
with:
141-
report_paths: '**/build/test-results/test/TEST-*.xml'
174+
report_paths: 'build/test-results/test/TEST-*.xml'
142175
annotate_only: true # forked repo cannot write to checks so just do annotations
143176
- name: Add artifact.ci links
144177
if: always()
145178
run: |
146179
echo "View [Allure Report](https://www.artifact.ci/artifact/view/${{ github.repository }}/run/${{ github.run_id }}.${{ github.run_attempt}}/allure-report-${{ matrix.os }}) [direct link (available after first view)](https://www.artifact.ci/artifact/view/${{ github.repository }}/run/${{ github.run_id }}.${{ github.run_attempt}}/allure-report-${{ matrix.os }}/build/reports/allure-report/allureReport/index.html) for ${{ matrix.os }} build" >> $GITHUB_STEP_SUMMARY
180+
181+
test-native-image:
182+
needs: build-native-image
183+
strategy:
184+
fail-fast: false
185+
matrix:
186+
os: *os_matrix
187+
runs-on: ${{ matrix.os }}
188+
steps:
189+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
190+
- uses: ./.github/actions/shared-build-setup
191+
- name: download shared build
192+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
193+
with:
194+
name: build-shared-build-${{ github.sha }}
195+
path: build
147196

148-
149-
testing:
150-
needs: build
197+
- name: download jbang.bin
198+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
199+
with:
200+
name: build-native-image-jbang.bin-${{ matrix.os }}
201+
path: build/native-image
202+
- name: create install with jbang.bin
203+
run: |
204+
./gradlew --no-daemon installDist
205+
- name: integration-test-native-image
206+
env:
207+
JBANG_USE_NATIVE: true
208+
run: |
209+
./gradlew --no-daemon integrationTest
210+
- name: codecoverage-report
211+
run: |
212+
./gradlew --no-daemon jacocoTestReport
213+
- name: allure report
214+
if: always() # always run even if the previous step fails
215+
run: |
216+
./gradlew allureReport --clean
217+
- name: Upload Allure Test Report
218+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
219+
if: always() # always run even if the previous step fails
220+
with:
221+
name: test-native-image-allure-report-${{ matrix.os }}
222+
path: 'build/reports/allure-report/allureReport/index.html'
223+
retention-days: 7
224+
225+
smoke-test:
226+
needs: build-shared
151227
strategy:
152228
## disable fail-fast so on variance failing don't fail the rest
153229
#fail-fast: false
154230
matrix:
155231
os: [ubuntu-latest]
156232
java: [8,11,17,21]
157233
runs-on: ${{ matrix.os }}
234+
env:
235+
GRADLE_ACTIONS_SKIP_BUILD_RESULT_CAPTURE: true
236+
_JBANG_: ./build/install/jbang/bin/jbang
158237
steps:
159-
- uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4
160-
with:
161-
distribution: 'temurin'
162-
java-version: ${{ matrix.java }}
238+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
239+
- uses: ./.github/actions/shared-build-setup
163240
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
164241
with:
165-
name: ${{ runner.os }}-build-${{ github.sha }}
242+
name: build-shared-build-${{ github.sha }}
166243
path: build
167244
- name: smoke-test
168245
run: |
169246
java -version
170-
chmod +x ./build/install/jbang/bin/jbang
171-
./build/install/jbang/bin/jbang init --template=cli helloworld.java
172-
./build/install/jbang/bin/jbang --verbose helloworld.java
247+
chmod +x $_JBANG_
248+
$_JBANG_ init --template=cli helloworld.java
249+
$_JBANG_ --verbose helloworld.java
173250
rm helloworld.java
174251
- name: smoke-quarkus-test
175252
run: |
176253
java -version
177-
chmod +x ./build/install/jbang/bin/jbang
178-
./build/install/jbang/bin/jbang init --template=qcli qcli.java
179-
./build/install/jbang/bin/jbang --fresh --verbose qcli.java
254+
chmod +x $_JBANG_
255+
$_JBANG_ init --template=qcli qcli.java
256+
$_JBANG_ --fresh --verbose qcli.java
180257
rm qcli.java
181258
- name: smoke-quarkus-diff-version-test
182259
run: |
183260
java -version
184-
chmod +x ./build/install/jbang/bin/jbang
185-
./build/install/jbang/bin/jbang init --template=qcli qcli.java
186-
./build/install/jbang/bin/jbang --fresh --verbose --java 17 qcli.java
261+
chmod +x $_JBANG_
262+
$_JBANG_ init --template=qcli qcli.java
263+
$_JBANG_ --fresh --verbose --java 17 qcli.java
187264
rm qcli.java
188265
- name: integration-test-non-windows
189266
if: runner.os != 'Windows'
@@ -192,5 +269,3 @@ jobs:
192269
cd build/itests
193270
chmod +x ./test_suite.sh
194271
./test_suite.sh
195-
- name: add-to-path
196-
run: echo "../build/install/jbang/bin" >> $env:GITHUB_PATH

0 commit comments

Comments
 (0)