From 25d94ffe2ac588d340534e03e441dea3fadfccdc Mon Sep 17 00:00:00 2001
From: Mohammed Al Sahaf <msaa1990@gmail.com>
Date: Tue, 29 Oct 2024 21:37:09 +0000
Subject: [PATCH] generate coverage profile

---
 .github/workflows/ci.yml                  | 20 +++++++++++++++++++-
 caddytest/spec/http/requestbody/spec.hurl |  1 +
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ef965da34..9487da36c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -205,7 +205,7 @@ jobs:
       env:
         CGO_ENABLED: 0
       run: |
-        go build -tags nobadger -trimpath -ldflags="-w -s" -v
+        go build -cover -tags nobadger,nopgx,nomysql -trimpath -ldflags="-w -s" -v
       
     - name: Install Hurl
       env:
@@ -217,6 +217,9 @@ jobs:
   
     - name: Run Caddy
       run: |
+        ./cmd/caddy/caddy environ
+        mkdir coverdir
+        export GOCOVERDIR=./coverdir
         ./cmd/caddy/caddy start
 
     - name: Run tests with Hurl
@@ -230,6 +233,21 @@ jobs:
         files: |
           hurl-report/junit.xml
 
+    - name: Generate Coverage Data
+      run: |
+        export GOCOVERDIR=./coverdir
+        ./cmd/caddy/caddy stop
+        go tool covdata textfmt -i=coverdir -o hurl-report/cover-profile.txt
+        go tool cover -html hurl-report/cover-profile.txt -o hurl-report/cover.html
+
+
+    - name: Publish Coverage Profile
+      uses: actions/upload-artifact@v4
+      with:
+        name: caddy_cover_${{ steps.vars.outputs.short_sha }}.html
+        path: "./hurl-report/cover.html"
+        compression-level: 0
+
   s390x-test:
     name: test (s390x on IBM Z)
     runs-on: ubuntu-latest
diff --git a/caddytest/spec/http/requestbody/spec.hurl b/caddytest/spec/http/requestbody/spec.hurl
index 3971fddd3..3abf56e96 100644
--- a/caddytest/spec/http/requestbody/spec.hurl
+++ b/caddytest/spec/http/requestbody/spec.hurl
@@ -25,6 +25,7 @@ http://localhost:8000 {
 
 GET https://localhost:9443
 [Options]
+delay: 1s
 insecure: true
 ```
 Hello