aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2024-08-10 16:29:21 -0400
committerGitHub <noreply@github.com>2024-08-10 16:29:21 -0400
commit1e25ed89ba5c58ce712d1da4a25b367e900feab3 (patch)
treea1aa3ee9113d855283c271a3a07c18ce69f203d0 /.github/workflows
parentRelease version v0.9.0 (diff)
downloadcli-1e25ed89ba5c58ce712d1da4a25b367e900feab3.zip
Add code coverage job (#2)
* Add code coverage job * Wait for database to be ready in gha * Fix postgres docker container name * fix mssql healthcheck * Add covermode * Tweak mode * use gocovmerge * use go run * tweak readme
Diffstat (limited to '.github/workflows')
-rw-r--r--.github/workflows/test.yml67
1 files changed, 64 insertions, 3 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
+