如何为我的 KMM 项目部署 GitHub 操作

How to deploy GitHub Action for my KMM project

目前,当我尝试编写用于为 KMM 项目部署 GitHub 操作的 YAML 文件时遇到了一些问题。我不知道如何编写有关测试共享模块代码的正确脚本(gradlew 命令)。这是我的 YAML 文件的一部分:

test_job:
    name: Test
    runs-on: ubuntu-latest
    continue-on-error: true
    steps:

      - name: Checkout
        uses: actions/checkout@v2

      - name: Set up JDK 11
        uses: actions/setup-java@v2
        with:
          java-version: '11'
          distribution: 'adopt'

      - name: Validate Gradle wrapper
        uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b

      - name: Restore Cache
        uses: actions/cache@v2
        with:
          path: |
            ~/.gradle/caches
            ~/.gradle/wrapper
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
          restore-keys: |
            ${{ runner.os }}-gradle-

      - name: Make gradle executable
        run: chmod +x ./gradlew

      - name: Run Debug Tests
        run: ./gradlew testDebugUnitTest --continue

      - name: Upload Test Reports
        if: ${{ always() }}
        uses: actions/upload-artifact@v2
        with:
          name: test-reports
          path: '**/build/reports/tests/'

您可以使用:

  • ./gradlew check 到 运行 测试所有目标
  • ./gradlew <targetName>Test 到 运行 它针对特定目标

请注意,您可能还想指定共享模块,例如:./gradlew :shared:check

有关更多信息,您可以查看:https://kotlinlang.org/docs/mpp-run-tests.html#run-tests-for-one-or-more-targets