From 0899d414deda4423150684d42dab24c406428dbb Mon Sep 17 00:00:00 2001 From: Janne Valkealahti Date: Wed, 30 Nov 2022 15:39:10 +0000 Subject: [PATCH] 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 --- .github/workflows/e2e.yml | 63 +++++++++++++++---- .github/workflows/manual.yml | 19 +++--- e2e/spring-shell-e2e-tests/src/utils.ts | 4 +- e2e/spring-shell-e2e/package-lock.json | 13 ++++ e2e/spring-shell-e2e/package.json | 1 + e2e/spring-shell-e2e/src/cli.ts | 4 ++ .../spring-shell-samples.gradle | 14 +++++ 7 files changed, 92 insertions(+), 26 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 532b20fa..e69c8e56 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -6,42 +6,40 @@ on: - cron: '0 0 * * 1,3,5' jobs: - e2e: + build: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: - nickname: win - os: windows-latest + os: windows-2022 graal: 22.3.0 + musl: false - nickname: macos - os: macos-latest + os: macos-12 graal: 22.3.0 + musl: false - nickname: linux - os: ubuntu-latest + os: ubuntu-22.04 graal: 22.3.0 - name: E2E ${{ matrix.nickname }} + musl: true + name: Compile ${{ matrix.nickname }} steps: - uses: actions/checkout@v2 - - uses: actions/setup-java@v2 - with: - distribution: adopt - java-version: 17 - cache: gradle - uses: graalvm/setup-graalvm@v1 with: version: ${{ matrix.graal }} java-version: 17 components: native-image - set-java-home: false + native-image-musl: ${{ matrix.musl }} github-token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/setup-node@v2 with: node-version: '16' - run: | - ./gradlew clean build nativeCompile - - uses: actions/upload-artifact@v2 + ./gradlew clean build nativeCompile -PspringShellSampleMusl=${{ matrix.musl }} -PspringShellSampleE2E=true + - uses: actions/upload-artifact@v3 with: name: spring-shell-samples-${{ matrix.nickname }} retention-days: 1 @@ -49,11 +47,50 @@ jobs: spring-shell-samples/build/libs/*.jar spring-shell-samples/build/native/nativeCompile/spring-shell-samples spring-shell-samples/build/native/nativeCompile/spring-shell-samples.exe + e2e: + runs-on: ${{ matrix.os }} + needs: build + strategy: + fail-fast: false + matrix: + include: + - os: windows-2022 + nickname: win + # - os: windows-2019 + # nickname: win + - os: macos-12 + nickname: macos + - os: macos-11 + nickname: macos + - os: ubuntu-22.04 + nickname: linux + - os: ubuntu-20.04 + nickname: linux + name: E2E ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 17 + cache: gradle + - uses: actions/setup-node@v2 + with: + node-version: '16' - name: compile e2e module working-directory: e2e/spring-shell-e2e run: | npm install npm run build + - uses: actions/download-artifact@v3 + with: + name: spring-shell-samples-${{ matrix.nickname }} + path: spring-shell-samples/build + - name: fix artifacts + if: runner.os != 'Windows' + shell: bash + run: | + chmod +x spring-shell-samples/build/native/nativeCompile/spring-shell-samples - name: run e2e tests working-directory: e2e/spring-shell-e2e-tests run: | diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml index 22d9ab3a..c55814fb 100644 --- a/.github/workflows/manual.yml +++ b/.github/workflows/manual.yml @@ -13,12 +13,15 @@ jobs: - nickname: win os: windows-latest graal: 22.3.0 + musl: false - nickname: macos os: macos-latest graal: 22.3.0 + musl: false - nickname: linux os: ubuntu-latest graal: 22.3.0 + musl: true name: Build ${{ matrix.nickname }} steps: - uses: actions/checkout@v2 @@ -27,21 +30,15 @@ jobs: version: ${{ matrix.graal }} java-version: 17 components: native-image - set-java-home: true + native-image-musl: ${{ matrix.musl }} github-token: ${{ secrets.GITHUB_TOKEN }} - run: | - ./mvnw clean package -Pnativex + ./gradlew build nativeCompile -PspringShellSampleMusl=${{ matrix.musl }} - uses: actions/upload-artifact@v2 with: name: spring-shell-samples-${{ matrix.nickname }} retention-days: 1 path: | - spring-shell-samples/target/*.jar - spring-shell-samples/target/spring-shell-samples - spring-shell-samples/target/spring-shell-samples.exe - - uses: actions/upload-artifact@v2 - with: - name: surefire-reports-${{ matrix.nickname }} - retention-days: 1 - path: | - */target/surefire-reports/* + spring-shell-samples/build/libs/*.jar + spring-shell-samples/build/native/nativeCompile/spring-shell-samples + spring-shell-samples/build/native/nativeCompile/spring-shell-samples.exe diff --git a/e2e/spring-shell-e2e-tests/src/utils.ts b/e2e/spring-shell-e2e-tests/src/utils.ts index eddafdad..10b469cd 100644 --- a/e2e/spring-shell-e2e-tests/src/utils.ts +++ b/e2e/spring-shell-e2e-tests/src/utils.ts @@ -7,8 +7,8 @@ export const cliPathRelative = isWindows ? '..\\..\\spring-shell-samples\\build\\native\\nativeCompile\\spring-shell-samples.exe' : '../../spring-shell-samples/build/native/nativeCompile/spring-shell-samples'; export const jarPathRelative = isWindows - ? '..\\..\\spring-shell-samples\\build\\libs\\spring-shell-samples-3.0.0-SNAPSHOT.jar' - : '../../spring-shell-samples/build/libs/spring-shell-samples-3.0.0-SNAPSHOT.jar'; + ? '..\\..\\spring-shell-samples\\build\\libs\\spring-shell-samples.jar' + : '../../spring-shell-samples/build/libs/spring-shell-samples.jar'; export const cliPath = path.resolve(cliPathRelative); export const jarPath = path.resolve(jarPathRelative); export const nativeDesc = 'native'; diff --git a/e2e/spring-shell-e2e/package-lock.json b/e2e/spring-shell-e2e/package-lock.json index 7673b10e..b7103563 100644 --- a/e2e/spring-shell-e2e/package-lock.json +++ b/e2e/spring-shell-e2e/package-lock.json @@ -13,10 +13,17 @@ "xterm-headless": "^4.18.0" }, "devDependencies": { + "@types/node": "^18.11.9", "prettier": "^2.6.2", "typescript": "^4.6.4" } }, + "node_modules/@types/node": { + "version": "18.11.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz", + "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==", + "dev": true + }, "node_modules/nan": { "version": "2.15.0", "resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz", @@ -69,6 +76,12 @@ } }, "dependencies": { + "@types/node": { + "version": "18.11.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz", + "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==", + "dev": true + }, "nan": { "version": "2.15.0", "resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz", diff --git a/e2e/spring-shell-e2e/package.json b/e2e/spring-shell-e2e/package.json index 92f06724..f71bb9da 100644 --- a/e2e/spring-shell-e2e/package.json +++ b/e2e/spring-shell-e2e/package.json @@ -31,6 +31,7 @@ }, "homepage": "https://github.com/spring-projects/spring-shell#readme", "devDependencies": { + "@types/node": "^18.11.9", "prettier": "^2.6.2", "typescript": "^4.6.4" }, diff --git a/e2e/spring-shell-e2e/src/cli.ts b/e2e/spring-shell-e2e/src/cli.ts index 3e5ef4c1..373bc28a 100644 --- a/e2e/spring-shell-e2e/src/cli.ts +++ b/e2e/spring-shell-e2e/src/cli.ts @@ -1,4 +1,5 @@ import * as pty from 'node-pty'; +import * as os from 'os'; import { Terminal } from 'xterm-headless'; export interface CliOptions { @@ -32,7 +33,10 @@ export class Cli { } public run(): void { + const isWindows = (os.platform() === 'win32') this.term = new Terminal({ + allowProposedApi: true, + windowsMode: isWindows, cols: this.cols, rows: this.rows }); diff --git a/spring-shell-samples/spring-shell-samples.gradle b/spring-shell-samples/spring-shell-samples.gradle index 78914f5a..474a1b63 100644 --- a/spring-shell-samples/spring-shell-samples.gradle +++ b/spring-shell-samples/spring-shell-samples.gradle @@ -18,8 +18,22 @@ springBoot { buildInfo() } +if (project.hasProperty('springShellSampleE2E') && springShellSampleE2E.toBoolean()) { + bootJar { + archiveName = "$baseName.$extension" + } +} + graalvmNative { metadataRepository { enabled = true } + binaries { + main { + if (project.hasProperty('springShellSampleMusl') && springShellSampleMusl.toBoolean()) { + buildArgs.add('--static') + buildArgs.add('--libc=musl') + } + } + } }