Skip to content

Commit 0899d41

Browse files
committed
Build linux sample with musl
- Change sample build to use musl on linux - Optionally remove version from jar so that e2e tests don't need to use version in path. - Add better matrix to e2e so that we're able to build on one OS and then test with others. - Fixes #576
1 parent d3e897f commit 0899d41

File tree

7 files changed

+92
-26
lines changed

7 files changed

+92
-26
lines changed

.github/workflows/e2e.yml

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,91 @@ on:
66
- cron: '0 0 * * 1,3,5'
77

88
jobs:
9-
e2e:
9+
build:
1010
runs-on: ${{ matrix.os }}
1111
strategy:
1212
fail-fast: false
1313
matrix:
1414
include:
1515
- nickname: win
16-
os: windows-latest
16+
os: windows-2022
1717
graal: 22.3.0
18+
musl: false
1819
- nickname: macos
19-
os: macos-latest
20+
os: macos-12
2021
graal: 22.3.0
22+
musl: false
2123
- nickname: linux
22-
os: ubuntu-latest
24+
os: ubuntu-22.04
2325
graal: 22.3.0
24-
name: E2E ${{ matrix.nickname }}
26+
musl: true
27+
name: Compile ${{ matrix.nickname }}
2528
steps:
2629
- uses: actions/checkout@v2
27-
- uses: actions/setup-java@v2
28-
with:
29-
distribution: adopt
30-
java-version: 17
31-
cache: gradle
3230
- uses: graalvm/setup-graalvm@v1
3331
with:
3432
version: ${{ matrix.graal }}
3533
java-version: 17
3634
components: native-image
37-
set-java-home: false
35+
native-image-musl: ${{ matrix.musl }}
3836
github-token: ${{ secrets.GITHUB_TOKEN }}
3937
- uses: actions/setup-node@v2
4038
with:
4139
node-version: '16'
4240
- run: |
43-
./gradlew clean build nativeCompile
44-
- uses: actions/upload-artifact@v2
41+
./gradlew clean build nativeCompile -PspringShellSampleMusl=${{ matrix.musl }} -PspringShellSampleE2E=true
42+
- uses: actions/upload-artifact@v3
4543
with:
4644
name: spring-shell-samples-${{ matrix.nickname }}
4745
retention-days: 1
4846
path: |
4947
spring-shell-samples/build/libs/*.jar
5048
spring-shell-samples/build/native/nativeCompile/spring-shell-samples
5149
spring-shell-samples/build/native/nativeCompile/spring-shell-samples.exe
50+
e2e:
51+
runs-on: ${{ matrix.os }}
52+
needs: build
53+
strategy:
54+
fail-fast: false
55+
matrix:
56+
include:
57+
- os: windows-2022
58+
nickname: win
59+
# - os: windows-2019
60+
# nickname: win
61+
- os: macos-12
62+
nickname: macos
63+
- os: macos-11
64+
nickname: macos
65+
- os: ubuntu-22.04
66+
nickname: linux
67+
- os: ubuntu-20.04
68+
nickname: linux
69+
name: E2E ${{ matrix.os }}
70+
steps:
71+
- uses: actions/checkout@v2
72+
- uses: actions/setup-java@v2
73+
with:
74+
distribution: adopt
75+
java-version: 17
76+
cache: gradle
77+
- uses: actions/setup-node@v2
78+
with:
79+
node-version: '16'
5280
- name: compile e2e module
5381
working-directory: e2e/spring-shell-e2e
5482
run: |
5583
npm install
5684
npm run build
85+
- uses: actions/download-artifact@v3
86+
with:
87+
name: spring-shell-samples-${{ matrix.nickname }}
88+
path: spring-shell-samples/build
89+
- name: fix artifacts
90+
if: runner.os != 'Windows'
91+
shell: bash
92+
run: |
93+
chmod +x spring-shell-samples/build/native/nativeCompile/spring-shell-samples
5794
- name: run e2e tests
5895
working-directory: e2e/spring-shell-e2e-tests
5996
run: |

.github/workflows/manual.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ jobs:
1313
- nickname: win
1414
os: windows-latest
1515
graal: 22.3.0
16+
musl: false
1617
- nickname: macos
1718
os: macos-latest
1819
graal: 22.3.0
20+
musl: false
1921
- nickname: linux
2022
os: ubuntu-latest
2123
graal: 22.3.0
24+
musl: true
2225
name: Build ${{ matrix.nickname }}
2326
steps:
2427
- uses: actions/checkout@v2
@@ -27,21 +30,15 @@ jobs:
2730
version: ${{ matrix.graal }}
2831
java-version: 17
2932
components: native-image
30-
set-java-home: true
33+
native-image-musl: ${{ matrix.musl }}
3134
github-token: ${{ secrets.GITHUB_TOKEN }}
3235
- run: |
33-
./mvnw clean package -Pnativex
36+
./gradlew build nativeCompile -PspringShellSampleMusl=${{ matrix.musl }}
3437
- uses: actions/upload-artifact@v2
3538
with:
3639
name: spring-shell-samples-${{ matrix.nickname }}
3740
retention-days: 1
3841
path: |
39-
spring-shell-samples/target/*.jar
40-
spring-shell-samples/target/spring-shell-samples
41-
spring-shell-samples/target/spring-shell-samples.exe
42-
- uses: actions/upload-artifact@v2
43-
with:
44-
name: surefire-reports-${{ matrix.nickname }}
45-
retention-days: 1
46-
path: |
47-
*/target/surefire-reports/*
42+
spring-shell-samples/build/libs/*.jar
43+
spring-shell-samples/build/native/nativeCompile/spring-shell-samples
44+
spring-shell-samples/build/native/nativeCompile/spring-shell-samples.exe

e2e/spring-shell-e2e-tests/src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export const cliPathRelative = isWindows
77
? '..\\..\\spring-shell-samples\\build\\native\\nativeCompile\\spring-shell-samples.exe'
88
: '../../spring-shell-samples/build/native/nativeCompile/spring-shell-samples';
99
export const jarPathRelative = isWindows
10-
? '..\\..\\spring-shell-samples\\build\\libs\\spring-shell-samples-3.0.0-SNAPSHOT.jar'
11-
: '../../spring-shell-samples/build/libs/spring-shell-samples-3.0.0-SNAPSHOT.jar';
10+
? '..\\..\\spring-shell-samples\\build\\libs\\spring-shell-samples.jar'
11+
: '../../spring-shell-samples/build/libs/spring-shell-samples.jar';
1212
export const cliPath = path.resolve(cliPathRelative);
1313
export const jarPath = path.resolve(jarPathRelative);
1414
export const nativeDesc = 'native';

e2e/spring-shell-e2e/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/spring-shell-e2e/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
},
3232
"homepage": "https://github.com/spring-projects/spring-shell#readme",
3333
"devDependencies": {
34+
"@types/node": "^18.11.9",
3435
"prettier": "^2.6.2",
3536
"typescript": "^4.6.4"
3637
},

e2e/spring-shell-e2e/src/cli.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as pty from 'node-pty';
2+
import * as os from 'os';
23
import { Terminal } from 'xterm-headless';
34

45
export interface CliOptions {
@@ -32,7 +33,10 @@ export class Cli {
3233
}
3334

3435
public run(): void {
36+
const isWindows = (os.platform() === 'win32')
3537
this.term = new Terminal({
38+
allowProposedApi: true,
39+
windowsMode: isWindows,
3640
cols: this.cols,
3741
rows: this.rows
3842
});

spring-shell-samples/spring-shell-samples.gradle

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,22 @@ springBoot {
1818
buildInfo()
1919
}
2020

21+
if (project.hasProperty('springShellSampleE2E') && springShellSampleE2E.toBoolean()) {
22+
bootJar {
23+
archiveName = "$baseName.$extension"
24+
}
25+
}
26+
2127
graalvmNative {
2228
metadataRepository {
2329
enabled = true
2430
}
31+
binaries {
32+
main {
33+
if (project.hasProperty('springShellSampleMusl') && springShellSampleMusl.toBoolean()) {
34+
buildArgs.add('--static')
35+
buildArgs.add('--libc=musl')
36+
}
37+
}
38+
}
2539
}

0 commit comments

Comments
 (0)