跳过/失败运行测试时如何在github动作中使作业失败

时间:2020-07-15 06:48:28

标签: git github github-actions

我正在尝试使用GitHub Actions进行CI测试,但是如果跳过运行测试或失败测试,​​我的工作不会失败。它显示测试作业的通过状态

GithubAction工作流程enter image description here

任何人都可以提出任何真正有帮助的建议

Workflow.yml:

名称:Android版本

开启:推送

jobs:

  build:

    runs-on: ubuntu-latest

    steps:

      - uses: actions/checkout@v1


      - name: Set Up JDK
        uses: actions/setup-java@v1
        with:
          java-version: 1.8
      - name: Clean
        run: ./gradlew clean

      - name: Compile
        run: ./gradlew compileDebugSources

      - name: Unit Tests
        run: ./gradlew test

      - name: Build Project
        run: ./gradlew assembleRelease

      - name: Sign Apk
        id: sign
        uses: r0adkll/sign-android-release@v1
        with:
          releaseDirectory: app/build/outputs/apk/release
          signingKeyBase64: ${{ secrets.SIGNING_KEY }}
          alias: ${{ secrets.ALIAS }}
          keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
          keyPassword: ${{ secrets.KEY_PASSWORD }}

      - name: Build Analysis
        run: ./gradlew lint

      - name: Artifact Build report
        if: ${{ always() }}
        uses: actions/upload-artifact@v1
        with:
          name: CICDArtifacts
          path: app/build/reports

      - name: Artifacts APK
        uses: actions/upload-artifact@v1
        with:
          name: CICDArtifacts
          path: app/build/outputs/apk/release/app-release.apk

      - name: upload app to pCloudy
        env:
          PCLOUDY_USERNAME: ${{ secrets.PCLOUDY_USERNAME }}
          PCLOUDY_ACCESS_KEY: ${{ secrets.PCLOUDY_ACCESS_KEY }}
        run: |
            echo "install cURL"
            sudo apt install curl
            echo "Verify install of curl on Ubuntu"
            curl --version
            echo "upload apk"
            curl -X POST -F "file=@/home/runner/work/app/build/outputs/apk/release/app-release-unsigned-signed.apk" -F "source_type=raw" -F "token=t9xm" -F "filter=all" https://device.pcloudy.com/api/upload_file
  test:
    needs: build
    runs-on: ubuntu-latest # the machine type
    steps:
      - uses: actions/checkout@v2 #checkout the code
        with:
          repository: testrepo     
      - name: Set up JDK 1.8
        uses: actions/setup-java@v1
        with:
          java-version: 1.8
      - name: Run tests on pCloudy  
        id: pCloudy
        run: mvn clean test
        continue-on-error: false
      - name: Check on failures
        if: steps.pCloudy.outputs.status == 'failure'
        run: exit 1

这是workflow.yml文件

0 个答案:

没有答案