From fc5a98ef0935d8b65848cd3f1e79c40a7628db3c Mon Sep 17 00:00:00 2001 From: Brian Wyka Date: Fri, 25 Feb 2022 22:44:00 -0500 Subject: [PATCH 1/2] more-fixes: Fix native image build outputs --- .../build-homebrew-tap-formula-archive/action.yml | 5 +++++ .github/workflows/maven-ci.yml | 2 +- .github/workflows/release.yml | 5 +++-- distributions/linux/pom.xml | 1 - distributions/scripts/build-native-image.sh | 15 +++++++++++++++ 5 files changed, 24 insertions(+), 4 deletions(-) create mode 100755 distributions/scripts/build-native-image.sh diff --git a/.github/actions/build-homebrew-tap-formula-archive/action.yml b/.github/actions/build-homebrew-tap-formula-archive/action.yml index a2f03fa..de890b4 100644 --- a/.github/actions/build-homebrew-tap-formula-archive/action.yml +++ b/.github/actions/build-homebrew-tap-formula-archive/action.yml @@ -15,6 +15,11 @@ inputs: default: 'manpages' required: true +outputs: + archive-path: + description: "Archive Path" + value: build/sourcehawk-homebrew-tap-formula.tar.gz + runs: using: "composite" steps: diff --git a/.github/workflows/maven-ci.yml b/.github/workflows/maven-ci.yml index dcfbf1a..5ca7502 100644 --- a/.github/workflows/maven-ci.yml +++ b/.github/workflows/maven-ci.yml @@ -137,7 +137,7 @@ jobs: uses: actions/upload-artifact@v2 with: name: linux-native-image - path: distributions/linux/target/sourcehawk + path: ${{ steps.build.outputs.native-image-path }} build-linux-distribution: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bc2af12..8e86570 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -318,7 +318,8 @@ jobs: steps: - name: Build uses: optum/sourcehawk/.github/actions/build-homebrew-tap-formula-archive@main - - name: Upload Homebrew Tap Formula Archive + id: build + - name: Upload Homebrew Tap Formula Archive Release Asset id: upload if: success() uses: actions/upload-release-asset@v1 @@ -326,7 +327,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ needs.create-release.outputs.release-asset-upload-url }} - asset_path: homebrew/sourcehawk-homebrew-tap-formula.tar.gz + asset_path: ${{ steps.build.outputs.archive-path }} asset_name: sourcehawk-${{ github.event.inputs.version }}-darwin-x86_64.tar.gz asset_content_type: application/octet-stream diff --git a/distributions/linux/pom.xml b/distributions/linux/pom.xml index 8ce9308..e4834c0 100644 --- a/distributions/linux/pom.xml +++ b/distributions/linux/pom.xml @@ -36,7 +36,6 @@ com.optum.sourcehawk sourcehawk-cli - ${project.version} completion sh provided diff --git a/distributions/scripts/build-native-image.sh b/distributions/scripts/build-native-image.sh new file mode 100755 index 0000000..4f39a77 --- /dev/null +++ b/distributions/scripts/build-native-image.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# shellcheck disable=SC2164 +DIR="${DIR:-"$(dirname "$(dirname "$(cd -- "$(dirname "$0")"; pwd -P)")")"}" + +GH_PAGES_DIR="$DIR/gh-pages" + +# TODO: copy native image JAR +# TODO: copy completion script + + +# TODO: build native image +BUILD_DIR="$DIR/distributions/linux" + +. "$DIR"/distributions/scripts/extract-file-from-docker-container.sh /home/sourcehawk/sourcehawk /sourcehawk From b0f792f5e7e89dc93174566e6e42d17f18f28794 Mon Sep 17 00:00:00 2001 From: Brian Wyka Date: Thu, 15 Dec 2022 20:06:35 -0500 Subject: [PATCH 2/2] more-fixes: Changes I can't remember --- .gitignore | 1 + .../cli/ValidateConfigCommandSpec.groovy | 6 +- .../linux/native-image-builder/Dockerfile | 24 -- distributions/linux/pom.xml | 276 +----------------- .../NativeImageSpecification.groovy | 15 +- distributions/pom.xml | 19 +- pom.xml | 6 +- 7 files changed, 30 insertions(+), 317 deletions(-) delete mode 100644 distributions/linux/native-image-builder/Dockerfile diff --git a/.gitignore b/.gitignore index 6028a98..86dda36 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ target/ log logs *.bak +.DS_Store ### STS ### .apt_generated diff --git a/cli/src/test/groovy/com/optum/sourcehawk/cli/ValidateConfigCommandSpec.groovy b/cli/src/test/groovy/com/optum/sourcehawk/cli/ValidateConfigCommandSpec.groovy index 5c161a2..01e1470 100644 --- a/cli/src/test/groovy/com/optum/sourcehawk/cli/ValidateConfigCommandSpec.groovy +++ b/cli/src/test/groovy/com/optum/sourcehawk/cli/ValidateConfigCommandSpec.groovy @@ -267,7 +267,8 @@ class ValidateConfigCommandSpec extends CliBaseSpecification { String errorMessage = ValidateConfigCommand.deriveErrorMessage(context, e) then: - errorMessage == "Parse error [Source: UNKNOWN; line: -1, column: -1] ${context}" + errorMessage.startsWith("Parse error [Source: UNKNOWN;") + errorMessage.endsWith("] ${context}") } def "deriveErrorMessage - cause JsonProcessingException"() { @@ -279,7 +280,8 @@ class ValidateConfigCommandSpec extends CliBaseSpecification { String errorMessage = ValidateConfigCommand.deriveErrorMessage(context, e) then: - errorMessage == "Parse error [Source: UNKNOWN; line: -1, column: -1] ${context}" + errorMessage.startsWith("Parse error [Source: UNKNOWN;") + errorMessage.endsWith("] ${context}") } def "deriveErrorMessage - Exception"() { diff --git a/distributions/linux/native-image-builder/Dockerfile b/distributions/linux/native-image-builder/Dockerfile deleted file mode 100644 index c6b7a87..0000000 --- a/distributions/linux/native-image-builder/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -ARG GRAALVM_VERSION=22.0.0-java11 -FROM ghcr.io/optum/ci/nativeimage:graalvm-ce-${GRAALVM_VERSION} - -# Build Arguments -ARG JAR -ARG WORKDIR - -# Copy shaded native jar into build -COPY ${JAR} ${WORKDIR}/native-image.jar - -# Define the working directory -WORKDIR ${WORKDIR} - -# Build the native image -RUN cd /opt/graalvm-ce-*/bin; \ - GRAALVM_BIN_DIR="$(pwd)"; \ - cd ${WORKDIR}; \ - "$GRAALVM_BIN_DIR"/native-image -cp native-image.jar \ - -H:+ReportExceptionStackTraces \ - --report-unsupported-elements-at-runtime \ - --gc=epsilon \ - --libc=musl \ - --no-fallback \ - --static \ No newline at end of file diff --git a/distributions/linux/pom.xml b/distributions/linux/pom.xml index e4834c0..baa26b7 100644 --- a/distributions/linux/pom.xml +++ b/distributions/linux/pom.xml @@ -18,280 +18,22 @@ pom - - ${project.artifactId}-native-image-builder - /home/${global.project.name} - ${docker.workdir}/${global.project.name} - ${project.build.directory}/${global.project.name} - true + - com.optum.sourcehawk - sourcehawk-cli - native-image - provided + org.spockframework + spock-core + 2.1-groovy-3.0 + test - com.optum.sourcehawk - sourcehawk-cli - completion - sh - provided + org.slf4j + slf4j-simple + 1.7.36 + test - - - - - - maven-resources-plugin - - - copy-manpages - process-resources - - copy-resources - - - - - ${maven.multiModuleProjectDirectory}/gh-pages/manpages - - ${global.project.name}* - - - - ${project.build.directory}/dist/manpages - - - - - - - - maven-dependency-plugin - - - copy-native-image - prepare-package - - copy-dependencies - - - com.optum.sourcehawk - sourcehawk-cli - native-image - ${project.build.directory}/dist - - - - copy-native-image-completion-script - prepare-package - - copy - - - - - com.optum.sourcehawk - sourcehawk-cli - completion - sh - ${project.build.directory}/dist/completion - ${global.project.name} - - - - - - - - - - com.spotify - dockerfile-maven-plugin - - - build-native-image - prepare-package - - build - tag - - - ${basedir}/native-image-builder/Dockerfile - ${docker.image} - ${project.version} - - ${graalvm.version} - target/dist/sourcehawk-cli-${project.version}-native-image.jar - ${docker.workdir} - - true - - - - - - - - org.codehaus.mojo - exec-maven-plugin - - - - - extract-native-image - package - - exec - - - ../scripts/extract-file-from-docker-container.sh - - ${docker.image}:${project.version} - ${docker.build.executable} - ${project.build.directory} - - - - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-native-image-artifact - - attach-artifact - - post-integration-test - - - - ${native.image} - x86_64 - zip - - - - - - - - - - - - - - - windows - - - windows - - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - true - - - - - - - - - mac - - - mac - - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - true - - - - - - - - - linux-integration-tests - - - unix - Linux - - - - - - org.codehaus.mojo - exec-maven-plugin - - - - - verify-native-image-execution - integration-test - - exec - - - ${native.image} - - --version - - - - - - - - - - - - - java11 - - 11 - - - 22.0.0-java11 - - - - - - java17 - - 17 - - - 22.0.0-java17 - - - - - diff --git a/distributions/linux/src/it/groovy/sourcehawk/NativeImageSpecification.groovy b/distributions/linux/src/it/groovy/sourcehawk/NativeImageSpecification.groovy index 6c20798..b40f3b1 100644 --- a/distributions/linux/src/it/groovy/sourcehawk/NativeImageSpecification.groovy +++ b/distributions/linux/src/it/groovy/sourcehawk/NativeImageSpecification.groovy @@ -7,16 +7,17 @@ class NativeImageSpecification extends Specification { @Shared protected String moduleRoot = new File(NativeImageSpecification.classLoader.getResource("marker").toURI()) - .getParentFile() // test - .getParentFile() // src - .getParentFile() // linux - .getAbsolutePath() + .getParentFile() // test + .getParentFile() // src + .getParentFile() // linux + .getAbsolutePath() @Shared protected String resourcesRoot = new File(NativeImageSpecification.classLoader.getResource("marker").toURI()) - .getParentFile() - .getAbsolutePath() + .getParentFile() + .getAbsolutePath() - protected String executable = "${moduleRoot}/target/sourcehawk".toString() + protected String executable = Optional.ofNullable(System.getProperty("native.image.path")) + .orElse("${moduleRoot}/sourcehawk".toString()) } diff --git a/distributions/pom.xml b/distributions/pom.xml index 22b3f1e..9ccb63e 100644 --- a/distributions/pom.xml +++ b/distributions/pom.xml @@ -7,12 +7,14 @@ com.optum.sourcehawk - sourcehawk - 0.7.2-SNAPSHOT - ../pom.xml + sourcehawk-jar-parent + 2.0.0 + sourcehawk-dist + 0.7.2-SNAPSHOT + Sourcehawk Distributions Sourcehawk distributions for different platforms and technologies pom @@ -23,17 +25,6 @@ yyyyMMddHHmmss - - - - com.optum.sourcehawk - sourcehawk-cli - native-image - ${project.version} - - - - diff --git a/pom.xml b/pom.xml index 7617347..ac50418 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 0.97 - 1.7.32 + 1.7.36 e1 @@ -95,14 +95,14 @@ com.fasterxml.jackson jackson-bom - 2.12.5 + 2.13.1 import pom org.spockframework spock-core - 2.0-groovy-3.0 + 2.1-groovy-3.0 test