Github Actions Quarkus测试工作流程

huangapple go评论79阅读模式
英文:

Github Actions Workflow for Quarkus Tests

问题

我正在尝试编写一个 GitHub Actions 工作流来运行 Quarkus 应用程序的测试。然而,当运行 Quarkus 测试时,它会运行所有测试,然后显示一个命令提示符并要求输入更多命令。这会导致 GitHub 上的作业挂起并无限期地运行。我无法弄清楚如何让 Quarkus 运行所有测试然后退出。

这是我的当前 .yml 文件:

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

希望这对你有所帮助。如果你有其他问题,请随时提出。

英文:

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

答案1

得分: 2

quarkus:test命令主要用于本地、交互式、持续测试。该命令的优点在于它会自动检测代码更改并重新运行受影响的测试。这在本地非常方便,但在CI中没有意义。

要以'正常'模式运行Quarkus测试,只需运行普通的Maven命令,如mvn installmvn verify。在您的情况下,mvn package应该已经运行了测试,但您可以通过故意提交一个失败的测试并确认构建失败来进行确认。

我相当确定quarkus.test.disable-continuous-testing选项不存在。我认为可能是与quarkus.test.continuous-testing=disabled混淆了,后者确实存在。该选项主要用于在使用quarkus:dev运行应用程序(该选项运行应用程序并可以持续运行测试)但只需要应用程序的实时重新加载,绝对不需要运行测试的情况。

对于您的情况,我建议从工作流程文件中删除./mvnw quarkus:test -Dquarkus.test.disable-continuous-testing=true行。这样可以避免交互式会话,Quarkus测试将在之前的Maven步骤中运行。

英文:

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.

huangapple
  • 本文由 发表于 2023年7月28日 00:42:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76781846.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定