How to fail job in a github-actions when running tests are skipped/failed

Viewed 3136

I'm trying to use GitHub Actions for CI testing but my job isn't failed if running test are skipped or failed. it shows the pass status of the test job

GithubAction Workflowenter image description here

Could anyone please give any suggestion that would really help

Workflow.yml:

name: Android build

on: push

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

this is the workflow.yml file

0 Answers
Related