axel-op/googlejavaformat-action

Action fails on Windows and MacOS

evandrocoan opened this issue · 4 comments

I had setup it to run on Linux/Window/Mac OS, but one of them if failing this that error:

  1. https://github.com/evandroforks/AppointmentPublishing/runs/903562824?check_suite_focus=true#step:4:11

image

Only now I realiaze I can only run it in one of the machines, otherwise, I would get double commits.

The correct usage would be:

jobs:

  test:

    name: Tests on ${{ matrix.os }} JDK ${{ matrix.java }}

    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        java: [1.8, 1.11]

      # Keep all systems running if something fails
      fail-fast: false

    steps:
      - uses: actions/checkout@v2

      - name: Set up JDK
        uses: actions/setup-java@v1
        with:
          java-version: ${{ matrix.java }}

      # Automatically format and commit code with Google style guide
      # https://github.com/axel-op/googlejavaformat-action/issues/4
      - uses: axel-op/googlejavaformat-action@v3
        if: matrix.java == '1.11' && matrix.os == 'ubuntu-latest'
        with:
          args: "--skip-sorting-imports --replace"

That's because I've only built this action for Linux machines, my bad. I'll try to make this cross-platform in a future version.

Thanks for the issue!

Here's why this action fails on non-Linux machines:

  • On MacOS: calls to GitHub API are rejected when trying to get the releases of GJF (related to this issue). The solution would be to add a required parameter to this action for the GITHUB_TOKEN, so the calls would be authentified.
  • On Windows: the HOME environment variable is not set and I cannot figure out why.

I managed to find a workaround on Windows, so this action will now work on this OS.

Issue "fixed" (with a workaround) with v3.3.0.