git » chasquid » commit 2e279de

github: Run coverage tests

author Alberto Bertogli
2023-07-27 22:37:55 UTC
committer Alberto Bertogli
2023-07-28 09:05:15 UTC
parent a3f7914e292dd4e2499701e2e68c255f499b1ecc

github: Run coverage tests

This patch adds a job to the docker workflow to run coverage tests, and
upload the results to coveralls.

.github/workflows/docker.yml +28 -1
README.md +1 -1

diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index b17872b..781c529 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -26,10 +26,37 @@ jobs:
       - name: Run tests
         run: docker run --name test1 chasquid-test  make test
 
+  coverage:
+    runs-on: ubuntu-latest
+    timeout-minutes: 5
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-go@v3
+        with:
+          go-version: ">=1.20"
+      - name: Install goveralls
+        run: go install github.com/mattn/goveralls@latest
+      - name: Docker info (for debugging)
+        run: docker info
+      - name: Build test image
+        run: docker build -t chasquid-test -f test/Dockerfile .
+      - name: Run coverage tests
+        run: docker run --name test1 chasquid-test  test/cover.sh
+      - name: Extract coverage results
+        run: >
+          docker cp
+          test1:/go/src/blitiri.com.ar/go/chasquid/.coverage/final.out
+          .
+      - name: Upload coverage results
+        run: >
+          goveralls
+          -coverprofile=final.out
+          -repotoken=${{ secrets.COVERALLS_TOKEN }}
+
   public-image:
     runs-on: ubuntu-latest
     timeout-minutes: 15
-    needs: integration
+    needs: [integration, coverage]
     if: github.event_name == 'push'
     steps:
       - uses: actions/checkout@v3
diff --git a/README.md b/README.md
index 915eccc..ed45850 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ It's written in [Go](https://golang.org), and distributed under the
 
 [![Go tests](https://github.com/albertito/chasquid/actions/workflows/gotests.yml/badge.svg?branch=master)](https://github.com/albertito/chasquid/actions)
 [![Go Report Card](https://goreportcard.com/badge/github.com/albertito/chasquid)](https://goreportcard.com/report/github.com/albertito/chasquid)
-[![Coverage](https://img.shields.io/badge/coverage-next-brightgreen.svg)](https://blitiri.com.ar/p/chasquid/coverage.html)  
+[![Coverage](https://coveralls.io/repos/github/albertito/chasquid/badge.svg?branch=next)](https://coveralls.io/github/albertito/chasquid?branch=next)  
 [![Docs](https://img.shields.io/badge/docs-reference-blue.svg)](https://blitiri.com.ar/p/chasquid/)
 [![OFTC IRC](https://img.shields.io/badge/chat-oftc-blue.svg)](https://webchat.oftc.net/?channels=%23chasquid)