From 4215bfafa45bda169a1c9446dc0efcf407ad0af6 Mon Sep 17 00:00:00 2001 From: Nick Paisley <2ep303@gmail.com> Date: Wed, 31 Jan 2024 11:26:58 -0600 Subject: [PATCH] build: Added latest go versions to test matrix --- .github/workflows/test-package.yml | 2 +- features/fixtures/app/Dockerfile | 12 +++++++++++- features/fixtures/app/main.go | 2 +- features/fixtures/autoconfigure/Dockerfile | 11 +++++++++-- features/fixtures/net_http/Dockerfile | 11 +++++++++-- 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index ff637390..0feee70e 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: os: [ubuntu, windows] - go-version: ['1.11', '1.12', '1.13', '1.14', '1.15', '1.16'] + go-version: ['1.11', '1.12', '1.13', '1.14', '1.15', '1.16', '1.17', '1.18', '1.19', '1.20', '1.21', '1.22'] steps: - uses: actions/checkout@v2 diff --git a/features/fixtures/app/Dockerfile b/features/fixtures/app/Dockerfile index be61d206..fa18e33d 100644 --- a/features/fixtures/app/Dockerfile +++ b/features/fixtures/app/Dockerfile @@ -8,7 +8,17 @@ ENV GOPATH /app COPY testbuild /app/src/github.com/bugsnag/bugsnag-go WORKDIR /app/src/github.com/bugsnag/bugsnag-go/v2 -RUN go get ./... +# A conditional call to run go get or go install based on the go version +RUN GO_VERSION=$(go version | cut -d " " -f3 | sed 's/go//') && \ + if [[ $(echo -e "1.11\n$GO_VERSION\n1.16" | sort -V | head -2 | tail -1) == "$GO_VERSION" ]]; then \ + echo "Version is between 1.11 and 1.16, running go get"; \ + go get ./...; \ + else \ + echo "Version is greater than 1.16, running go install"; \ + go install ./...; \ + fi + + # Copy test scenarios COPY ./app /app/src/test diff --git a/features/fixtures/app/main.go b/features/fixtures/app/main.go index 5617999f..0831ead2 100644 --- a/features/fixtures/app/main.go +++ b/features/fixtures/app/main.go @@ -130,7 +130,7 @@ func multipleUnhandled() { defer notifier.AutoNotify(ctx) panic("oops") } - +//go:noinline func unhandledCrash() { // Invalid type assertion, will panic func(a interface{}) string { diff --git a/features/fixtures/autoconfigure/Dockerfile b/features/fixtures/autoconfigure/Dockerfile index e0764b9f..d603f9e9 100644 --- a/features/fixtures/autoconfigure/Dockerfile +++ b/features/fixtures/autoconfigure/Dockerfile @@ -8,8 +8,15 @@ ENV GOPATH /app COPY testbuild /app/src/github.com/bugsnag/bugsnag-go WORKDIR /app/src/github.com/bugsnag/bugsnag-go/v2 -# Get bugsnag dependencies -RUN go get ./... +# Get bugsnag dependencies using a conditional call to run go get or go install based on the go version +RUN GO_VERSION=$(go version | cut -d " " -f3 | sed 's/go//') && \ + if [[ $(echo -e "1.11\n$GO_VERSION\n1.16" | sort -V | head -2 | tail -1) == "$GO_VERSION" ]]; then \ + echo "Version is between 1.11 and 1.16, running go get"; \ + go get ./...; \ + else \ + echo "Version is greater than 1.16, running go install"; \ + go install ./...; \ + fi # Copy test scenarios COPY ./autoconfigure /app/src/test diff --git a/features/fixtures/net_http/Dockerfile b/features/fixtures/net_http/Dockerfile index de86a56b..b10cd40b 100644 --- a/features/fixtures/net_http/Dockerfile +++ b/features/fixtures/net_http/Dockerfile @@ -10,8 +10,15 @@ ENV GOPATH /app COPY testbuild /app/src/github.com/bugsnag/bugsnag-go WORKDIR /app/src/github.com/bugsnag/bugsnag-go/v2 -# Get bugsnag dependencies -RUN go get ./... +# Get bugsnag dependencies using a conditional call to run go get or go install based on the go version +RUN GO_VERSION=$(go version | cut -d " " -f3 | sed 's/go//') && \ + if [[ $(echo -e "1.11\n$GO_VERSION\n1.16" | sort -V | head -2 | tail -1) == "$GO_VERSION" ]]; then \ + echo "Version is between 1.11 and 1.16, running go get"; \ + go get ./...; \ + else \ + echo "Version is greater than 1.16, running go install"; \ + go install ./...; \ + fi # Copy test scenarios COPY ./net_http /app/src/test