-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoverage-codecov.sh
More file actions
executable file
·31 lines (23 loc) · 1012 Bytes
/
coverage-codecov.sh
File metadata and controls
executable file
·31 lines (23 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"
OUTPUT_FILE="${COVERAGE_OUTPUT:-coverage.txt}"
TMP_ROOT="${COVERAGE_TMP_DIR:-/tmp/cache-coverage}"
GOCACHE_DIR="${GOCACHE_DIR:-/tmp/go-build-cache}"
INTEGRATION_BACKEND="${INTEGRATION_BACKEND:-all}"
UNIT_DIR="$TMP_ROOT/unit"
INT_DIR="$TMP_ROOT/integration"
MERGED_DIR="$TMP_ROOT/merged"
rm -rf "$TMP_ROOT"
mkdir -p "$UNIT_DIR" "$INT_DIR" "$MERGED_DIR"
echo "==> Unit coverage"
GOCACHE="$GOCACHE_DIR" \
go test -cover -coverpkg=./... ./... -args -test.gocoverdir="$UNIT_DIR"
echo "==> Integration coverage (backend=${INTEGRATION_BACKEND})"
INTEGRATION_BACKEND="$INTEGRATION_BACKEND" GOCACHE="$GOCACHE_DIR" \
go test -cover -tags integration -coverpkg=./... ./... -args -test.gocoverdir="$INT_DIR"
echo "==> Merge coverage"
go tool covdata merge -i="$UNIT_DIR,$INT_DIR" -o="$MERGED_DIR"
go tool covdata textfmt -i="$MERGED_DIR" -o="$OUTPUT_FILE"
go tool cover -func="$OUTPUT_FILE" | tail -n 1