From bdc72e79b8b3d0badb57e6953a170a16b1c77b06 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 17 Mar 2020 02:21:09 -0400 Subject: [PATCH 01/36] WIP: Trying to make a new branch --- .github/workflows/ci.yml | 113 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000..7d8f7d5b544 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,113 @@ +# Used as inspiration: https://github.com/mvdan/github-actions-golang + +name: Cross-Platform Tests + +on: + push: + branches: [ v2 ] + pull_request: + branches: [ v2 ] + +jobs: + test: + name: Cross-Platform Tests + + strategy: + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + go-version: [ 1.14.x ] + runs-on: ${{ matrix.os }} + + steps: + - name: Install Go + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go-version }} + + - name: Checkout code + uses: actions/checkout@v2 + + # TODO May not be required + - name: Install golangci-lint + run: | + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.6 + + - name: Install test and coverage analysis tools + run: | + go get github.com/axw/gocov/gocov + go get github.com/AlekSi/gocov-xml + go get -u github.com/jstemmer/go-junit-report + + - name: Print Go version and environment + run: | + 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 + + - name: Get dependencies + run: | + go get -v -t -d ./... + mkdir test-results + + # TODO Might not be in the correct dir at this point + - name: Build Caddy + run: | + CGO_ENABLED=0 go build -trimpath -a -ldflags="-w -s" -v + + # TODO Publish build artifacts (figure out output path) + # - name: Publish Build Artifact (Windows) + # if: matrix.platform == 'windows-latest' + # uses: actions/upload-artifact@v1 + # with: + # name: caddy_v2_${{ matrix.os }} + # path: ${{ env.somewhere }}/cmd/caddy/caddy.exe + + # - name: Publish Build Artifact (Linux/Mac) + # if: matrix.platform != 'windows-latest' + # uses: actions/upload-artifact@v1 + # with: + # name: caddy_v2_${{ matrix.os }} + # path: ${{ env.somewhere }}/cmd/caddy/caddy + + # TODO I don't think github actions supports junit reports, + # we should probably just send this stuff to stdout + # TODO set-output may be incorrect, see https://stackoverflow.com/questions/57850553/github-actions-check-steps-status + - name: Run lint check + id: step_lint + continue-on-error: true + run: | + (golangci-lint run --out-format junit-xml) > test-results/lint-result.xml + echo "::set-output name=status::$?" + + # TODO working dir might be wrong + - name: Run tests + id: step_test + continue-on-error: true + run: | + (go test -v -coverprofile=cover-profile.out -race ./... 2>&1) > test-results/test-result.out + echo "::set-output name=status::$?" + + - name: Run integration tests + run: | + set -e + cmd/caddy/caddy start + go test -v -count=1 ./caddytest/... + cmd/caddy/caddy stop + + - 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 + + # TODO publish coverage/lint/test results ? + + # To return the correct result even though we set 'continue-on-error: true' + - name: Coerce correct build result + if: steps.step_lint.outputs.status != 0 || steps.step_test.outputs.status != 0 + run: | + exit 1 From c67b7ccc1e5a663b943c2226d3d2112a421a2584 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 17 Mar 2020 02:29:01 -0400 Subject: [PATCH 02/36] Create fuzzing.yml --- .github/workflows/fuzzing.yml | 75 +++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/fuzzing.yml diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml new file mode 100644 index 00000000000..bba1369845e --- /dev/null +++ b/.github/workflows/fuzzing.yml @@ -0,0 +1,75 @@ +name: Fuzzing + +on: + schedule: + # Daily midnight fuzzing + - cron: '0 0 * * *' + +jobs: + fuzzing: + name: Fuzzing + + strategy: + matrix: + os: [ ubuntu-latest ] + go-version: [ 1.14.x ] + runs-on: ${{ matrix.os }} + + steps: + - name: Install Go + uses: actions/setup-go@v1 + with: + go-version: ${{ matrix.go-version }} + + # - name: Checkout code + # uses: actions/checkout@v2 + + # TODO env GOBIN may not be set + # TODO should have if condition to disable for forks? + - name: Download go-fuzz tools and the Fuzzit CLI, move Fuzzit CLI to GOBIN + # if: isFork == false + run: | + # Install Clang-7.0 because other versions seem to be missing the file libclang_rt.fuzzer-x86_64.a + sudo add-apt-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main" + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo apt update && sudo apt install -y clang-7 lldb-7 lld-7 + + go get -v github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build + wget -q -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v2.4.77/fuzzit_Linux_x86_64 + chmod a+x fuzzit + mv fuzzit $(GOBIN) + + # TODO $(Build.Reason) is probably not set + - name: Download go-fuzz tools and the Fuzzit CLI, move Fuzzit CLI to GOBIN + env: + FUZZIT_API_KEY: ${{ secrets.FUZZIT_API_KEY }} + run: | + declare -A fuzzers_funcs=(\ + ["./caddyconfig/httpcaddyfile/addresses_fuzz.go"]="FuzzParseAddress" \ + ["./caddyconfig/caddyfile/parse_fuzz.go"]="FuzzParseCaddyfile" \ + ["./listeners_fuzz.go"]="FuzzParseNetworkAddress" \ + ["./replacer_fuzz.go"]="FuzzReplacer" \ + ) + + declare -A fuzzers_targets=(\ + ["./caddyconfig/httpcaddyfile/addresses_fuzz.go"]="parse-address" \ + ["./caddyconfig/caddyfile/parse_fuzz.go"]="parse-caddyfile" \ + ["./listeners_fuzz.go"]="parse-network-address" \ + ["./replacer_fuzz.go"]="replacer" \ + ) + + fuzz_type="local-regression" + if [[ $(Build.Reason) == "Schedule" ]]; then + fuzz_type="fuzzing" + fi + echo "Fuzzing type: $fuzz_type" + + for f in $(find . -name \*_fuzz.go); do + FUZZER_DIRECTORY=$(dirname $f) + echo "go-fuzz-build func ${fuzzers_funcs[$f]} residing in $f" + go-fuzz-build -func "${fuzzers_funcs[$f]}" -libfuzzer -o "$FUZZER_DIRECTORY/${fuzzers_targets[$f]}.a" $FUZZER_DIRECTORY + echo "Generating fuzzer binary of func ${fuzzers_funcs[$f]} which resides in $f" + clang-7 -fsanitize=fuzzer "$FUZZER_DIRECTORY/${fuzzers_targets[$f]}.a" -o "$FUZZER_DIRECTORY/${fuzzers_targets[$f]}" + fuzzit create job caddyserver/${fuzzers_targets[$f]} $FUZZER_DIRECTORY/${fuzzers_targets[$f]} --api-key ${FUZZIT_API_KEY} --type "${fuzz_type}" --branch "${SYSTEM_PULLREQUEST_SOURCEBRANCH}" --revision "${BUILD_SOURCEVERSION}" + echo "Completed $f" + done From cb6b63897b6a9511bc18bf9f64d7b776a4572e67 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 17 Mar 2020 02:32:05 -0400 Subject: [PATCH 03/36] Update ci.yml --- .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 7d8f7d5b544..ce3ca77d36c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,7 +79,7 @@ jobs: id: step_lint continue-on-error: true run: | - (golangci-lint run --out-format junit-xml) > test-results/lint-result.xml + ($(go env GOPATH)/bin/golangci-lint run --out-format junit-xml) > test-results/lint-result.xml echo "::set-output name=status::$?" # TODO working dir might be wrong From 403b4c34b6a5a41cdc38838dbd31d820ed9288bb Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 17 Mar 2020 02:40:39 -0400 Subject: [PATCH 04/36] Try using reviewdog for golangci-lint --- .github/workflows/ci.yml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce3ca77d36c..b4649a1accd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,11 +27,6 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - # TODO May not be required - - name: Install golangci-lint - run: | - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.6 - - name: Install test and coverage analysis tools run: | go get github.com/axw/gocov/gocov @@ -72,17 +67,13 @@ jobs: # name: caddy_v2_${{ matrix.os }} # path: ${{ env.somewhere }}/cmd/caddy/caddy - # TODO I don't think github actions supports junit reports, - # we should probably just send this stuff to stdout - # TODO set-output may be incorrect, see https://stackoverflow.com/questions/57850553/github-actions-check-steps-status - name: Run lint check - id: step_lint - continue-on-error: true - run: | - ($(go env GOPATH)/bin/golangci-lint run --out-format junit-xml) > test-results/lint-result.xml - echo "::set-output name=status::$?" + uses: reviewdog/action-golangci-lint@v1 + with: + github_token: ${{ secrets.github_token }} # TODO working dir might be wrong + # TODO set-output may be incorrect, see https://stackoverflow.com/questions/57850553/github-actions-check-steps-status - name: Run tests id: step_test continue-on-error: true From 4da0b2013ebfa9bad0194302ddb8c8852f29e1e2 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 17 Mar 2020 02:51:12 -0400 Subject: [PATCH 05/36] Only run lint on ubuntu --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4649a1accd..2980da694a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,9 @@ jobs: # name: caddy_v2_${{ matrix.os }} # path: ${{ env.somewhere }}/cmd/caddy/caddy + # Only run lint on ubuntu, the reviewdog action uses docker - name: Run lint check + if: matrix.platform == 'ubuntu-latest' uses: reviewdog/action-golangci-lint@v1 with: github_token: ${{ secrets.github_token }} From 1d02adc2be2faf95f7f6b66443419c7fe9d95ba9 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 17 Mar 2020 02:53:36 -0400 Subject: [PATCH 06/36] Whoops, wrong matrix variable --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2980da694a2..9675d7424c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,14 +54,14 @@ jobs: # TODO Publish build artifacts (figure out output path) # - name: Publish Build Artifact (Windows) - # if: matrix.platform == 'windows-latest' + # if: matrix.os == 'windows-latest' # uses: actions/upload-artifact@v1 # with: # name: caddy_v2_${{ matrix.os }} # path: ${{ env.somewhere }}/cmd/caddy/caddy.exe # - name: Publish Build Artifact (Linux/Mac) - # if: matrix.platform != 'windows-latest' + # if: matrix.os != 'windows-latest' # uses: actions/upload-artifact@v1 # with: # name: caddy_v2_${{ matrix.os }} @@ -69,7 +69,7 @@ jobs: # Only run lint on ubuntu, the reviewdog action uses docker - name: Run lint check - if: matrix.platform == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' uses: reviewdog/action-golangci-lint@v1 with: github_token: ${{ secrets.github_token }} From 92c38033e6d3b7584c22cbf8cf7f13bde19dc614 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 17 Mar 2020 03:09:20 -0400 Subject: [PATCH 07/36] Let's try just ubuntu for the moment --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9675d7424c1..cad4712834d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,8 @@ jobs: strategy: matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] + # os: [ ubuntu-latest, macos-latest, windows-latest ] + os: [ ubuntu-latest ] go-version: [ 1.14.x ] runs-on: ${{ matrix.os }} From 34ba43e2bc5a3e28504e1c1b286137f7b86ccc5f Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 20:15:00 -0400 Subject: [PATCH 08/36] Remove integration tests --- .github/workflows/ci.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cad4712834d..43035443358 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,13 +84,6 @@ jobs: (go test -v -coverprofile=cover-profile.out -race ./... 2>&1) > test-results/test-result.out echo "::set-output name=status::$?" - - name: Run integration tests - run: | - set -e - cmd/caddy/caddy start - go test -v -count=1 ./caddytest/... - cmd/caddy/caddy stop - - name: Prepare coverage reports run: | mkdir coverage From 4cedbfdc2daaf315a1d6ff4aca5562885de83a8e Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 20:16:16 -0400 Subject: [PATCH 09/36] Let's see what the tree looks like (where's the binary) --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 43035443358..9f46de570d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,6 +53,10 @@ jobs: run: | CGO_ENABLED=0 go build -trimpath -a -ldflags="-w -s" -v + - name: Tree + run: | + tree + # TODO Publish build artifacts (figure out output path) # - name: Publish Build Artifact (Windows) # if: matrix.os == 'windows-latest' From 029e190373e07b060559860950bfdc6762c515eb Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 20:19:27 -0400 Subject: [PATCH 10/36] Let's plant a tree --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f46de570d3..7d65160e6bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,7 @@ jobs: - name: Tree run: | + sudo apt install tree tree # TODO Publish build artifacts (figure out output path) From 19196bb6011132a2d92e6f2474f22dcdf548d907 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 20:50:37 -0400 Subject: [PATCH 11/36] Let's look at another tree --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d65160e6bf..596a6a08059 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,7 +56,9 @@ jobs: - name: Tree run: | sudo apt install tree - tree + tree ~ + printf "GOPATH $GOPATH" + tree $GOPATH # TODO Publish build artifacts (figure out output path) # - name: Publish Build Artifact (Windows) From 9e7e4f45c9c34336ea74ddc72d6728e50ef46700 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 20:57:46 -0400 Subject: [PATCH 12/36] Burn the tree --- .github/workflows/ci.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 596a6a08059..43035443358 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,13 +53,6 @@ jobs: run: | CGO_ENABLED=0 go build -trimpath -a -ldflags="-w -s" -v - - name: Tree - run: | - sudo apt install tree - tree ~ - printf "GOPATH $GOPATH" - tree $GOPATH - # TODO Publish build artifacts (figure out output path) # - name: Publish Build Artifact (Windows) # if: matrix.os == 'windows-latest' From 0e8e9289e000bf1d62e6f3a971b28032b9eda3df Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 21:03:56 -0400 Subject: [PATCH 13/36] Let's build in the right dir --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 43035443358..db938ae0830 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,8 +50,11 @@ jobs: # TODO Might not be in the correct dir at this point - name: Build Caddy + working-directory: ./cmd/caddy run: | CGO_ENABLED=0 go build -trimpath -a -ldflags="-w -s" -v + pwd + ls -la # TODO Publish build artifacts (figure out output path) # - name: Publish Build Artifact (Windows) From 5750efd5e0e6e56a2460bebe2acec07d348d7436 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 21:12:23 -0400 Subject: [PATCH 14/36] Turn on publishing artifacts --- .github/workflows/ci.yml | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db938ae0830..f1c2ec54dea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,23 +53,20 @@ jobs: working-directory: ./cmd/caddy run: | CGO_ENABLED=0 go build -trimpath -a -ldflags="-w -s" -v - pwd - ls -la - - # TODO Publish build artifacts (figure out output path) - # - name: Publish Build Artifact (Windows) - # if: matrix.os == 'windows-latest' - # uses: actions/upload-artifact@v1 - # with: - # name: caddy_v2_${{ matrix.os }} - # path: ${{ env.somewhere }}/cmd/caddy/caddy.exe - - # - name: Publish Build Artifact (Linux/Mac) - # if: matrix.os != 'windows-latest' - # uses: actions/upload-artifact@v1 - # with: - # name: caddy_v2_${{ matrix.os }} - # path: ${{ env.somewhere }}/cmd/caddy/caddy + + - name: Publish Build Artifact (Windows) + if: matrix.os == 'windows-latest' + uses: actions/upload-artifact@v1 + with: + name: caddy_v2_${{ matrix.os }} + path: ./cmd/caddy/caddy.exe + + - name: Publish Build Artifact (Linux/Mac) + if: matrix.os != 'windows-latest' + uses: actions/upload-artifact@v1 + with: + name: caddy_v2_${{ matrix.os }} + path: ./cmd/caddy/caddy # Only run lint on ubuntu, the reviewdog action uses docker - name: Run lint check From b3a6dd1d4fdc8b6088d7c71359fe46fce33b411e Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 21:24:46 -0400 Subject: [PATCH 15/36] Add gobin to path --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1c2ec54dea..fbbecbe36b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,7 @@ jobs: go get github.com/axw/gocov/gocov go get github.com/AlekSi/gocov-xml go get -u github.com/jstemmer/go-junit-report + echo "::add-path::$(go env GOPATH)/bin" - name: Print Go version and environment run: | From a037377d6c36b2937813db85f95b8a6f962eaf5d Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 21:46:21 -0400 Subject: [PATCH 16/36] Try running golangci-lint earlier --- .github/workflows/ci.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fbbecbe36b7..48a664f258a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,13 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + # Only run lint on ubuntu, the reviewdog action uses docker + - name: Run lint check + if: matrix.os == 'ubuntu-latest' + uses: reviewdog/action-golangci-lint@v1 + with: + github_token: ${{ secrets.github_token }} + - name: Install test and coverage analysis tools run: | go get github.com/axw/gocov/gocov @@ -47,7 +54,7 @@ jobs: - name: Get dependencies run: | go get -v -t -d ./... - mkdir test-results + # mkdir test-results # TODO Might not be in the correct dir at this point - name: Build Caddy @@ -69,20 +76,13 @@ jobs: name: caddy_v2_${{ matrix.os }} path: ./cmd/caddy/caddy - # Only run lint on ubuntu, the reviewdog action uses docker - - name: Run lint check - if: matrix.os == 'ubuntu-latest' - uses: reviewdog/action-golangci-lint@v1 - with: - github_token: ${{ secrets.github_token }} - - # TODO working dir might be wrong - # TODO set-output may be incorrect, see https://stackoverflow.com/questions/57850553/github-actions-check-steps-status + # For info about set-output, see https://stackoverflow.com/questions/57850553/github-actions-check-steps-status - name: Run tests id: step_test continue-on-error: true run: | - (go test -v -coverprofile=cover-profile.out -race ./... 2>&1) > test-results/test-result.out + # (go test -v -coverprofile=cover-profile.out -race ./... 2>&1) > test-results/test-result.out + go test -v -coverprofile=cover-profile.out -race ./... echo "::set-output name=status::$?" - name: Prepare coverage reports From 022d5b07f2f4be8327e66eee6bd14336f1062178 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 21:50:39 -0400 Subject: [PATCH 17/36] Try running golangci-lint on its own, with checkout@v1 --- .github/workflows/ci.yml | 10 +++++----- .github/workflows/golangci-lint.yml | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/golangci-lint.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48a664f258a..e57494c58c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,11 +29,11 @@ jobs: uses: actions/checkout@v2 # Only run lint on ubuntu, the reviewdog action uses docker - - name: Run lint check - if: matrix.os == 'ubuntu-latest' - uses: reviewdog/action-golangci-lint@v1 - with: - github_token: ${{ secrets.github_token }} + # - name: Run lint check + # if: matrix.os == 'ubuntu-latest' + # uses: reviewdog/action-golangci-lint@v1 + # with: + # github_token: ${{ secrets.github_token }} - name: Install test and coverage analysis tools run: | diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 00000000000..fe1ce2b12ae --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,21 @@ +name: golangci-lint + +on: + push: + branches: [ v2 ] + pull_request: + branches: [ v2 ] + +jobs: + golangci-lint: + name: runner / golangci-lint + runs-on: ubuntu-latest + steps: + - name: Checkout code into the Go module directory + uses: actions/checkout@v1 + + - name: Run golangci-lint + uses: reviewdog/action-golangci-lint@v1 + # uses: docker://reviewdog/action-golangci-lint:v1 # pre-build docker image + with: + github_token: ${{ secrets.github_token }} \ No newline at end of file From 3123bb51a3e85100c7d388eca64530ee25cccfde Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 21:59:41 -0400 Subject: [PATCH 18/36] Try moving golangci-lint back into ci.yml as a separate job --- .github/workflows/ci.yml | 15 ++++++++++++++- .github/workflows/golangci-lint.yml | 21 --------------------- 2 files changed, 14 insertions(+), 22 deletions(-) delete mode 100644 .github/workflows/golangci-lint.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e57494c58c6..6ba2a3ef014 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ on: branches: [ v2 ] jobs: - test: + build-and-test: name: Cross-Platform Tests strategy: @@ -99,3 +99,16 @@ jobs: if: steps.step_lint.outputs.status != 0 || steps.step_test.outputs.status != 0 run: | exit 1 + + golangci-lint: + name: runner / golangci-lint + runs-on: ubuntu-latest + steps: + - name: Checkout code into the Go module directory + uses: actions/checkout@v1 + + - name: Run golangci-lint + uses: reviewdog/action-golangci-lint@v1 + # uses: docker://reviewdog/action-golangci-lint:v1 # pre-build docker image + with: + github_token: ${{ secrets.github_token }} \ No newline at end of file diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml deleted file mode 100644 index fe1ce2b12ae..00000000000 --- a/.github/workflows/golangci-lint.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: golangci-lint - -on: - push: - branches: [ v2 ] - pull_request: - branches: [ v2 ] - -jobs: - golangci-lint: - name: runner / golangci-lint - runs-on: ubuntu-latest - steps: - - name: Checkout code into the Go module directory - uses: actions/checkout@v1 - - - name: Run golangci-lint - uses: reviewdog/action-golangci-lint@v1 - # uses: docker://reviewdog/action-golangci-lint:v1 # pre-build docker image - with: - github_token: ${{ secrets.github_token }} \ No newline at end of file From 8ead75961a2d173f402578745f25eb8e5519ca36 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 22:00:35 -0400 Subject: [PATCH 19/36] Turn off azure-pipelines --- azure-pipelines.yml | 263 -------------------------------------------- 1 file changed, 263 deletions(-) delete mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 1829cdec253..00000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,263 +0,0 @@ -# Mutilated beyond recognition from the example at: -# https://docs.microsoft.com/azure/devops/pipelines/languages/go - -trigger: - - v2 - -schedules: -- cron: "0 0 * * *" - displayName: Daily midnight fuzzing - branches: - include: - - v2 - always: true - -variables: - GOROOT: $(gorootDir)/go - GOPATH: $(system.defaultWorkingDirectory)/gopath - GOBIN: $(GOPATH)/bin - modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' - -jobs: -- job: crossPlatformTest - displayName: "Cross-Platform Tests" - strategy: - matrix: - linux: - imageName: ubuntu-16.04 - gorootDir: /usr/local - mac: - imageName: macos-10.14 - gorootDir: /usr/local - windows: - imageName: windows-2019 - gorootDir: C:\ - pool: - vmImage: $(imageName) - - steps: - - bash: | - latestGo=$(curl "https://golang.org/VERSION?m=text") - echo "##vso[task.setvariable variable=LATEST_GO]$latestGo" - echo "Latest Go version: $latestGo" - displayName: "Get latest Go version" - - - bash: | - sudo rm -f $(which go) - echo '##vso[task.prependpath]$(GOBIN)' - echo '##vso[task.prependpath]$(GOROOT)/bin' - mkdir -p '$(modulePath)' - shopt -s extglob - shopt -s dotglob - mv !(gopath) '$(modulePath)' - displayName: Remove old Go, set GOBIN/GOROOT, and move project into GOPATH - - # Install Go (this varies by platform) - - bash: | - wget "https://dl.google.com/go/$(LATEST_GO).linux-amd64.tar.gz" - sudo tar -C $(gorootDir) -xzf "$(LATEST_GO).linux-amd64.tar.gz" - condition: eq( variables['Agent.OS'], 'Linux' ) - displayName: Install Go on Linux - - - bash: | - wget "https://dl.google.com/go/$(LATEST_GO).darwin-amd64.tar.gz" - sudo tar -C $(gorootDir) -xzf "$(LATEST_GO).darwin-amd64.tar.gz" - condition: eq( variables['Agent.OS'], 'Darwin' ) - displayName: Install Go on macOS - - # The low performance is partly due to PowerShell's attempt to update the progress bar. Disabling it speeds up the process. - # Reference: https://github.com/PowerShell/PowerShell/issues/2138 - - powershell: | - $ProgressPreference = 'SilentlyContinue' - Write-Host "Downloading Go..." - (New-Object System.Net.WebClient).DownloadFile("https://dl.google.com/go/$(LATEST_GO).windows-amd64.zip", "$(LATEST_GO).windows-amd64.zip") - Write-Host "Extracting Go... (I'm slow too)" - 7z x "$(LATEST_GO).windows-amd64.zip" -o"$(gorootDir)" - condition: eq( variables['Agent.OS'], 'Windows_NT' ) - displayName: Install Go on Windows - - - bash: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.6 - displayName: Install golangci-lint - - - script: | - go get github.com/axw/gocov/gocov - go get github.com/AlekSi/gocov-xml - go get -u github.com/jstemmer/go-junit-report - displayName: Install test and coverage analysis tools - - - bash: | - 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 - displayName: Print Go version and environment - - - script: | - go get -v -t -d ./... - mkdir test-results - workingDirectory: '$(modulePath)' - displayName: Get dependencies - - - bash: CGO_ENABLED=0 go build -trimpath -a -ldflags="-w -s" -v - workingDirectory: '$(modulePath)/cmd/caddy' - displayName: Build Caddy - - - task: PublishBuildArtifacts@1 - condition: eq( variables['Agent.OS'], 'Windows_NT' ) - inputs: - pathtoPublish: '$(modulePath)/cmd/caddy/caddy.exe' - artifactName: caddy_v2.exe - - - task: PublishBuildArtifacts@1 - condition: ne( variables['Agent.OS'], 'Windows_NT' ) - inputs: - pathtoPublish: '$(modulePath)/cmd/caddy/caddy' - artifactName: 'caddy_v2_$(Agent.OS)' - - # its behavior is governed by .golangci.yml - - script: | - (golangci-lint run --out-format junit-xml) > test-results/lint-result.xml - exit 0 - workingDirectory: '$(modulePath)' - continueOnError: true - displayName: Run lint check - - - script: | - (go test -v -coverprofile=cover-profile.out -race ./... 2>&1) > test-results/test-result.out - workingDirectory: '$(modulePath)' - continueOnError: true - displayName: Run tests - - - script: | - set -e - cmd/caddy/caddy start - go test -v -count=1 ./caddytest/... - cmd/caddy/caddy stop - workingDirectory: '$(modulePath)' - continueOnError: false - displayName: Run Integration tests - - - script: | - 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 - workingDirectory: '$(modulePath)' - displayName: Prepare coverage reports - - - script: | - (cat ./test-results/test-result.out | go-junit-report) > test-results/test-result.xml - workingDirectory: '$(modulePath)' - displayName: Prepare test report - - - task: PublishCodeCoverageResults@1 - displayName: Publish test coverage report - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: $(modulePath)/coverage/coverage.xml - - - task: PublishTestResults@2 - displayName: Publish unit test - inputs: - testResultsFormat: 'JUnit' - testResultsFiles: $(modulePath)/test-results/test-result.xml - testRunTitle: $(agent.OS) Unit Test - mergeTestResults: false - - - task: PublishTestResults@2 - displayName: Publish lint results - inputs: - testResultsFormat: 'JUnit' - testResultsFiles: $(modulePath)/test-results/lint-result.xml - testRunTitle: $(agent.OS) Lint - mergeTestResults: false - - - bash: | - exit 1 - condition: eq(variables['Agent.JobStatus'], 'SucceededWithIssues') - displayName: Coerce correct build result - -- job: fuzzing - displayName: 'Fuzzing' - # Only run this job on schedules or PRs for non-forks. - condition: or(eq(variables['System.PullRequest.IsFork'], 'False'), eq(variables['Build.Reason'], 'Schedule') ) - strategy: - matrix: - linux: - imageName: ubuntu-16.04 - gorootDir: /usr/local - pool: - vmImage: $(imageName) - - steps: - - bash: | - latestGo=$(curl "https://golang.org/VERSION?m=text") - echo "##vso[task.setvariable variable=LATEST_GO]$latestGo" - echo "Latest Go version: $latestGo" - displayName: "Get latest Go version" - - - bash: | - sudo rm -f $(which go) - echo '##vso[task.prependpath]$(GOBIN)' - echo '##vso[task.prependpath]$(GOROOT)/bin' - mkdir -p '$(modulePath)' - shopt -s extglob - shopt -s dotglob - mv !(gopath) '$(modulePath)' - displayName: Remove old Go, set GOBIN/GOROOT, and move project into GOPATH - - - bash: | - wget "https://dl.google.com/go/$(LATEST_GO).linux-amd64.tar.gz" - sudo tar -C $(gorootDir) -xzf "$(LATEST_GO).linux-amd64.tar.gz" - condition: eq( variables['Agent.OS'], 'Linux' ) - displayName: Install Go on Linux - - - bash: | - # Install Clang-7.0 because other versions seem to be missing the file libclang_rt.fuzzer-x86_64.a - sudo add-apt-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main" - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo apt update && sudo apt install -y clang-7 lldb-7 lld-7 - - go get -v github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build - wget -q -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v2.4.77/fuzzit_Linux_x86_64 - chmod a+x fuzzit - mv fuzzit $(GOBIN) - displayName: Download go-fuzz tools and the Fuzzit CLI, and move Fuzzit CLI to GOBIN - condition: and(eq(variables['System.PullRequest.IsFork'], 'False') , eq( variables['Agent.OS'], 'Linux' )) - - - bash: | - declare -A fuzzers_funcs=(\ - ["./caddyconfig/httpcaddyfile/addresses_fuzz.go"]="FuzzParseAddress" \ - ["./caddyconfig/caddyfile/parse_fuzz.go"]="FuzzParseCaddyfile" \ - ["./listeners_fuzz.go"]="FuzzParseNetworkAddress" \ - ["./replacer_fuzz.go"]="FuzzReplacer" \ - ) - - declare -A fuzzers_targets=(\ - ["./caddyconfig/httpcaddyfile/addresses_fuzz.go"]="parse-address" \ - ["./caddyconfig/caddyfile/parse_fuzz.go"]="parse-caddyfile" \ - ["./listeners_fuzz.go"]="parse-network-address" \ - ["./replacer_fuzz.go"]="replacer" \ - ) - - fuzz_type="local-regression" - if [[ $(Build.Reason) == "Schedule" ]]; then - fuzz_type="fuzzing" - fi - echo "Fuzzing type: $fuzz_type" - - for f in $(find . -name \*_fuzz.go); do - FUZZER_DIRECTORY=$(dirname $f) - echo "go-fuzz-build func ${fuzzers_funcs[$f]} residing in $f" - go-fuzz-build -func "${fuzzers_funcs[$f]}" -libfuzzer -o "$FUZZER_DIRECTORY/${fuzzers_targets[$f]}.a" $FUZZER_DIRECTORY - echo "Generating fuzzer binary of func ${fuzzers_funcs[$f]} which resides in $f" - clang-7 -fsanitize=fuzzer "$FUZZER_DIRECTORY/${fuzzers_targets[$f]}.a" -o "$FUZZER_DIRECTORY/${fuzzers_targets[$f]}" - fuzzit create job caddyserver/${fuzzers_targets[$f]} $FUZZER_DIRECTORY/${fuzzers_targets[$f]} --api-key ${FUZZIT_API_KEY} --type "${fuzz_type}" --branch "${SYSTEM_PULLREQUEST_SOURCEBRANCH}" --revision "${BUILD_SOURCEVERSION}" - echo "Completed $f" - done - env: - FUZZIT_API_KEY: $(FUZZIT_API_KEY) - workingDirectory: '$(modulePath)' - displayName: Generate fuzzers & submit them to Fuzzit From 7d4f6e825b7b024e2c17b9faad66fd359abc19d7 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 22:03:11 -0400 Subject: [PATCH 20/36] Remove the redundant name, see how it looks --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ba2a3ef014..d1e717ab856 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,6 @@ on: jobs: build-and-test: - name: Cross-Platform Tests - strategy: matrix: # os: [ ubuntu-latest, macos-latest, windows-latest ] From a3e0de3d210f16c5f2da9ff27278c39f792101d5 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 22:06:34 -0400 Subject: [PATCH 21/36] Trim down the naming some more --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d1e717ab856..995c08c6833 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ # Used as inspiration: https://github.com/mvdan/github-actions-golang -name: Cross-Platform Tests +name: Cross-Platform on: push: @@ -9,7 +9,7 @@ on: branches: [ v2 ] jobs: - build-and-test: + test: strategy: matrix: # os: [ ubuntu-latest, macos-latest, windows-latest ] From db49dd3dc3dc3d7b4be93b395bfbaaf2227e54a7 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 22:07:26 -0400 Subject: [PATCH 22/36] Turn on windows and mac --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 995c08c6833..e05e8237ef1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,7 @@ jobs: test: strategy: matrix: - # os: [ ubuntu-latest, macos-latest, windows-latest ] - os: [ ubuntu-latest ] + os: [ ubuntu-latest, macos-latest, windows-latest ] go-version: [ 1.14.x ] runs-on: ${{ matrix.os }} From 22b31a91be65d179e85341e3221cee161bd379ac Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 22:15:34 -0400 Subject: [PATCH 23/36] Try to fix windows build, cleanup --- .github/workflows/ci.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e05e8237ef1..2657309593c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,13 +25,6 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - # Only run lint on ubuntu, the reviewdog action uses docker - # - name: Run lint check - # if: matrix.os == 'ubuntu-latest' - # uses: reviewdog/action-golangci-lint@v1 - # with: - # github_token: ${{ secrets.github_token }} - - name: Install test and coverage analysis tools run: | go get github.com/axw/gocov/gocov @@ -53,9 +46,10 @@ jobs: go get -v -t -d ./... # mkdir test-results - # TODO Might not be in the correct dir at this point + # Force bash shell, this command fails on windows if using pwsh - name: Build Caddy working-directory: ./cmd/caddy + shell: bash run: | CGO_ENABLED=0 go build -trimpath -a -ldflags="-w -s" -v @@ -102,7 +96,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code into the Go module directory - uses: actions/checkout@v1 + uses: actions/checkout@v2 - name: Run golangci-lint uses: reviewdog/action-golangci-lint@v1 From 89e112617ce4f93eb84fb2733d58a87b9024ff4c Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 22:24:50 -0400 Subject: [PATCH 24/36] Try to fix strange failure on windows --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2657309593c..fd380822959 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,8 @@ on: jobs: test: strategy: + # Default is true, cancels jobs for other platforms if one fails + fail-fast: false matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] go-version: [ 1.14.x ] @@ -73,7 +75,7 @@ jobs: continue-on-error: true run: | # (go test -v -coverprofile=cover-profile.out -race ./... 2>&1) > test-results/test-result.out - go test -v -coverprofile=cover-profile.out -race ./... + go test -v -coverprofile="cover-profile.out" -race ./... echo "::set-output name=status::$?" - name: Prepare coverage reports From 2664ee75af5f93c711b0605b42bf9d89a0cfdfda Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 22:34:37 -0400 Subject: [PATCH 25/36] Print our the coerce reason --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd380822959..c498c3f5fd4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,6 +91,8 @@ jobs: - name: Coerce correct build result if: steps.step_lint.outputs.status != 0 || steps.step_test.outputs.status != 0 run: | + echo "step_lint ${{ steps.step_lint.outputs.status }}\n" + echo "step_test ${{ steps.step_test.outputs.status }}\n" exit 1 golangci-lint: From 989f19a19695a942b9c3df05e50de696084c486b Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 19 Mar 2020 22:48:57 -0400 Subject: [PATCH 26/36] Apparently $? is 'True' on Windows, not 1 or 0 --- .github/workflows/ci.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c498c3f5fd4..2bfd0ecc192 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,10 +88,15 @@ jobs: # TODO publish coverage/lint/test results ? # To return the correct result even though we set 'continue-on-error: true' - - name: Coerce correct build result - if: steps.step_lint.outputs.status != 0 || steps.step_test.outputs.status != 0 + - name: Coerce correct build result (Windows) + if: matrix.os == 'windows-latest' && steps.step_test.outputs.status != 'True' + run: | + echo "step_test ${{ steps.step_test.outputs.status }}\n" + exit 1 + + - name: Coerce correct build result (Linux/Mac) + if: matrix.os != 'windows-latest' && steps.step_test.outputs.status != 0 run: | - echo "step_lint ${{ steps.step_lint.outputs.status }}\n" echo "step_test ${{ steps.step_test.outputs.status }}\n" exit 1 From e4b2eb8b059cead87999ad7671c9d74f1baaafd6 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Fri, 20 Mar 2020 00:11:30 -0400 Subject: [PATCH 27/36] Try setting CGO_ENABLED as an env in yml --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2bfd0ecc192..d26b4f524ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,9 +51,10 @@ jobs: # Force bash shell, this command fails on windows if using pwsh - name: Build Caddy working-directory: ./cmd/caddy - shell: bash + env: + CGO_ENABLED: 0 run: | - CGO_ENABLED=0 go build -trimpath -a -ldflags="-w -s" -v + go build -trimpath -a -ldflags="-w -s" -v - name: Publish Build Artifact (Windows) if: matrix.os == 'windows-latest' From b0e0280e53fd0be5148793d200d55711aa9c7bb2 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Fri, 20 Mar 2020 00:24:18 -0400 Subject: [PATCH 28/36] Try enabling/fixing the fuzzer --- .github/workflows/ci.yml | 6 ++++-- .github/workflows/fuzzing.yml | 22 ++++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d26b4f524ee..e4add6bdd2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,9 +4,11 @@ name: Cross-Platform on: push: - branches: [ v2 ] + branches: + - v2 pull_request: - branches: [ v2 ] + branches: + - v2 jobs: test: diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml index bba1369845e..b30a02f16ce 100644 --- a/.github/workflows/fuzzing.yml +++ b/.github/workflows/fuzzing.yml @@ -1,8 +1,16 @@ name: Fuzzing on: + # Regression testing + push: + branches: + - v2 + pull_request: + branches: + - v2 + + # Daily midnight fuzzing schedule: - # Daily midnight fuzzing - cron: '0 0 * * *' jobs: @@ -21,13 +29,8 @@ jobs: with: go-version: ${{ matrix.go-version }} - # - name: Checkout code - # uses: actions/checkout@v2 - - # TODO env GOBIN may not be set - # TODO should have if condition to disable for forks? - name: Download go-fuzz tools and the Fuzzit CLI, move Fuzzit CLI to GOBIN - # if: isFork == false + if: github.repository == 'caddyserver/caddy' run: | # Install Clang-7.0 because other versions seem to be missing the file libclang_rt.fuzzer-x86_64.a sudo add-apt-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main" @@ -37,9 +40,8 @@ jobs: go get -v github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build wget -q -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v2.4.77/fuzzit_Linux_x86_64 chmod a+x fuzzit - mv fuzzit $(GOBIN) + mv fuzzit $(go env GOPATH)/bin - # TODO $(Build.Reason) is probably not set - name: Download go-fuzz tools and the Fuzzit CLI, move Fuzzit CLI to GOBIN env: FUZZIT_API_KEY: ${{ secrets.FUZZIT_API_KEY }} @@ -59,7 +61,7 @@ jobs: ) fuzz_type="local-regression" - if [[ $(Build.Reason) == "Schedule" ]]; then + if [[ ${{ github.event_name }} == "schedule" ]]; then fuzz_type="fuzzing" fi echo "Fuzzing type: $fuzz_type" From e0748d3a7908e6d52c6ccbb6f9a5693f1637fffb Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Fri, 20 Mar 2020 00:29:55 -0400 Subject: [PATCH 29/36] Print out github event to check, fix step name --- .github/workflows/fuzzing.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml index b30a02f16ce..c184f03aa54 100644 --- a/.github/workflows/fuzzing.yml +++ b/.github/workflows/fuzzing.yml @@ -42,7 +42,7 @@ jobs: chmod a+x fuzzit mv fuzzit $(go env GOPATH)/bin - - name: Download go-fuzz tools and the Fuzzit CLI, move Fuzzit CLI to GOBIN + - name: Generate fuzzers & submit them to Fuzzit env: FUZZIT_API_KEY: ${{ secrets.FUZZIT_API_KEY }} run: | @@ -64,6 +64,7 @@ jobs: if [[ ${{ github.event_name }} == "schedule" ]]; then fuzz_type="fuzzing" fi + echo "Github event: ${{ github.event_name }}" echo "Fuzzing type: $fuzz_type" for f in $(find . -name \*_fuzz.go); do From a7ccf69b56bed8e11274c38fb3407c57fe3a893e Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Fri, 20 Mar 2020 00:33:31 -0400 Subject: [PATCH 30/36] Fuzzer needs the code --- .github/workflows/fuzzing.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml index c184f03aa54..c019acc7b23 100644 --- a/.github/workflows/fuzzing.yml +++ b/.github/workflows/fuzzing.yml @@ -29,6 +29,9 @@ jobs: with: go-version: ${{ matrix.go-version }} + - name: Checkout code + uses: actions/checkout@v2 + - name: Download go-fuzz tools and the Fuzzit CLI, move Fuzzit CLI to GOBIN if: github.repository == 'caddyserver/caddy' run: | From 78c750c6766f48a5262369243cea479cbe305eec Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Fri, 20 Mar 2020 00:36:03 -0400 Subject: [PATCH 31/36] Add GOBIN to PATH for fuzzer --- .github/workflows/fuzzing.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml index c019acc7b23..2374d16af79 100644 --- a/.github/workflows/fuzzing.yml +++ b/.github/workflows/fuzzing.yml @@ -44,6 +44,7 @@ jobs: wget -q -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v2.4.77/fuzzit_Linux_x86_64 chmod a+x fuzzit mv fuzzit $(go env GOPATH)/bin + echo "::add-path::$(go env GOPATH)/bin" - name: Generate fuzzers & submit them to Fuzzit env: From 89d53af4e5e92274c5f2ae395e774ffc303a4d79 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Fri, 20 Mar 2020 00:37:35 -0400 Subject: [PATCH 32/36] Comment out fork condition, left in-case we want it again --- .github/workflows/fuzzing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml index 2374d16af79..2c12eda3e8b 100644 --- a/.github/workflows/fuzzing.yml +++ b/.github/workflows/fuzzing.yml @@ -33,7 +33,7 @@ jobs: uses: actions/checkout@v2 - name: Download go-fuzz tools and the Fuzzit CLI, move Fuzzit CLI to GOBIN - if: github.repository == 'caddyserver/caddy' + # if: github.repository == 'caddyserver/caddy' run: | # Install Clang-7.0 because other versions seem to be missing the file libclang_rt.fuzzer-x86_64.a sudo add-apt-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main" From bbcbfc3777b5581de88cee2c6b7493d510b61e47 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Fri, 20 Mar 2020 01:05:38 -0400 Subject: [PATCH 33/36] Remove obsolete comment --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4add6bdd2c..e5dd3de78c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,6 @@ jobs: go get -v -t -d ./... # mkdir test-results - # Force bash shell, this command fails on windows if using pwsh - name: Build Caddy working-directory: ./cmd/caddy env: From 90b38919b6e898c0bf30ca5ea1c8be759fe56388 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Fri, 20 Mar 2020 09:06:20 -0400 Subject: [PATCH 34/36] Comment out the coverage/test conversions for now --- .github/workflows/ci.yml | 50 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5dd3de78c1..4352874ad51 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,12 +29,12 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Install test and coverage analysis tools - run: | - go get github.com/axw/gocov/gocov - go get github.com/AlekSi/gocov-xml - go get -u github.com/jstemmer/go-junit-report - echo "::add-path::$(go env GOPATH)/bin" + # - name: Install test and coverage analysis tools + # run: | + # go get github.com/axw/gocov/gocov + # go get github.com/AlekSi/gocov-xml + # go get -u github.com/jstemmer/go-junit-report + # echo "::add-path::$(go env GOPATH)/bin" - name: Print Go version and environment run: | @@ -73,34 +73,34 @@ jobs: # For info about set-output, see https://stackoverflow.com/questions/57850553/github-actions-check-steps-status - name: Run tests - id: step_test - continue-on-error: true + # id: step_test + # continue-on-error: true run: | # (go test -v -coverprofile=cover-profile.out -race ./... 2>&1) > test-results/test-result.out go test -v -coverprofile="cover-profile.out" -race ./... echo "::set-output name=status::$?" - - 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 + # - 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 # TODO publish coverage/lint/test results ? # To return the correct result even though we set 'continue-on-error: true' - - name: Coerce correct build result (Windows) - if: matrix.os == 'windows-latest' && steps.step_test.outputs.status != 'True' - run: | - echo "step_test ${{ steps.step_test.outputs.status }}\n" - exit 1 - - - name: Coerce correct build result (Linux/Mac) - if: matrix.os != 'windows-latest' && steps.step_test.outputs.status != 0 - run: | - echo "step_test ${{ steps.step_test.outputs.status }}\n" - exit 1 + # - name: Coerce correct build result (Windows) + # if: matrix.os == 'windows-latest' && steps.step_test.outputs.status != 'True' + # run: | + # echo "step_test ${{ steps.step_test.outputs.status }}\n" + # exit 1 + + # - name: Coerce correct build result (Linux/Mac) + # if: matrix.os != 'windows-latest' && steps.step_test.outputs.status != 0 + # run: | + # echo "step_test ${{ steps.step_test.outputs.status }}\n" + # exit 1 golangci-lint: name: runner / golangci-lint From d81d6023e2dff862160c843082909725acfebea2 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Fri, 20 Mar 2020 09:19:43 -0400 Subject: [PATCH 35/36] Set continue-on-error: true for fuzzer, it runs out of mem --- .github/workflows/fuzzing.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml index 2c12eda3e8b..b5571c719ce 100644 --- a/.github/workflows/fuzzing.yml +++ b/.github/workflows/fuzzing.yml @@ -47,6 +47,7 @@ jobs: echo "::add-path::$(go env GOPATH)/bin" - name: Generate fuzzers & submit them to Fuzzit + continue-on-error: true env: FUZZIT_API_KEY: ${{ secrets.FUZZIT_API_KEY }} run: | From ea4bdd7a775b858da72eb370568a1b4e4f32cc97 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Fri, 20 Mar 2020 10:03:53 -0400 Subject: [PATCH 36/36] Add some clarification to the retained commented sections --- .github/workflows/ci.yml | 13 ++++++++----- .github/workflows/fuzzing.yml | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4352874ad51..1bd13fd79e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ on: jobs: test: strategy: - # Default is true, cancels jobs for other platforms if one fails + # Default is true, cancels jobs for other platforms in the matrix if one fails fail-fast: false matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] @@ -29,6 +29,8 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + # These tools would be useful if we later decide to reinvestigate + # publishing test/coverage reports to some tool for easier consumption # - name: Install test and coverage analysis tools # run: | # go get github.com/axw/gocov/gocov @@ -71,6 +73,8 @@ jobs: name: caddy_v2_${{ matrix.os }} path: ./cmd/caddy/caddy + # Commented bits below were useful to allow the job to continue + # even if the tests fail, so we can publish the report separately # For info about set-output, see https://stackoverflow.com/questions/57850553/github-actions-check-steps-status - name: Run tests # id: step_test @@ -78,8 +82,9 @@ jobs: run: | # (go test -v -coverprofile=cover-profile.out -race ./... 2>&1) > test-results/test-result.out go test -v -coverprofile="cover-profile.out" -race ./... - echo "::set-output name=status::$?" + # echo "::set-output name=status::$?" + # Relevant step if we reinvestigate publishing test/coverage reports # - name: Prepare coverage reports # run: | # mkdir coverage @@ -87,21 +92,19 @@ jobs: # # Because Windows doesn't work with input redirection like *nix, but output redirection works. # (cat ./coverage/coverage.json | gocov-xml) > coverage/coverage.xml - # TODO publish coverage/lint/test results ? - # To return the correct result even though we set 'continue-on-error: true' # - name: Coerce correct build result (Windows) # if: matrix.os == 'windows-latest' && steps.step_test.outputs.status != 'True' # run: | # echo "step_test ${{ steps.step_test.outputs.status }}\n" # exit 1 - # - name: Coerce correct build result (Linux/Mac) # if: matrix.os != 'windows-latest' && steps.step_test.outputs.status != 0 # run: | # echo "step_test ${{ steps.step_test.outputs.status }}\n" # exit 1 + # From https://github.com/reviewdog/action-golangci-lint golangci-lint: name: runner / golangci-lint runs-on: ubuntu-latest diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml index b5571c719ce..a0487c171a7 100644 --- a/.github/workflows/fuzzing.yml +++ b/.github/workflows/fuzzing.yml @@ -33,6 +33,7 @@ jobs: uses: actions/checkout@v2 - name: Download go-fuzz tools and the Fuzzit CLI, move Fuzzit CLI to GOBIN + # If we decide we need to prevent this from running on forks, we can use this line: # if: github.repository == 'caddyserver/caddy' run: | # Install Clang-7.0 because other versions seem to be missing the file libclang_rt.fuzzer-x86_64.a