I'm trying to run tests(Karate) using GitHub actions and even if the build fails(failing test) and results in exit code 1, the Github step passes.
My workflow file:
name: Run E2E tests
on: pull_request
jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run karate tests
run: make test
- name: Karate DSL Test Reports
uses: actions/upload-artifact@v2
with:
name: Test Reports
path: ./target/cucumber-html-reports/overview-features.html
My make command is simply running a docker container(with maven dependencies) and has the following:
test:
docker-compose up --build
Docker-compose file:
version: '3.8'
services:
karate-tests:
image: karate-tests
build:
context: .
dockerfile: ./Dockerfile
volumes:
- ./target:/usr/src/app/target
- ~/.m2:/root/.m2
command: mvn --batch-mode test
Dockerfile:
FROM maven:3.8.6-jdk-11
WORKDIR /usr/src/app
COPY pom.xml /usr/src/app/
COPY /src/test/java /usr/src/app/src/test/java
GitHub actions showing that the step is successful despite a failing build:
Can anyone help me figure out why the step passes even if the build fails(exit code 1)?
Update: I found that if I run "mvn test" directly then the step fails as expected. So it seems to be related to the make command that I'm running.
I just had to add the argument --exit-code-from
while running the Docker container and that helped GitHub actions to identify the exit code properly.