updating CI process + tests for code coverage

This commit is contained in:
Julien Neuhart
2019-08-20 12:06:08 +02:00
parent 09d07e4890
commit bb6a3471d5
5 changed files with 26 additions and 5 deletions

View File

@@ -8,4 +8,5 @@ jobs:
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- run: make lint - run: make lint
- run: make tests - run: make tests CODE_COVERAGE=1
- run: bash <(curl -s https://codecov.io/bash)

3
.gitignore vendored
View File

@@ -1 +1,2 @@
.idea .idea
coverage.txt

View File

@@ -4,6 +4,7 @@ DOCKER_USER=
DOCKER_PASSWORD= DOCKER_PASSWORD=
DOCKER_REPOSITORY=thecodingmachine DOCKER_REPOSITORY=thecodingmachine
GOLANGCI_LINT_VERSION=1.17.1 GOLANGCI_LINT_VERSION=1.17.1
CODE_COVERAGE=0
MAXIMUM_WAIT_TIMEOUT=30.0 MAXIMUM_WAIT_TIMEOUT=30.0
MAXIMUM_WAIT_DELAY=10.0 MAXIMUM_WAIT_DELAY=10.0
MAXIMUM_WEBHOOK_URL_TIMEOUT=30.0 MAXIMUM_WEBHOOK_URL_TIMEOUT=30.0
@@ -37,8 +38,7 @@ lint:
# run all tests. # run all tests.
tests: tests:
make workspace make workspace
docker build -t $(DOCKER_REPOSITORY)/gotenberg:tests -f build/tests/Dockerfile . ./scripts/tests.sh $(DOCKER_REPOSITORY) $(CODE_COVERAGE)
docker run --rm $(DOCKER_REPOSITORY)/gotenberg:tests
# generate documentation. # generate documentation.
doc: doc:

View File

@@ -14,4 +14,8 @@ fi
go run github.com/thecodingmachine/gotenberg/test/cmd/pm2 go run github.com/thecodingmachine/gotenberg/test/cmd/pm2
# Run our tests. # Run our tests.
go test -race -cover ./... if [ "$CODE_COVERAGE" = "1" ]; then
go test -race -coverprofile=coverage.txt -covermode=atomic ./...
else
go test -race -cover ./...
fi

15
scripts/tests.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
set -e
DOCKER_REPOSITORY="$1"
CODE_COVERAGE="$2"
touch "$PWD/coverage.txt"
docker build -t "$DOCKER_REPOSITORY/gotenberg:tests" -f build/tests/Dockerfile .
if [ "$CODE_COVERAGE" = "1" ]; then
docker run --rm -e "CODE_COVERAGE=$CODE_COVERAGE" -v "$PWD/coverage.txt:/gotenberg/tests/coverage.txt" "$DOCKER_REPOSITORY/gotenberg:tests"
else
docker run --rm -e "CODE_COVERAGE=$CODE_COVERAGE" "$DOCKER_REPOSITORY/gotenberg:tests"
fi