Github actions decline action if fails
There is a super convenient way to build, test and aggregate the outcome of changes of some branch before merging using pull requests.
Its common to create a pull request and trigger a workflow doing the checks. Just add "pull_request:" to reuse your existing workflow, to build and test your changes.
name: Android CI
on:
push:
branches: [ main ]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
# Runs ktlint
- name: Lint
run: ./gradlew ktlintCheck
# Execute unit tests
- name: Unit Test
run: ./gradlew testDebugUnitTest
Jobs are executed in parallel. Of course that is faster. Common use case is a matrix that defines required test targets, e.g. os versions, node or Java versions.