oracle-actions / setup-java

GitHub Action to download and install Oracle's Java Development Kit builds
Universal Permissive License v1.0
62 stars 11 forks source link

Action fails at aarch64 machine since action.yml hardcodes X64 #63

Closed vlsi closed 7 months ago

vlsi commented 9 months ago

See https://github.com/pgjdbc/pgjdbc/actions/runs/6997219349/job/19033952407#step:5:14

Can the action support arm linux as well? https://github.com/oracle-actions/setup-java/blob/afea155ec9ead9da533a803c03cb135f01e6a949/action.yml#L49

Here's the log (note there's JAVA_HOME_17_ARM64 environment variable):

Run oracle-actions/setup-java@7a0114d66dbd02646abd345c3395b34c148e6126
  with:
    website: jdk.java.net
    release: [2](https://github.com/pgjdbc/pgjdbc/actions/runs/6997140560/job/19033784475#step:5:2)2
    version: latest
    install: true
  env:
    ACTIONS_STEP_DEBUG: true
    ACTIONS_RUNNER_DEBUG: true
    TZ: America/New_York
    JAVA_HOME: /home/pgjdbc/actions-runner/_work/_tool/Java_Oracle_jdk/17/arm64
    JAVA_HOME_17_ARM64: /home/pgjdbc/actions-runner/_work/_tool/Java_Oracle_jdk/17/arm64
Run JAVA=$JAVA_HOME_17_X64/bin/java
  JAVA=$JAVA_HOME_17_X64/bin/java
  DOWNLOAD=$GITHUB_ACTION_PATH/src/Download.java
  if [ ! -z "" ]; then
    $JAVA \
      -Dinstall-as-version="" \
      $DOWNLOAD \

  else
    $JAVA \
      -Dinstall-as-version="" \
      $DOWNLOAD \
      jdk.java.net \
      22 \
      latest
  fi
  shell: /bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    ACTIONS_STEP_DEBUG: true
    ACTIONS_RUNNER_DEBUG: true
    TZ: America/New_York
    JAVA_HOME: /home/pgjdbc/actions-runner/_work/_tool/Java_Oracle_jdk/17/arm64
    JAVA_HOME_17_ARM64: /home/pgjdbc/actions-runner/_work/_tool/Java_Oracle_jdk/17/arm64
/home/pgjdbc/actions-runner/_work/_temp/948b854[3](https://github.com/pgjdbc/pgjdbc/actions/runs/6997140560/job/19033784475#step:5:3)-3de5-[4](https://github.com/pgjdbc/pgjdbc/actions/runs/6997140560/job/19033784475#step:5:4)01f-aa19-[6](https://github.com/pgjdbc/pgjdbc/actions/runs/6997140560/job/19033784475#step:5:6)e[9](https://github.com/pgjdbc/pgjdbc/actions/runs/6997140560/job/19033784475#step:5:9)6ade9ce4d.sh: line [10](https://github.com/pgjdbc/pgjdbc/actions/runs/6997140560/job/19033784475#step:5:10): /bin/java: No such file or directory
vlsi commented 9 months ago

Here's a workaround:

      uses: oracle-actions/setup-java@7a0114d66dbd02646abd345c3395b34c148e6126 # v1.3.2
      env:
        # ARM machines miss JAVA_HOME_17_X64, however, the action uses the variable
        JAVA_HOME_17_X64: ${{ env.JAVA_HOME_17_ARM64 || env.JAVA_HOME_17_X64 }}
vlsi commented 9 months ago

Note that JAVA_HOME_17_ARM64 is not reliable. setup-java creates variable JAVA_HOME_17_ARM64 when called without explicit architecture: ..., and it creates JAVA_HOME_17_AARCH64 when architecture: aarch64 is specified in action call 🤷

sormuras commented 9 months ago

With setup-java creates variable [...] you refer to the underlying actions/setup-java right?

vlsi commented 9 months ago

By the way, it looks like JAVA_HOME_17_... does not even exist on pgjdbc self-hosted runner (no idea why), so I had to install Java 17 first, then call oracle-action/setup-java to download Java 22, and then re-install Java 17 with actions/setup-java so it restores Java 17 as the default one.

actions/setup-java always sets the installed Java as the default one: https://github.com/actions/setup-java/issues/560

sormuras commented 7 months ago

@vlsi and @sureshg - I went ahead and added support for ARM-based runners. Tests look good so far: https://github.com/oracle-actions/setup-java/actions/runs/7738950766

Can you please double-check using either the commit hash c9a099b12bd9a6c0d491c63b76e99b190a621def or main version of this action? Thanks in advance.

sureshg commented 7 months ago

@sormuras it's working fine on macos-14 (M1)..thanks for the quick fix.

10s
Run oracle-actions/setup-java@main
Run JAVA=$JAVA_HOME_[1](https://.../actions/runs/77457234162/job/211234587168#step:3:1)7_X64/bin/java
openjdk 17.0.9 2023-10-17
OpenJDK Runtime Environment Temurin-17.0.9+9 (build 17.0.9+9)
OpenJDK 64-Bit Server VM Temurin-17.0.9+9 (build 17.0.9+9, mixed mode)
Archive openjdk-23-ea+7_macos-aarch64_bin.tar.gz in file:///Users/runner/.oracle-actions/setup-java/1b7d4742/