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