ci: ensure portable jextract code, to match deploy release build #311
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [master] | |
| paths: | |
| - pom.xml | |
| - spotbugs-exclude.xml | |
| - core | |
| - src/** | |
| - scripts/jextract.* | |
| - scripts/TreeSitter_java.patch | |
| - .github/workflows/ci.yml | |
| pull_request: | |
| branches: [master] | |
| paths: | |
| - pom.xml | |
| - spotbugs-exclude.xml | |
| - core | |
| - src/** | |
| - scripts/jextract.* | |
| - scripts/TreeSitter_java.patch | |
| - .github/workflows/ci.yml | |
| concurrency: | |
| cancel-in-progress: true | |
| group: ${{github.workflow}}-${{github.ref_name}} | |
| permissions: | |
| contents: write | |
| security-events: write | |
| jobs: | |
| jextract-linux: | |
| name: Generate jextract code on Linux | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - name: Set up Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| # NOTE: keep this in sync with deploy | |
| java-version: 25 | |
| cache: maven | |
| - name: Set up jextract | |
| shell: bash | |
| run: |- | |
| curl -LSs '${{env.JEXTRACT_URL}}_linux-x64_bin.tar.gz' | tar xzf - -C "$RUNNER_TOOL_CACHE" | |
| printf '%s/jextract-25/bin\n' "$RUNNER_TOOL_CACHE" >> "$GITHUB_PATH" | |
| env: | |
| # NOTE: keep this in sync with deploy, docs | |
| JEXTRACT_URL: https://download.java.net/java/early_access/jextract/25/1/openjdk-25-jextract+1-1 | |
| - name: Generate code | |
| run: mvn --no-transfer-progress generate-sources | |
| - name: Upload jextract generated code | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: jextract-linux-code | |
| path: target/generated-sources/jextract | |
| if-no-files-found: error | |
| test: | |
| name: Test package | |
| needs: jextract-linux | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: [ubuntu-latest, windows-latest, macos-latest] | |
| java-version: [23, 24, 25] | |
| # To match the release build workflow, use the jextract generated code for Linux and | |
| # verify that it is portable | |
| use-jextract-linux-code: [true] | |
| # Additionally check for non-Linux platforms that the complete build setup, including running | |
| # jextract on that platform, works as well | |
| # This is mainly relevant for users building the project locally, since the release workflow | |
| # uses only the jextract code from Linux | |
| include: | |
| - target: windows-latest | |
| java-version: 25 | |
| use-jextract-linux-code: false | |
| - target: macos-latest | |
| java-version: 25 | |
| use-jextract-linux-code: false | |
| runs-on: ${{matrix.target}} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| submodules: true | |
| - name: Set up Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: ${{matrix.java-version}} | |
| cache: maven | |
| - name: Get tree-sitter commit | |
| shell: sh | |
| run: printf 'TREE_SITTER_REF=%s\n' "$(git rev-parse HEAD:core)" >> "$GITHUB_ENV" | |
| - name: Set up tree-sitter CLI | |
| uses: tree-sitter/setup-action/cli@v2 | |
| - name: Set up tree-sitter library | |
| uses: tree-sitter/setup-action/lib@v2 | |
| with: | |
| tree-sitter-ref: ${{env.TREE_SITTER_REF}} | |
| - name: Set up tree-sitter-java | |
| shell: bash | |
| run: |- | |
| git clone --depth=1 https://github.com/tree-sitter/tree-sitter-java | |
| cd tree-sitter-java | |
| tree-sitter generate --abi=15 | |
| cmake -B build \ | |
| -DBUILD_SHARED_LIBS=ON \ | |
| -DTREE_SITTER_ABI_VERSION=15 \ | |
| -DCMAKE_INSTALL_LIBDIR=lib \ | |
| -DCMAKE_INSTALL_BINDIR=lib \ | |
| -DCMAKE_INSTALL_PREFIX="$RUNNER_TOOL_CACHE/tree-sitter/lib" | |
| cmake --build build && cmake --install build --config Debug | |
| - name: Download jextract generated code for Linux | |
| if: ${{ matrix.use-jextract-linux-code }} | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: jextract-linux-code | |
| path: target/generated-sources/jextract | |
| - name: Set up jextract | |
| if: ${{ !matrix.use-jextract-linux-code }} | |
| shell: bash | |
| run: |- | |
| if [[ $RUNNER_OS == Linux ]]; then | |
| echo "Linux jextract code should have been used from dedicated job" | |
| exit 1 | |
| elif [[ $RUNNER_OS == macOS ]]; then | |
| JEXTRACT_URL+=_macos-aarch64_bin.tar.gz | |
| else | |
| JEXTRACT_URL+=_windows-x64_bin.tar.gz | |
| fi | |
| curl -LSs "$JEXTRACT_URL" | tar xzf - -C "$RUNNER_TOOL_CACHE" | |
| printf '%s/jextract-25/bin\n' "$RUNNER_TOOL_CACHE" >> "$GITHUB_PATH" | |
| env: | |
| # NOTE: keep this in sync with deploy, docs | |
| JEXTRACT_URL: https://download.java.net/java/early_access/jextract/25/1/openjdk-25-jextract+1-1 | |
| - name: Run tests | |
| run: mvn --no-transfer-progress test "-Djextract.skip=${{ matrix.use-jextract-linux-code }}" | |
| - name: Patch SpotBugs SARIF report | |
| if: "!cancelled() && github.event_name == 'push'" | |
| run: mvn antrun:run@patch-sarif | |
| - name: Upload SpotBugs SARIF report | |
| uses: github/codeql-action/upload-sarif@v4 | |
| if: "!cancelled() && github.event_name == 'push'" | |
| with: | |
| category: spotbugs | |
| sarif_file: target/reports/spotbugsSarif.json | |
| - name: Upload JUnit XML report | |
| uses: mikepenz/action-junit-report@v6 | |
| if: "!cancelled()" | |
| with: | |
| annotate_only: true | |
| detailed_summary: true | |
| report_paths: target/reports/surefire/TEST-*.xml |