Search code examples
javagithub-actionsquarkus

Github Actions Workflow for Quarkus Tests


I am trying to write a github actions workflow to run tests for a quarkus application. However, when running quarkus tests, it runs all the tests, and then displays a command prompt and asks for more commands. This causes the job to hang on github and just keep running indefinitely. I can't figure out how to get quarkus to run all the tests and then just exit.

Here is my current .yml file:

name: Java CI with Quarkus

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK 17
        uses: actions/setup-java@v2
        with:
          java-version: '17'
          distribution: 'adopt'
      - name: Cache Maven packages
        uses: actions/cache@v2
        with:
          path: ~/.m2
          key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
          restore-keys: ${{ runner.os }}-m2
      - name: Build with Maven
        run: mvn -B package --file pom.xml
      - name: Test with Quarkus
        run: ./mvnw quarkus:test -Dquarkus.test.disable-continuous-testing=true

Solution

  • The quarkus:test command is really intended for local, interactive, continuous testing. The advantage of the command is that it will detect code changes and re-run the affected tests automatically. That's awesome locally, but doesn't make sense in a CI.

    To run Quarkus tests in 'normal' mode, it's sufficient to just run the normal maven commands, such as mvn install or mvn verify. In your case, the mvn package should be running the tests already, but you could confirm by deliberately committing a failing test and confirming the build fails.

    I'm fairly sure that quarkus.test.disable-continuous-testing option doesn't exist. I think maybe it's got confused with quarkus.test.continuous-testing=disabled, which does exist. That option is mostly intended if you're running with quarkus:dev (which runs the application and can also continuously run tests) but only want live reload of the application, and definitely don't want tests.

    For your scenario, I'd just remove the ./mvnw quarkus:test -Dquarkus.test.disable-continuous-testing=true line from your workflow file. That should avoid the interactive session and the Quarkus tests will be run in the previous maven step.