From 1b4bd3ee1ba3da275c0b2eb185f9dbfd82519da1 Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Thu, 18 Apr 2024 23:47:57 +0300 Subject: [PATCH 01/12] testing: use Hurl in CI to test Caddy against spec --- .github/workflows/ci.yml | 29 +++++ caddytest/spec/http/headers/spec.hurl | 22 ++++ caddytest/spec/http/rewrite/spec.hurl | 66 +++++++++++ caddytest/spec/http/static_response/spec.hurl | 105 ++++++++++++++++++ 4 files changed, 222 insertions(+) create mode 100644 caddytest/spec/http/headers/spec.hurl create mode 100644 caddytest/spec/http/rewrite/spec.hurl create mode 100644 caddytest/spec/http/static_response/spec.hurl diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32da779ba33..d60b08b2fb2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: branches: - master - 2.* + - hurl-tests pull_request: branches: - master @@ -14,6 +15,9 @@ on: jobs: test: + permissions: + checks: write + pull-requests: write strategy: # Default is true, cancels jobs for other platforms in the matrix if one fails fail-fast: false @@ -125,6 +129,31 @@ jobs: go test -tags nobadger -v -coverprofile="cover-profile.out" -short -race ./... # echo "status=$?" >> $GITHUB_OUTPUT + - name: Install Hurl + if: matrix.os == 'linux' && matrix.go == '1.22' + run: | + curl --location --remote-name https://github.com/Orange-OpenSource/hurl/releases/download/4.2.0/hurl_4.2.0_amd64.deb + sudo dpkg -i hurl_4.2.0_amd64.deb + + - name: Run Caddy + if: matrix.os == 'linux' && matrix.go == '1.22' + working-directory: ./cmd/caddy + run: | + ./caddy start + + - name: Run tests with Hurl + if: matrix.os == 'linux' && matrix.go == '1.22' + run: | + mkdir hurl-report + find . -name *.hurl -exec hurl --very-verbose --verbose --test --report-junit hurl-report/junit.xml --color {} \; + + - name: Publish Test Results + if: matrix.os == 'linux' && matrix.go == '1.22' + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + files: | + hurl-report/junit.xml + # Relevant step if we reinvestigate publishing test/coverage reports # - name: Prepare coverage reports # run: | diff --git a/caddytest/spec/http/headers/spec.hurl b/caddytest/spec/http/headers/spec.hurl new file mode 100644 index 00000000000..909402b6fa2 --- /dev/null +++ b/caddytest/spec/http/headers/spec.hurl @@ -0,0 +1,22 @@ +# Configure Caddy +POST http://localhost:2019/load +Content-Type: text/caddyfile +``` +{ + skip_install_trust + http_port 9080 + https_port 9443 + local_certs + debug +} +localhost { + header "X-Custom-Header" "Custom-Value" +} +``` + +GET https://localhost:9443 +[Options] +insecure: true +HTTP 200 +[Asserts] +header "X-Custom-Header" == "Custom-Value" diff --git a/caddytest/spec/http/rewrite/spec.hurl b/caddytest/spec/http/rewrite/spec.hurl new file mode 100644 index 00000000000..dd1de7bdc06 --- /dev/null +++ b/caddytest/spec/http/rewrite/spec.hurl @@ -0,0 +1,66 @@ +# Configure Caddy +POST http://localhost:2019/load +User-Agent: hurl/ci +Content-Type: text/caddyfile +``` +{ + skip_install_trust + http_port 9080 + https_port 9443 + local_certs +} +localhost { + rewrite /from /to + respond {uri} +} +``` + +# simple scenario: rewriting /from to /to produces expected result of seeing /to +GET https://localhost:9443/from +[Options] +insecure: true +HTTP 200 +[Asserts] +body == "/to" + +# unmatched path is passed through unchanged +GET https://localhost:9443 +[Options] +insecure: true +HTTP 200 +[Asserts] +body == "/" + +# having a query parameter does not trip the rewrite and retains the query +GET https://localhost:9443/from?query_param=value +[Options] +insecure: true +HTTP 200 +[Asserts] +body == "/to?query_param=value" + + +# Configure Caddy +POST http://localhost:2019/load +User-Agent: hurl/ci +Content-Type: text/caddyfile +``` +{ + skip_install_trust + http_port 9080 + https_port 9443 + local_certs +} +localhost { + rewrite /from /to?a=b + respond {uri} +} +``` + +# a rewrite with query parameters affects the parameters +GET https://localhost:9443/from?query_param=value +[Options] +insecure: true +HTTP 200 +[Asserts] +body == "/to?a=b" diff --git a/caddytest/spec/http/static_response/spec.hurl b/caddytest/spec/http/static_response/spec.hurl new file mode 100644 index 00000000000..e3d0c0697a1 --- /dev/null +++ b/caddytest/spec/http/static_response/spec.hurl @@ -0,0 +1,105 @@ +# Configure Caddy +POST http://localhost:2019/load +User-Agent: hurl/ci +Content-Type: text/caddyfile +``` +{ + skip_install_trust + http_port 9080 + https_port 9443 + local_certs +} +localhost { + log + respond "Hello, World!" +} +``` + +GET https://localhost:9443 +[Options] +insecure: true +HTTP 200 +[Asserts] +`Hello, World!` + + +GET https://localhost:9443/foo +[Options] +insecure: true +HTTP 200 +[Asserts] +`Hello, World!` + +# Configure Caddy +POST http://localhost:2019/load +User-Agent: hurl/ci +Content-Type: text/caddyfile +``` +{ + skip_install_trust + http_port 9080 + https_port 9443 + local_certs +} +localhost { + respond "New text!" +} +``` + +GET https://localhost:9443 +[Options] +insecure: true +HTTP/2 200 +[Asserts] +`New text!` + + +GET https://localhost:9443/foo +[Options] +insecure: true +HTTP/2 200 +[Asserts] +`New text!` + +GET https://localhost:9443/foo +[Options] +insecure: true +HTTP/2 200 +[Asserts] +body != "Hello, World!" + +# Configure Caddy +# The body is a placeholder +POST http://localhost:2019/load +User-Agent: hurl/ci +Content-Type: text/caddyfile +``` +{ + skip_install_trust + http_port 9080 + https_port 9443 + local_certs +} +localhost { + log + respond {http.request.body} +} +``` + +# handler responds with the "application/json" if the response body is valid JSON +POST https://localhost:9443 +[Options] +insecure: true +```json +{ + "greeting": "Hello, world!" +} +``` +HTTP/2 200 +[Asserts] +header "Content-Type" == "application/json" +```json +{ + "greeting": "Hello, world!" +} +``` From 0ecb1ba26279e3438abefc31dedd963920c2c3cc Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Sat, 15 Jun 2024 00:48:08 +0300 Subject: [PATCH 02/12] add `basic_auth` test Signed-off-by: Mohammed Al Sahaf --- caddytest/spec/http/basicauth/spec.hurl | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 caddytest/spec/http/basicauth/spec.hurl diff --git a/caddytest/spec/http/basicauth/spec.hurl b/caddytest/spec/http/basicauth/spec.hurl new file mode 100644 index 00000000000..0362d3dbdff --- /dev/null +++ b/caddytest/spec/http/basicauth/spec.hurl @@ -0,0 +1,38 @@ +# Configure Caddy +POST http://localhost:2019/load +Content-Type: text/caddyfile +``` +{ + skip_install_trust + http_port 9080 + https_port 9443 + local_certs + debug +} +localhost { + log + basic_auth { + john $2a$14$x4HlYwA9Zeer4RkMEYbUzug9XxWmncneR.dcMs.UjalR95URnHg5. + } + respond "Hello, World!" +} +``` + +# requests without `Authorization` header are rejected with 401 +GET https://localhost:9443 +[Options] +insecure: true +HTTP 401 +[Asserts] +header "WWW-Authenticate" == "Basic realm=\"restricted\"" + + +# requests with `Authorization` header are accepted with 200 +GET https://localhost:9443 +[BasicAuth] +john:password +[Options] +insecure: true +HTTP 200 +[Asserts] +`Hello, World!` From c1cdc25b7774b21b9a8eaa3bd39c335f18eca844 Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Sat, 15 Jun 2024 00:48:18 +0300 Subject: [PATCH 03/12] add `file_server` test Signed-off-by: Mohammed Al Sahaf --- .github/workflows/ci.yml | 5 +- .../file_server/assets/indexed/index.html | 9 ++ .../http/file_server/assets/indexed/index.txt | 1 + .../file_server/assets/unindexed/.gitkeep | 0 caddytest/spec/http/file_server/spec.hurl | 119 ++++++++++++++++++ caddytest/spec/hurl_vars.properties | 2 + 6 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 caddytest/spec/http/file_server/assets/indexed/index.html create mode 100644 caddytest/spec/http/file_server/assets/indexed/index.txt create mode 100644 caddytest/spec/http/file_server/assets/unindexed/.gitkeep create mode 100644 caddytest/spec/http/file_server/spec.hurl create mode 100644 caddytest/spec/hurl_vars.properties diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 31c9f1b9c04..705c3f0f816 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -137,15 +137,14 @@ jobs: - name: Run Caddy if: matrix.os == 'linux' && matrix.go == '1.22' - working-directory: ./cmd/caddy run: | - ./caddy start + ./cmd/caddy/caddy start - name: Run tests with Hurl if: matrix.os == 'linux' && matrix.go == '1.22' run: | mkdir hurl-report - find . -name *.hurl -exec hurl --very-verbose --verbose --test --report-junit hurl-report/junit.xml --color {} \; + find . -name *.hurl -exec hurl --variables-file caddytest/spec/hurl_vars.properties --very-verbose --verbose --test --report-junit hurl-report/junit.xml --color {} \; - name: Publish Test Results if: matrix.os == 'linux' && matrix.go == '1.22' diff --git a/caddytest/spec/http/file_server/assets/indexed/index.html b/caddytest/spec/http/file_server/assets/indexed/index.html new file mode 100644 index 00000000000..da5de44a090 --- /dev/null +++ b/caddytest/spec/http/file_server/assets/indexed/index.html @@ -0,0 +1,9 @@ + + + + Index.html Title + + + Index.html + + \ No newline at end of file diff --git a/caddytest/spec/http/file_server/assets/indexed/index.txt b/caddytest/spec/http/file_server/assets/indexed/index.txt new file mode 100644 index 00000000000..21fc0c67e88 --- /dev/null +++ b/caddytest/spec/http/file_server/assets/indexed/index.txt @@ -0,0 +1 @@ +index.txt \ No newline at end of file diff --git a/caddytest/spec/http/file_server/assets/unindexed/.gitkeep b/caddytest/spec/http/file_server/assets/unindexed/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/caddytest/spec/http/file_server/spec.hurl b/caddytest/spec/http/file_server/spec.hurl new file mode 100644 index 00000000000..be9504e1513 --- /dev/null +++ b/caddytest/spec/http/file_server/spec.hurl @@ -0,0 +1,119 @@ +# Configure Caddy with default configuration +POST http://localhost:2019/load +Content-Type: text/caddyfile +``` +{ + skip_install_trust + http_port 9080 + https_port 9443 + local_certs + debug +} +localhost { + root {{indexed_root}} + file_server +} +``` + +# requests without specific file receive index file per +# the default index list: index.html, index.txt +GET https://localhost:9443 +[Options] +insecure: true +HTTP 200 +[Asserts] +``` + + + + Index.html Title + + + Index.html + +``` + + +# if index.txt is specifically requested, we expect index.txt +GET https://localhost:9443/index.txt +[Options] +insecure: true +HTTP 200 +[Asserts] +body == "index.txt" + +# requests for sub-folder followed by .. result in sanitized path +GET https://localhost:9443/non-existent/../index.txt +[Options] +insecure: true +HTTP 200 +[Asserts] +body == "index.txt" + +# results out of root folder are sanitized, +# and conform to default index list sequence. +GET https://localhost:9443/../ +[Options] +insecure: true +HTTP 200 +[Asserts] +``` + + + + Index.html Title + + + Index.html + +``` + + +# Configure Caddy with custsom index "index.txt" +POST http://localhost:2019/load +Content-Type: text/caddyfile +``` +{ + skip_install_trust + http_port 9080 + https_port 9443 + local_certs + debug +} +localhost { + root {{indexed_root}} + file_server { + index index.txt + } +} +``` + +GET https://localhost:9443 +[Options] +insecure: true +HTTP 200 +[Asserts] +body == "index.txt" + + +# Configure with a root not containing index files +POST http://localhost:2019/load +Content-Type: text/caddyfile +``` +{ + skip_install_trust + http_port 9080 + https_port 9443 + local_certs + debug +} +localhost { + root {{unindexed_root}} + file_server +} +``` + +GET https://localhost:9443 +[Options] +insecure: true +HTTP 404 \ No newline at end of file diff --git a/caddytest/spec/hurl_vars.properties b/caddytest/spec/hurl_vars.properties new file mode 100644 index 00000000000..a3832eaead4 --- /dev/null +++ b/caddytest/spec/hurl_vars.properties @@ -0,0 +1,2 @@ +indexed_root=caddytest/spec/http/file_server/assets/indexed +unindexed_root=caddytest/spec/http/file_server/assets/unindexed \ No newline at end of file From 8d2ed344c1a1772cbe23966aff97d1dd695029fd Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Mon, 9 Sep 2024 08:29:23 +0000 Subject: [PATCH 04/12] update hurl to 5.0.1 --- .github/workflows/ci.yml | 105 +++++++++++++++++++++++++++++++-------- 1 file changed, 83 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cba485386b9..a694dcb524d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -129,45 +129,106 @@ jobs: go test -tags nobadger -v -coverprofile="cover-profile.out" -short -race ./... # echo "status=$?" >> $GITHUB_OUTPUT - - name: Install Hurl - if: matrix.os == 'linux' && matrix.go == '1.22' + # Relevant step if we reinvestigate publishing test/coverage reports + # - name: Prepare coverage reports + # run: | + # mkdir coverage + # gocov convert cover-profile.out > coverage/coverage.json + # # Because Windows doesn't work with input redirection like *nix, but output redirection works. + # (cat ./coverage/coverage.json | gocov-xml) > coverage/coverage.xml + + # To return the correct result even though we set 'continue-on-error: true' + # - name: Coerce correct build result + # if: matrix.os != 'windows' && steps.step_test.outputs.status != ${{ matrix.SUCCESS }} + # run: | + # echo "step_test ${{ steps.step_test.outputs.status }}\n" + # exit 1 + + spec-test: + permissions: + checks: write + pull-requests: write + strategy: + matrix: + os: + - linux + go: + - '1.23' + + include: + # Set the minimum Go patch version for the given Go minor + # Usable via ${{ matrix.GO_SEMVER }} + - go: '1.23' + GO_SEMVER: '~1.23.0' + + # Set some variables per OS, usable via ${{ matrix.VAR }} + # OS_LABEL: the VM label from GitHub Actions (see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories) + # CADDY_BIN_PATH: the path to the compiled Caddy binary, for artifact publishing + # SUCCESS: the typical value for $? per OS (Windows/pwsh returns 'True') + - os: linux + OS_LABEL: ubuntu-latest + CADDY_BIN_PATH: ./cmd/caddy/caddy + SUCCESS: 0 + + runs-on: ${{ matrix.OS_LABEL }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.GO_SEMVER }} + check-latest: true + + - name: Print Go version and environment + id: vars + shell: bash run: | - curl --location --remote-name https://github.com/Orange-OpenSource/hurl/releases/download/4.2.0/hurl_4.2.0_amd64.deb - sudo dpkg -i hurl_4.2.0_amd64.deb + printf "Using go at: $(which go)\n" + printf "Go version: $(go version)\n" + printf "\n\nGo environment:\n\n" + go env + printf "\n\nSystem environment:\n\n" + env + printf "Git version: $(git version)\n\n" + # Calculate the short SHA1 hash of the git commit + echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + - name: Get dependencies + run: | + go get -v -t -d ./... + # mkdir test-results + - name: Build Caddy + working-directory: ./cmd/caddy + env: + CGO_ENABLED: 0 + run: | + go build -tags nobadger -trimpath -ldflags="-w -s" -v + + - name: Install Hurl + env: + HURL_VERSION: "5.0.1" + run: | + curl --location --remote-name https://github.com/Orange-OpenSource/hurl/releases/download/${HURL_VERSION}/hurl_${HURL_VERSION}_amd64.deb + sudo dpkg -i hurl_${HURL_VERSION}_amd64.deb + - name: Run Caddy - if: matrix.os == 'linux' && matrix.go == '1.22' run: | ./cmd/caddy/caddy start - name: Run tests with Hurl - if: matrix.os == 'linux' && matrix.go == '1.22' run: | mkdir hurl-report find . -name *.hurl -exec hurl --variables-file caddytest/spec/hurl_vars.properties --very-verbose --verbose --test --report-junit hurl-report/junit.xml --color {} \; - name: Publish Test Results - if: matrix.os == 'linux' && matrix.go == '1.22' uses: EnricoMi/publish-unit-test-result-action@v2 with: files: | hurl-report/junit.xml - # Relevant step if we reinvestigate publishing test/coverage reports - # - name: Prepare coverage reports - # run: | - # mkdir coverage - # gocov convert cover-profile.out > coverage/coverage.json - # # Because Windows doesn't work with input redirection like *nix, but output redirection works. - # (cat ./coverage/coverage.json | gocov-xml) > coverage/coverage.xml - - # To return the correct result even though we set 'continue-on-error: true' - # - name: Coerce correct build result - # if: matrix.os != 'windows' && steps.step_test.outputs.status != ${{ matrix.SUCCESS }} - # run: | - # echo "step_test ${{ steps.step_test.outputs.status }}\n" - # exit 1 - s390x-test: name: test (s390x on IBM Z) runs-on: ubuntu-latest From 01ae168f92b2419b4569643a9748333376661362 Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Mon, 9 Sep 2024 11:22:28 +0000 Subject: [PATCH 05/12] print curl and hurl versions --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a694dcb524d..faff8b4f125 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -186,6 +186,7 @@ jobs: id: vars shell: bash run: | + printf "curl version: $(curl --version)\n" printf "Using go at: $(which go)\n" printf "Go version: $(go version)\n" printf "\n\nGo environment:\n\n" @@ -213,6 +214,7 @@ jobs: run: | curl --location --remote-name https://github.com/Orange-OpenSource/hurl/releases/download/${HURL_VERSION}/hurl_${HURL_VERSION}_amd64.deb sudo dpkg -i hurl_${HURL_VERSION}_amd64.deb + hurl --version - name: Run Caddy run: | From 9ba7ea76a9b0f0041a81a4b6f513f80499929c29 Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Tue, 29 Oct 2024 20:52:17 +0000 Subject: [PATCH 06/12] add test case for `request_body` handler --- caddytest/spec/http/requestbody/spec.hurl | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 caddytest/spec/http/requestbody/spec.hurl diff --git a/caddytest/spec/http/requestbody/spec.hurl b/caddytest/spec/http/requestbody/spec.hurl new file mode 100644 index 00000000000..3971fddd385 --- /dev/null +++ b/caddytest/spec/http/requestbody/spec.hurl @@ -0,0 +1,35 @@ +# Configure Caddy +POST http://localhost:2019/load +Content-Type: text/caddyfile +``` +{ + skip_install_trust + http_port 9080 + https_port 9443 + local_certs +} +localhost { + log + request_body { + max_size 2B + } + reverse_proxy localhost:8000 # to fake body reading + handle_errors 4xx { + respond "OK" + } +} +http://localhost:8000 { + respond "Failed" +} +``` + +GET https://localhost:9443 +[Options] +insecure: true +``` +Hello +``` +HTTP 413 +`OK` + +# TODO: how to test{read,write}_timeout? \ No newline at end of file From b34c13c5cf793fde313c292e40c029a73ffcd78a Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Tue, 29 Oct 2024 21:10:09 +0000 Subject: [PATCH 07/12] limit hurl jobs to 1 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d87956c880..4382dbf6774 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -222,7 +222,7 @@ jobs: - name: Run tests with Hurl run: | mkdir hurl-report - find . -name *.hurl -exec hurl --variables-file caddytest/spec/hurl_vars.properties --very-verbose --verbose --test --report-junit hurl-report/junit.xml --color {} \; + find . -name *.hurl --jobs 1 -exec hurl --variables-file caddytest/spec/hurl_vars.properties --very-verbose --verbose --test --report-junit hurl-report/junit.xml --color {} \; - name: Publish Test Results uses: EnricoMi/publish-unit-test-result-action@v2 From ddc2ca3e106e4bb603c333466074877c00f96341 Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Tue, 29 Oct 2024 21:13:00 +0000 Subject: [PATCH 08/12] use Caddy CA in hurl options --- .github/workflows/ci.yml | 2 +- caddytest/spec/http/requestbody/spec.hurl | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4382dbf6774..99cc26d3c0e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -222,7 +222,7 @@ jobs: - name: Run tests with Hurl run: | mkdir hurl-report - find . -name *.hurl --jobs 1 -exec hurl --variables-file caddytest/spec/hurl_vars.properties --very-verbose --verbose --test --report-junit hurl-report/junit.xml --color {} \; + find . -name *.hurl -exec hurl --cacert $HOME/.local/share/caddy/pki/authorities/local/root.crt --jobs 1 --variables-file caddytest/spec/hurl_vars.properties --very-verbose --verbose --test --report-junit hurl-report/junit.xml --color {} \; - name: Publish Test Results uses: EnricoMi/publish-unit-test-result-action@v2 diff --git a/caddytest/spec/http/requestbody/spec.hurl b/caddytest/spec/http/requestbody/spec.hurl index 0e2809f3964..65a5912dd33 100644 --- a/caddytest/spec/http/requestbody/spec.hurl +++ b/caddytest/spec/http/requestbody/spec.hurl @@ -25,7 +25,6 @@ http://localhost:8000 { GET https://localhost:9443 [Options] -cacert: /home/codespace/.local/share/caddy/pki/authorities/local/root.crt ``` Hello ``` From 7ea59f0d4980d0e7a6124bb0d8083734bb8b9403 Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Tue, 29 Oct 2024 21:23:34 +0000 Subject: [PATCH 09/12] remove of `--cafile` in hurl --- .github/workflows/ci.yml | 2 +- caddytest/spec/http/requestbody/spec.hurl | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99cc26d3c0e..ef965da34af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -222,7 +222,7 @@ jobs: - name: Run tests with Hurl run: | mkdir hurl-report - find . -name *.hurl -exec hurl --cacert $HOME/.local/share/caddy/pki/authorities/local/root.crt --jobs 1 --variables-file caddytest/spec/hurl_vars.properties --very-verbose --verbose --test --report-junit hurl-report/junit.xml --color {} \; + find . -name *.hurl -exec hurl --jobs 1 --variables-file caddytest/spec/hurl_vars.properties --very-verbose --verbose --test --report-junit hurl-report/junit.xml --color {} \; - name: Publish Test Results uses: EnricoMi/publish-unit-test-result-action@v2 diff --git a/caddytest/spec/http/requestbody/spec.hurl b/caddytest/spec/http/requestbody/spec.hurl index 65a5912dd33..3971fddd385 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] +insecure: true ``` Hello ``` From 25d94ffe2ac588d340534e03e441dea3fadfccdc Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Tue, 29 Oct 2024 21:37:09 +0000 Subject: [PATCH 10/12] 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 ef965da34af..9487da36c5c 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 3971fddd385..3abf56e96f5 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 From e75fca007e74bab24e84c174c6a672a8637519dc Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Thu, 31 Oct 2024 07:23:43 +0000 Subject: [PATCH 11/12] include txt and html coverage profile --- .github/workflows/ci.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9487da36c5c..f7769803731 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -237,15 +237,14 @@ jobs: 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 + go tool covdata textfmt -i=coverdir -o hurl-report/caddy_cover_${{ steps.vars.outputs.short_sha }}.txt + go tool cover -html hurl-report/caddy_cover_${{ steps.vars.outputs.short_sha }}.txt -o hurl-report/caddy_cover_${{ steps.vars.outputs.short_sha }}.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" + path: hurl-report/caddy_cover_${{ steps.vars.outputs.short_sha }}.* compression-level: 0 s390x-test: From c7187444839c2c3e094dd9d95c32668fa92da710 Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Thu, 31 Oct 2024 07:39:31 +0000 Subject: [PATCH 12/12] Keep report to HTML only --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7769803731..dcd2fd19fab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -244,7 +244,7 @@ jobs: - name: Publish Coverage Profile uses: actions/upload-artifact@v4 with: - path: hurl-report/caddy_cover_${{ steps.vars.outputs.short_sha }}.* + path: hurl-report/caddy_cover_${{ steps.vars.outputs.short_sha }}.html compression-level: 0 s390x-test: