Skip to content

Commit 2e0b3fb

Browse files
committed
chore: add a codecov script
1 parent 2db2f1b commit 2e0b3fb

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

.env-example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ MYSQL_PASSWORD=smarter_test_user
1111
MYSQL_DATABASE=smarter_test_db
1212
MYSQL_CHARSET=utf8mb4
1313
PYTHONPATH=./venv:./
14+
CODECOV_TOKEN=ADD-YOUR-CODECOV_TOKEN-HERE

scripts/codecov.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# Always resolve the path to coverage.xml relative to the repo root
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
6+
COVERAGE_FILE="$REPO_ROOT/coverage.xml"
7+
BRANCH="main"
8+
CODECOV_TOKEN="${CODECOV_TOKEN}"
9+
10+
if [[ -z "$CODECOV_TOKEN" ]]; then
11+
echo "Error: CODECOV_TOKEN environment variable not set."
12+
exit 1
13+
fi
14+
15+
if [[ ! -f "$COVERAGE_FILE" ]]; then
16+
echo "Error: $COVERAGE_FILE not found."
17+
exit 1
18+
fi
19+
20+
COMMIT_SHA=$(git -C "$REPO_ROOT" rev-parse origin/main)
21+
22+
curl -X POST -F "file=@${COVERAGE_FILE}" \
23+
"https://codecov.io/upload/v4?token=${CODECOV_TOKEN}&branch=${BRANCH}&commit=${COMMIT_SHA}"

0 commit comments

Comments
 (0)