From 19e7bca09290b7213b08781dd4002568beea7f50 Mon Sep 17 00:00:00 2001
From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Date: Mon, 1 Jul 2024 09:37:46 -0400
Subject: [PATCH 01/16] Add workflow steps to build and include ARM64 binaries
for macOS and Ubuntu Focal; Remove unnecessary native-lib-build action; Add
workflow step to upload built jar.
---
.github/actions/native-lib-build/action.yml | 17 ------
.../workflows/build-and-release-package.yml | 57 ++++++++++++++++---
.../install-deps-and-build-native-lib.sh | 6 ++
3 files changed, 55 insertions(+), 25 deletions(-)
delete mode 100644 .github/actions/native-lib-build/action.yml
create mode 100755 tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
diff --git a/.github/actions/native-lib-build/action.yml b/.github/actions/native-lib-build/action.yml
deleted file mode 100644
index e9079b9..0000000
--- a/.github/actions/native-lib-build/action.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-name: "Builds and bundles libclp-ffi-java"
-description: "Builds libclp-ffi-java on the current platform"
-
-runs:
- using: "composite"
- steps:
- - name: "Build and test"
- run: "mvn --batch-mode test"
- shell: "bash"
-
- - name: "Bundle"
- # NOTE: We need the validate phase to run first, to perform a regex
- # replacement on the OS name
- run: |
- mvn --batch-mode validate assembly:single@assemble-lib-dir
- mv ./target/clp-ffi-*-native-lib $GITHUB_WORKSPACE/.
- shell: "bash"
diff --git a/.github/workflows/build-and-release-package.yml b/.github/workflows/build-and-release-package.yml
index bedd749..022c65d 100644
--- a/.github/workflows/build-and-release-package.yml
+++ b/.github/workflows/build-and-release-package.yml
@@ -6,7 +6,6 @@ env:
on:
pull_request:
paths:
- - ".github/actions/native-lib-build/action.yml"
- ".github/workflows/build-and-release-package.yml"
- ".gitmodules"
- "assembly-lib.xml"
@@ -14,9 +13,9 @@ on:
- "CMakeLists.txt"
- "pom.xml"
- "src/**/*"
+ - "tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh"
push:
paths:
- - ".github/actions/native-lib-build/action.yml"
- ".github/workflows/build-and-release-package.yml"
- ".gitmodules"
- "assembly-lib.xml"
@@ -24,14 +23,46 @@ on:
- "CMakeLists.txt"
- "pom.xml"
- "src/**/*"
+ - "tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh"
workflow_dispatch:
# Concurrency group to prevent multiple workflow instances from trying to publish releases
concurrency: "${{github.workflow}}-${{github.ref}}"
jobs:
+ build-lib-for-linux-arm64:
+ runs-on: "ubuntu-20.04"
+ steps:
+ - uses: "actions/checkout@v4"
+ with:
+ submodules: "recursive"
+
+ - uses: "docker/setup-qemu-action@v3"
+ with:
+ platforms: "arm64"
+
+ - name: "Build native library for Linux ARM64"
+ run: >-
+ docker run
+ --rm
+ --platform linux/arm64
+ --mount type=bind,source=${{ github.workspace }},target=/mnt/clp
+ --workdir /mnt/clp
+ eclipse-temurin:11-jdk-focal
+ ./tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
+
+ - uses: "actions/upload-artifact@v4"
+ with:
+ name: "libclp-ffi-java-linux-arm64"
+ path: "${{github.workspace}}/target/clp-ffi-*-native-lib/"
+ if-no-files-found: "error"
+ retention-days: 1
+
build-lib-for-macos:
- runs-on: "macos-latest"
+ strategy:
+ matrix:
+ runner: ["macos-13", "macos-14"]
+ runs-on: ${{ matrix.runner }}
steps:
- uses: "actions/checkout@v4"
with:
@@ -41,13 +72,15 @@ jobs:
run: "brew install cmake gcc java${{env.JAVA_VERSION}} maven"
- name: "Build native library for MacOS"
- id: "build"
- uses: "./.github/actions/native-lib-build"
+ run: "mvn --batch-mode validate assembly:single@assemble-lib-dir"
- uses: "actions/upload-artifact@v4"
with:
- name: "libclp-ffi-java-macos"
- path: "${{github.workspace}}/clp-ffi-*-native-lib/"
+ name: >-
+ ${{ matrix.runner == 'macos-13'
+ && 'libclp-ffi-java-macos-amd64'
+ || 'libclp-ffi-java-macos-arm64' }}
+ path: "${{github.workspace}}/target/clp-ffi-*-native-lib/"
if-no-files-found: "error"
retention-days: 1
@@ -92,8 +125,9 @@ jobs:
- uses: "actions/download-artifact@v4"
with:
- name: "libclp-ffi-java-macos"
+ pattern: "libclp-ffi-java-macos-*"
path: "./target/."
+ merge-multiple: true
- if: "github.event_name != 'pull_request' && github.ref == 'refs/heads/main'"
name: "Deploy to GitHub Packages"
@@ -108,3 +142,10 @@ jobs:
MAVEN_USERNAME: "${{secrets.OSSRH_USERNAME}}"
MAVEN_PASSWORD: "${{secrets.OSSRH_TOKEN}}"
MAVEN_GPG_PASSPHRASE: "${{secrets.GPG_PASSPHRASE}}"
+
+ - uses: "actions/upload-artifact@v4"
+ with:
+ name: "clp-ffi-java"
+ path: "${{github.workspace}}/target/clp-ffi-*.jar"
+ if-no-files-found: "error"
+ retention-days: 1
diff --git a/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh b/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
new file mode 100755
index 0000000..27e3336
--- /dev/null
+++ b/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+apt-get update
+apt-get install -y build-essential cmake maven
+
+mvn --batch-mode generate-resources validate assembly:single@assemble-lib-dir
From 42581d3fbcbeda37e63a97b8b7a6b58be013940d Mon Sep 17 00:00:00 2001
From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Date: Mon, 1 Jul 2024 09:40:54 -0400
Subject: [PATCH 02/16] Make jar build job depend on Linux ARM lib build job.
---
.github/workflows/build-and-release-package.yml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/build-and-release-package.yml b/.github/workflows/build-and-release-package.yml
index 022c65d..37acd5b 100644
--- a/.github/workflows/build-and-release-package.yml
+++ b/.github/workflows/build-and-release-package.yml
@@ -85,7 +85,9 @@ jobs:
retention-days: 1
build-and-release:
- needs: "build-lib-for-macos"
+ needs:
+ - "build-lib-for-linux-arm64"
+ - "build-lib-for-macos"
runs-on: "ubuntu-20.04"
permissions:
contents: "read"
From 0b3f55733d10cf4e3a2c93951376efff61eb5e7a Mon Sep 17 00:00:00 2001
From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Date: Mon, 1 Jul 2024 09:42:18 -0400
Subject: [PATCH 03/16] Add missing native lib generation command.
---
.github/workflows/build-and-release-package.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build-and-release-package.yml b/.github/workflows/build-and-release-package.yml
index 37acd5b..049259d 100644
--- a/.github/workflows/build-and-release-package.yml
+++ b/.github/workflows/build-and-release-package.yml
@@ -72,7 +72,7 @@ jobs:
run: "brew install cmake gcc java${{env.JAVA_VERSION}} maven"
- name: "Build native library for MacOS"
- run: "mvn --batch-mode validate assembly:single@assemble-lib-dir"
+ run: "mvn --batch-mode generate-resources validate assembly:single@assemble-lib-dir"
- uses: "actions/upload-artifact@v4"
with:
From e583618ec3ca73b09fe4982c23eba0418d78fec4 Mon Sep 17 00:00:00 2001
From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Date: Mon, 1 Jul 2024 09:49:34 -0400
Subject: [PATCH 04/16] Lint fix.
---
.github/workflows/build-and-release-package.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build-and-release-package.yml b/.github/workflows/build-and-release-package.yml
index 049259d..f0f49e1 100644
--- a/.github/workflows/build-and-release-package.yml
+++ b/.github/workflows/build-and-release-package.yml
@@ -62,7 +62,7 @@ jobs:
strategy:
matrix:
runner: ["macos-13", "macos-14"]
- runs-on: ${{ matrix.runner }}
+ runs-on: "${{ matrix.runner }}"
steps:
- uses: "actions/checkout@v4"
with:
From 3ead5937ad851a8ea547d141619cd509700b6a46 Mon Sep 17 00:00:00 2001
From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Date: Mon, 1 Jul 2024 10:01:14 -0400
Subject: [PATCH 05/16] Download Linux arm64 lib; Package after downloading
artifacts.
---
.github/workflows/build-and-release-package.yml | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/build-and-release-package.yml b/.github/workflows/build-and-release-package.yml
index f0f49e1..e2b0d8b 100644
--- a/.github/workflows/build-and-release-package.yml
+++ b/.github/workflows/build-and-release-package.yml
@@ -122,8 +122,13 @@ jobs:
sudo apt update
sudo apt install -y build-essential cmake
- - name: "Build, run tests, and package"
- run: "mvn --batch-mode test package"
+ - name: "Build, and run tests"
+ run: "mvn --batch-mode test"
+
+ - uses: "actions/download-artifact@v4"
+ with:
+ name: "libclp-ffi-java-linux-arm64"
+ path: "./target/."
- uses: "actions/download-artifact@v4"
with:
@@ -131,6 +136,9 @@ jobs:
path: "./target/."
merge-multiple: true
+ - name: "Build package"
+ run: "mvn --batch-mode package -DskipTests"
+
- if: "github.event_name != 'pull_request' && github.ref == 'refs/heads/main'"
name: "Deploy to GitHub Packages"
run: "mvn --batch-mode deploy -DskipTests -Pgithub_release"
From aa1fe3c75d5bfed72176eb878a82218d3507b030 Mon Sep 17 00:00:00 2001
From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Date: Wed, 3 Jul 2024 22:52:41 -0400
Subject: [PATCH 06/16] Use ubuntu:20.04 to build ARM native-lib.
---
.github/workflows/build-and-release-package.yml | 4 ++--
.../scripts/ubuntu-focal/install-deps-and-build-native-lib.sh | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/build-and-release-package.yml b/.github/workflows/build-and-release-package.yml
index e2b0d8b..ab1354b 100644
--- a/.github/workflows/build-and-release-package.yml
+++ b/.github/workflows/build-and-release-package.yml
@@ -31,7 +31,7 @@ concurrency: "${{github.workflow}}-${{github.ref}}"
jobs:
build-lib-for-linux-arm64:
- runs-on: "ubuntu-20.04"
+ runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
with:
@@ -48,7 +48,7 @@ jobs:
--platform linux/arm64
--mount type=bind,source=${{ github.workspace }},target=/mnt/clp
--workdir /mnt/clp
- eclipse-temurin:11-jdk-focal
+ ubuntu:20.04
./tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
- uses: "actions/upload-artifact@v4"
diff --git a/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh b/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
index 27e3336..ef46072 100755
--- a/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
+++ b/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
apt-get update
-apt-get install -y build-essential cmake maven
+apt-get install -y build-essential cmake maven openjdk-11-jdk
mvn --batch-mode generate-resources validate assembly:single@assemble-lib-dir
From 63bd3cc3cd4c6cf3db492f3919749e22309bc072 Mon Sep 17 00:00:00 2001
From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Date: Wed, 3 Jul 2024 22:57:40 -0400
Subject: [PATCH 07/16] Use DEBIAN_FRONTEND=noninteractive to handle jdk
install.
---
tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh b/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
index ef46072..6fd2efa 100755
--- a/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
+++ b/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
apt-get update
-apt-get install -y build-essential cmake maven openjdk-11-jdk
+DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake maven openjdk-11-jdk
mvn --batch-mode generate-resources validate assembly:single@assemble-lib-dir
From 7b667c78bba5a0eee331e921c7449637dfed6527 Mon Sep 17 00:00:00 2001
From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Date: Wed, 3 Jul 2024 23:08:30 -0400
Subject: [PATCH 08/16] Set JAVA_HOME
---
tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh b/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
index 6fd2efa..0c31813 100755
--- a/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
+++ b/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
@@ -3,4 +3,5 @@
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake maven openjdk-11-jdk
+export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-*
mvn --batch-mode generate-resources validate assembly:single@assemble-lib-dir
From a52b81823e26ec7bc0fc3e131999a40dfaa9c3fd Mon Sep 17 00:00:00 2001
From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Date: Thu, 4 Jul 2024 01:06:34 -0400
Subject: [PATCH 09/16] Switch back to eclipse-temurin:11-jdk-focal.
---
.github/workflows/build-and-release-package.yml | 2 +-
.../scripts/ubuntu-focal/install-deps-and-build-native-lib.sh | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/build-and-release-package.yml b/.github/workflows/build-and-release-package.yml
index ab1354b..1b6fa40 100644
--- a/.github/workflows/build-and-release-package.yml
+++ b/.github/workflows/build-and-release-package.yml
@@ -48,7 +48,7 @@ jobs:
--platform linux/arm64
--mount type=bind,source=${{ github.workspace }},target=/mnt/clp
--workdir /mnt/clp
- ubuntu:20.04
+ eclipse-temurin:11-jdk-focal
./tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
- uses: "actions/upload-artifact@v4"
diff --git a/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh b/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
index 0c31813..c1b98a7 100755
--- a/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
+++ b/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
@@ -1,7 +1,6 @@
#!/usr/bin/env bash
apt-get update
-DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake maven openjdk-11-jdk
+DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake maven
-export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-*
mvn --batch-mode generate-resources validate assembly:single@assemble-lib-dir
From 42a140590a8ce06eacd92ecb831f6c38175c40d9 Mon Sep 17 00:00:00 2001
From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Date: Thu, 4 Jul 2024 01:09:42 -0400
Subject: [PATCH 10/16] Make script more robust.
---
.../ubuntu-focal/install-deps-and-build-native-lib.sh | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh b/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
index c1b98a7..30899d3 100755
--- a/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
+++ b/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
@@ -1,6 +1,13 @@
#!/usr/bin/env bash
+# Exit on error
+set -e
+
+script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+project_dir="${script_dir}/../../../"
+
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake maven
+cd "$project_dir"
mvn --batch-mode generate-resources validate assembly:single@assemble-lib-dir
From cf88262ec167102347bb4efc7dec9b931b05c513 Mon Sep 17 00:00:00 2001
From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Date: Thu, 4 Jul 2024 06:58:04 -0400
Subject: [PATCH 11/16] Add integration test to test loading native lib.
---
Taskfile.yml | 21 +++++++++++-
integration-tests/jar-load-native-lib/pom.xml | 33 +++++++++++++++++++
.../src/main/java/com/yscope/clp/Main.java | 26 +++++++++++++++
3 files changed, 79 insertions(+), 1 deletion(-)
create mode 100644 integration-tests/jar-load-native-lib/pom.xml
create mode 100644 integration-tests/jar-load-native-lib/src/main/java/com/yscope/clp/Main.java
diff --git a/Taskfile.yml b/Taskfile.yml
index 23e5c3d..94be218 100644
--- a/Taskfile.yml
+++ b/Taskfile.yml
@@ -6,6 +6,8 @@ includes:
vars:
G_BUILD_DIR: "{{.ROOT_DIR}}/target"
G_LINT_VENV_DIR: "{{.G_BUILD_DIR}}/lint-venv"
+ G_PROJECT_VERSION:
+ sh: "mvn help:evaluate -Dexpression=project.version -q -DforceStdout"
tasks:
default:
@@ -23,7 +25,24 @@ tasks:
# NOTE: `validate` is necessary to remove spaces from the OS name
cmd: "mvn generate-resources validate assembly:single@assemble-lib-dir"
- test: "mvn test"
+ test:
+ cmds:
+ - task: "unit-tests"
+ - task: "integration-tests"
+
+ integration-tests:
+ deps: ["package"]
+ vars:
+ MAVEN_REPO_DIR: "{{.G_BUILD_DIR}}/repo/com/yscope/clp/clp-ffi/{{.G_PROJECT_VERSION}}"
+ cmds:
+ - "mkdir -p '{{.MAVEN_REPO_DIR}}'"
+ - "cp '{{.G_BUILD_DIR}}/clp-ffi-{{.G_PROJECT_VERSION}}.jar' '{{.MAVEN_REPO_DIR}}'"
+ - |-
+ cd "integration-tests/jar-load-native-lib"
+ mvn compile
+ mvn exec:java -Dexec.mainClass="com.yscope.clp.Main"
+
+ unit-tests: "mvn test"
lint:
deps: ["lint-venv"]
diff --git a/integration-tests/jar-load-native-lib/pom.xml b/integration-tests/jar-load-native-lib/pom.xml
new file mode 100644
index 0000000..0a70536
--- /dev/null
+++ b/integration-tests/jar-load-native-lib/pom.xml
@@ -0,0 +1,33 @@
+
+
+
+ 4.0.0
+
+ com.yscope.clp
+ jar-load-native-lib
+ 0.1.0
+
+
+ UTF-8
+ 1.8
+ 1.8
+
+
+
+
+ local
+ local
+ file://${project.basedir}/../../target/repo
+
+
+
+
+
+ com.yscope.clp
+ clp-ffi
+ 0.4-SNAPSHOT
+
+
+
diff --git a/integration-tests/jar-load-native-lib/src/main/java/com/yscope/clp/Main.java b/integration-tests/jar-load-native-lib/src/main/java/com/yscope/clp/Main.java
new file mode 100644
index 0000000..73ed71b
--- /dev/null
+++ b/integration-tests/jar-load-native-lib/src/main/java/com/yscope/clp/Main.java
@@ -0,0 +1,26 @@
+package com.yscope.clp;
+
+import com.yscope.clp.compressorfrontend.BuiltInVariableHandlingRuleVersions;
+import com.yscope.clp.compressorfrontend.EncodedMessage;
+import com.yscope.clp.compressorfrontend.MessageEncoder;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+public class Main {
+ public static void main(String[] args) {
+ // To trigger loading the native library, we encode a message and print its logtype
+ MessageEncoder messageEncoder = new MessageEncoder(
+ BuiltInVariableHandlingRuleVersions.VariablesSchemaV2,
+ BuiltInVariableHandlingRuleVersions.VariableEncodingMethodsV1
+ );
+ EncodedMessage encodedMessage = new EncodedMessage();
+ try {
+ String message = "Static text, dictVar1, 123, 456.7, dictVar2, 987, 654.3";
+ messageEncoder.encodeMessage(message, encodedMessage);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ System.out.println(new String(encodedMessage.logtype, StandardCharsets.ISO_8859_1));
+ }
+}
From 04ccdd7e559952d9d7db2b8d461d95c6c3952005 Mon Sep 17 00:00:00 2001
From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Date: Sun, 21 Jul 2024 15:10:01 -0400
Subject: [PATCH 12/16] Add new test tasks to the README.
---
README.md | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index f49ed50..94d34c7 100644
--- a/README.md
+++ b/README.md
@@ -46,11 +46,21 @@ task native-lib
# Testing
-Run tests:
+Run all tests:
```shell
task test
```
+Run unit tests:
+```shell
+task unit-tests
+```
+
+Run integration tests:
+```shell
+task integration-tests
+```
+
# Linting
Before submitting a PR, ensure you've run our linting tools and either fixed any violations or
From 1f3704acafdc011ff79d395641c4fb460188785b Mon Sep 17 00:00:00 2001
From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Date: Sun, 21 Jul 2024 15:39:03 -0400
Subject: [PATCH 13/16] Replace arm64 instances with aarch64 where possible.
---
.github/workflows/build-and-release-package.yml | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/build-and-release-package.yml b/.github/workflows/build-and-release-package.yml
index 1b6fa40..b025e04 100644
--- a/.github/workflows/build-and-release-package.yml
+++ b/.github/workflows/build-and-release-package.yml
@@ -30,7 +30,7 @@ on:
concurrency: "${{github.workflow}}-${{github.ref}}"
jobs:
- build-lib-for-linux-arm64:
+ build-lib-for-linux-aarch64:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
@@ -41,7 +41,7 @@ jobs:
with:
platforms: "arm64"
- - name: "Build native library for Linux ARM64"
+ - name: "Build native library for Linux aarch64"
run: >-
docker run
--rm
@@ -53,7 +53,7 @@ jobs:
- uses: "actions/upload-artifact@v4"
with:
- name: "libclp-ffi-java-linux-arm64"
+ name: "libclp-ffi-java-linux-aarch64"
path: "${{github.workspace}}/target/clp-ffi-*-native-lib/"
if-no-files-found: "error"
retention-days: 1
@@ -79,14 +79,14 @@ jobs:
name: >-
${{ matrix.runner == 'macos-13'
&& 'libclp-ffi-java-macos-amd64'
- || 'libclp-ffi-java-macos-arm64' }}
+ || 'libclp-ffi-java-macos-aarch64' }}
path: "${{github.workspace}}/target/clp-ffi-*-native-lib/"
if-no-files-found: "error"
retention-days: 1
build-and-release:
needs:
- - "build-lib-for-linux-arm64"
+ - "build-lib-for-linux-aarch64"
- "build-lib-for-macos"
runs-on: "ubuntu-20.04"
permissions:
@@ -127,7 +127,7 @@ jobs:
- uses: "actions/download-artifact@v4"
with:
- name: "libclp-ffi-java-linux-arm64"
+ name: "libclp-ffi-java-linux-aarch64"
path: "./target/."
- uses: "actions/download-artifact@v4"
From 171ca708988ae87e0d97253b70f09d1e5ad62c82 Mon Sep 17 00:00:00 2001
From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Date: Mon, 22 Jul 2024 00:56:28 -0400
Subject: [PATCH 14/16] Install jar to a local repo properly rather than
copying it hackily.
---
Taskfile.yml | 13 ++++++++-----
integration-tests/jar-load-native-lib/pom.xml | 8 --------
2 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/Taskfile.yml b/Taskfile.yml
index 94be218..5d1d919 100644
--- a/Taskfile.yml
+++ b/Taskfile.yml
@@ -31,12 +31,15 @@ tasks:
- task: "integration-tests"
integration-tests:
- deps: ["package"]
- vars:
- MAVEN_REPO_DIR: "{{.G_BUILD_DIR}}/repo/com/yscope/clp/clp-ffi/{{.G_PROJECT_VERSION}}"
+ env:
+ # Use a local directory for the Maven repo so that we can install the jar (for the integration
+ # tests to use) without affecting the user's environment.
+ # NOTE: Maven doesn't strip quotes around the value, but treats everything on the right hand
+ # side of the equals sign as the value; so we don't need to quote the path.
+ MAVEN_OPTS: "-Dmaven.repo.local={{.G_BUILD_DIR}}/repo"
cmds:
- - "mkdir -p '{{.MAVEN_REPO_DIR}}'"
- - "cp '{{.G_BUILD_DIR}}/clp-ffi-{{.G_PROJECT_VERSION}}.jar' '{{.MAVEN_REPO_DIR}}'"
+ # NOTE: Since we're using a custom repo-directory, this will end up rebuilding the package.
+ - "mvn install -DskipTests"
- |-
cd "integration-tests/jar-load-native-lib"
mvn compile
diff --git a/integration-tests/jar-load-native-lib/pom.xml b/integration-tests/jar-load-native-lib/pom.xml
index 0a70536..a06a2c3 100644
--- a/integration-tests/jar-load-native-lib/pom.xml
+++ b/integration-tests/jar-load-native-lib/pom.xml
@@ -15,14 +15,6 @@
1.8
-
-
- local
- local
- file://${project.basedir}/../../target/repo
-
-
-
com.yscope.clp
From 5db55e391d076fc200469d35dc2943caf33c1a23 Mon Sep 17 00:00:00 2001
From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Date: Tue, 23 Jul 2024 15:10:57 -0400
Subject: [PATCH 15/16] Make integration test print nothing on success and
error on failure.
---
.../src/main/java/com/yscope/clp/Main.java | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/integration-tests/jar-load-native-lib/src/main/java/com/yscope/clp/Main.java b/integration-tests/jar-load-native-lib/src/main/java/com/yscope/clp/Main.java
index 73ed71b..7235e7e 100644
--- a/integration-tests/jar-load-native-lib/src/main/java/com/yscope/clp/Main.java
+++ b/integration-tests/jar-load-native-lib/src/main/java/com/yscope/clp/Main.java
@@ -2,6 +2,7 @@
import com.yscope.clp.compressorfrontend.BuiltInVariableHandlingRuleVersions;
import com.yscope.clp.compressorfrontend.EncodedMessage;
+import com.yscope.clp.compressorfrontend.MessageDecoder;
import com.yscope.clp.compressorfrontend.MessageEncoder;
import java.io.IOException;
@@ -9,18 +10,28 @@
public class Main {
public static void main(String[] args) {
- // To trigger loading the native library, we encode a message and print its logtype
+ // To trigger loading the native library, we do a basic encode-decode test.
MessageEncoder messageEncoder = new MessageEncoder(
BuiltInVariableHandlingRuleVersions.VariablesSchemaV2,
BuiltInVariableHandlingRuleVersions.VariableEncodingMethodsV1
);
EncodedMessage encodedMessage = new EncodedMessage();
+ MessageDecoder messageDecoder =
+ new MessageDecoder(BuiltInVariableHandlingRuleVersions.VariablesSchemaV2,
+ BuiltInVariableHandlingRuleVersions.VariableEncodingMethodsV1);
try {
String message = "Static text, dictVar1, 123, 456.7, dictVar2, 987, 654.3";
messageEncoder.encodeMessage(message, encodedMessage);
+ String decodedMessage = messageDecoder.decodeMessage(
+ encodedMessage.getLogTypeAsString(),
+ encodedMessage.getDictionaryVarsAsStrings(),
+ encodedMessage.encodedVars
+ );
+ if (false == message.equals(decodedMessage)) {
+ throw new RuntimeException("Failed to encode message.");
+ }
} catch (IOException e) {
throw new RuntimeException(e);
}
- System.out.println(new String(encodedMessage.logtype, StandardCharsets.ISO_8859_1));
}
}
From bfc991f77d3e1e00d2df6ed7a6060e0c67e8bd57 Mon Sep 17 00:00:00 2001
From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Date: Tue, 23 Jul 2024 15:20:14 -0400
Subject: [PATCH 16/16] Run unit tests when building native lib in GH
workflows.
---
.github/workflows/build-and-release-package.yml | 10 +++++-----
Taskfile.yml | 2 +-
...h => install-deps-build-test-package-native-lib.sh} | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
rename tools/scripts/ubuntu-focal/{install-deps-and-build-native-lib.sh => install-deps-build-test-package-native-lib.sh} (76%)
diff --git a/.github/workflows/build-and-release-package.yml b/.github/workflows/build-and-release-package.yml
index b025e04..880d10e 100644
--- a/.github/workflows/build-and-release-package.yml
+++ b/.github/workflows/build-and-release-package.yml
@@ -13,7 +13,7 @@ on:
- "CMakeLists.txt"
- "pom.xml"
- "src/**/*"
- - "tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh"
+ - "tools/scripts/ubuntu-focal/install-deps-build-test-package-native-lib.sh"
push:
paths:
- ".github/workflows/build-and-release-package.yml"
@@ -23,7 +23,7 @@ on:
- "CMakeLists.txt"
- "pom.xml"
- "src/**/*"
- - "tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh"
+ - "tools/scripts/ubuntu-focal/install-deps-build-test-package-native-lib.sh"
workflow_dispatch:
# Concurrency group to prevent multiple workflow instances from trying to publish releases
@@ -49,7 +49,7 @@ jobs:
--mount type=bind,source=${{ github.workspace }},target=/mnt/clp
--workdir /mnt/clp
eclipse-temurin:11-jdk-focal
- ./tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
+ ./tools/scripts/ubuntu-focal/install-deps-build-test-package-native-lib.sh
- uses: "actions/upload-artifact@v4"
with:
@@ -71,8 +71,8 @@ jobs:
- name: "Install requirements"
run: "brew install cmake gcc java${{env.JAVA_VERSION}} maven"
- - name: "Build native library for MacOS"
- run: "mvn --batch-mode generate-resources validate assembly:single@assemble-lib-dir"
+ - name: "Build, test, and package native library for MacOS"
+ run: "mvn --batch-mode validate generate-resources test assembly:single@assemble-lib-dir"
- uses: "actions/upload-artifact@v4"
with:
diff --git a/Taskfile.yml b/Taskfile.yml
index 5d1d919..9874ac3 100644
--- a/Taskfile.yml
+++ b/Taskfile.yml
@@ -23,7 +23,7 @@ tasks:
native-lib:
# NOTE: `validate` is necessary to remove spaces from the OS name
- cmd: "mvn generate-resources validate assembly:single@assemble-lib-dir"
+ cmd: "mvn validate generate-resources assembly:single@assemble-lib-dir"
test:
cmds:
diff --git a/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh b/tools/scripts/ubuntu-focal/install-deps-build-test-package-native-lib.sh
similarity index 76%
rename from tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
rename to tools/scripts/ubuntu-focal/install-deps-build-test-package-native-lib.sh
index 30899d3..fd4f46a 100755
--- a/tools/scripts/ubuntu-focal/install-deps-and-build-native-lib.sh
+++ b/tools/scripts/ubuntu-focal/install-deps-build-test-package-native-lib.sh
@@ -10,4 +10,4 @@ apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake maven
cd "$project_dir"
-mvn --batch-mode generate-resources validate assembly:single@assemble-lib-dir
+mvn --batch-mode validate generate-resources test assembly:single@assemble-lib-dir