aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/test.yml67
-rw-r--r--README.md3
-rw-r--r--docker-compose.mssql.yml7
-rw-r--r--docker-compose.postgresql.yml2
4 files changed, 72 insertions, 7 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 59105f1..940986c 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -2,9 +2,9 @@ name: Test
on:
push:
- branches: ["main", "dev"]
+ branches: ["main"]
pull_request:
- branches: ["main", "dev"]
+ branches: ["main"]
jobs:
run-tests:
@@ -26,5 +26,66 @@ jobs:
if: matrix.db.name != 'sqlite3'
run: |
env $(cat ".env.${{ matrix.db.name }}" | xargs) docker compose -f "docker-compose.${{ matrix.db.name }}.yml" up -d
+ echo "Waiting for the database to be ready..."
+ until [ "`docker inspect -f {{.State.Health.Status}} bolt_${{ matrix.db.name }}_db`" == "healthy" ]; do
+ sleep 5;
+ done
+ echo "Database is ready."
- name: Run Tests
- run: env $(cat ".env.${{ matrix.db.name }}" | xargs) go test -p 1 -tags "${{ matrix.db.name }}" -cover ./...
+ run: env $(cat ".env.${{ matrix.db.name }}" | xargs) go test -p 1 -tags "${{ matrix.db.name }}" -covermode=count -coverprofile=coverage-${{ matrix.db.name }}.out ./...
+
+ - name: Upload Coverage Report
+ uses: actions/upload-artifact@v4
+ with:
+ name: coverage-${{ matrix.db.name }}
+ path: coverage-${{ matrix.db.name }}.out
+
+ combine-coverage-reports-and-upload:
+ needs: [run-tests]
+ runs-on: ubuntu-22.04
+ steps:
+ - name: Checkout Source Code
+ uses: actions/checkout@v4
+
+ - name: Download Coverage Reports
+ uses: actions/download-artifact@v4
+ with:
+ name: coverage-postgresql
+ path: .
+
+ - uses: actions/download-artifact@v4
+ with:
+ name: coverage-mysql
+ path: .
+
+ - uses: actions/download-artifact@v4
+ with:
+ name: coverage-mssql
+ path: .
+
+ - uses: actions/download-artifact@v4
+ with:
+ name: coverage-sqlite3
+ path: .
+
+ - name: Combine Coverage Reports
+ run: go run github.com/wadey/gocovmerge@b5bfa59ec0adc420475f97f89b58045c721d761c coverage-*.out > coverage.combined.out
+
+ - name: Show Combined Coverage
+ run: go tool cover -func=coverage.combined.out
+
+ - name: Upload Combined Coverage Report
+ uses: actions/upload-artifact@v4
+ with:
+ name: combined-coverage
+ path: coverage.combined.out
+
+ - name: Upload to Codecov
+ uses: codecov/codecov-action@v4
+ with:
+ token: ${{ secrets.CODECOV_TOKEN }}
+ files: coverage.combined.out
+ flags: unittests
+ name: bolt-coverage
+ fail_ci_if_error: true
+
diff --git a/README.md b/README.md
index 23eaad4..2304a0e 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,9 @@
<a href="https://goreportcard.com/report/github.com/eugenetriguba/bolt">
<img src="https://goreportcard.com/badge/github.com/eugenetriguba/bolt" alt="Go Report Card Badge">
</a>
+ <a href="https://codecov.io/gh/eugenetriguba/bolt" >
+ <img src="https://codecov.io/gh/eugenetriguba/bolt/graph/badge.svg?token=y8ZwsjjSQ3"/>
+ </a>
<img alt="Version Badge" src="https://img.shields.io/badge/version-0.9.0-blue" style="max-width:100%;">
</p>
diff --git a/docker-compose.mssql.yml b/docker-compose.mssql.yml
index e2a2f5c..d70ab7c 100644
--- a/docker-compose.mssql.yml
+++ b/docker-compose.mssql.yml
@@ -8,11 +8,12 @@ services:
test:
[
"CMD-SHELL",
- "/opt/mssql-tools/bin/sqlcmd -S ${BOLT_DB_HOST:?err} -U ${BOLT_DB_USER:?err} -P ${BOLT_DB_PASSWORD:?err} -Q 'SELECT 1'",
+ "/opt/mssql-tools18/bin/sqlcmd -S ${BOLT_DB_HOST:?err} -U ${BOLT_DB_USER:?err} -P ${BOLT_DB_PASSWORD:?err} -Q 'SELECT 1' -C || exit 1",
]
interval: 10s
- timeout: 5s
- retries: 5
+ timeout: 3s
+ start_period: 10s
+ retries: 10
ports:
- "${BOLT_DB_PORT:?err}:1433"
environment:
diff --git a/docker-compose.postgresql.yml b/docker-compose.postgresql.yml
index ae21fdd..0847eae 100644
--- a/docker-compose.postgresql.yml
+++ b/docker-compose.postgresql.yml
@@ -3,7 +3,7 @@ version: "3.8"
services:
postgres_db:
image: postgres:16.1-alpine3.19
- container_name: bolt_postgres_db
+ container_name: bolt_postgresql_db
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s