Repository navigation
87 lines (79 loc) · 3.63 KB
/
Copy pathjava-consumer-test.yml
File metadata and controls
87 lines (79 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Test Java Maven artifacts
on:
workflow_dispatch:
inputs:
release_tag:
description: 'Release tag to test'
required: true
type: string
workflow_call:
inputs:
release_tag:
required: true
type: string
permissions:
contents: write # `gh release download` of a draft release.
jobs:
java-consumer-test:
name: Java consumer test (${{ matrix.target }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: windows-x86_64
runner: windows-2025
- target: windows-aarch64
runner: windows-11-vs2026-arm
- target: linux-x86_64
runner: ubuntu-24.04
- target: linux-aarch64
runner: ubuntu-24.04-arm
- target: macos-x86_64
runner: macos-12-intel
- target: macos-aarch64
runner: macos-13
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Install Java
uses: ./.github/actions/setup-java
# The same artifacts `publish-maven.yml` uploads to Maven Central, with `native.txt` listing the archive of this platform only.
# A draft release can't be downloaded without a token, so the bindings take the archive from a directory (`MESHLIB_NATIVE_URL`).
- name: Pack the Maven artifacts
env:
GH_TOKEN: ${{ github.token }}
run: |
scripts/retry.sh -- gh release download ${{ inputs.release_tag }} --pattern "meshlib_*_java_bindings.zip" --pattern "meshlib_*_native_${{ matrix.target }}.zip" --dir downloaded --repo ${{ github.repository }} --clobber
BINDINGS="$(echo downloaded/meshlib_*_java_bindings.zip)"
unzip -qo "$BINDINGS" -d downloaded
APP_VERSION="${BINDINGS#downloaded/meshlib_}"
scripts/java/pack_maven.sh "${APP_VERSION%_java_bindings.zip}" downloaded/MeshLibJava downloaded "https://github.com/${{ github.repository }}/releases/download/${{ inputs.release_tag }}" m2
echo "MESHLIB_NATIVE_URL=$GITHUB_WORKSPACE/downloaded" >> "$GITHUB_ENV"
echo "MESHLIB_CACHE_DIR=$RUNNER_TEMP/meshlib-cache" >> "$GITHUB_ENV"
VERSION="$(ls m2/com/meshinspector/meshlib)"
echo "MAVEN_VERSION=$VERSION" >> "$GITHUB_ENV"
echo "ARTIFACTS=m2/com/meshinspector/meshlib/$VERSION/meshlib-$VERSION" >> "$GITHUB_ENV"
# No `java.library.path`: the libraries must come from the archive listed in the jar's `native.txt`.
- name: Run the tests
run: |
SEP=$([ "$RUNNER_OS" = Windows ] && echo ';' || echo ':')
javac --release 22 -Xlint:all -Werror -cp "$ARTIFACTS.jar" -d source/MRTestJava/classes source/MRTestJava/src/mrtest/*.java
java --enable-native-access=ALL-UNNAMED -cp "$ARTIFACTS.jar${SEP}source/MRTestJava/classes" mrtest.Main
ls "$MESHLIB_CACHE_DIR/meshlib"
- name: Install Maven
run: |
if ! command -v mvn >/dev/null; then
curl -sSfL https://archive.apache.org/dist/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz | tar -xzf - -C "$RUNNER_TEMP"
echo "$RUNNER_TEMP/apache-maven-3.9.9/bin" >> "$GITHUB_PATH"
fi
# The packed artifacts serve as the local repository, as if they were downloaded from Maven Central.
- name: Run an example with Maven
working-directory: examples/java-examples
run: mvn -B -ntp "-Dmaven.repo.local=$GITHUB_WORKSPACE/m2" "-Dmeshlib.version=$MAVEN_VERSION" compile exec:exec -Dexample=MeshBoolean