diff --git a/templates/github/workflows/bench.yml b/templates/github/workflows/bench.yml index 848799d..152d4a6 100644 --- a/templates/github/workflows/bench.yml +++ b/templates/github/workflows/bench.yml @@ -16,17 +16,25 @@ env: GO111MODULE: "on" CACHE_BENCHMARK: "off" # Enables benchmark result reuse between runs, may skew latency results. RUN_BASE_BENCHMARK: "on" # Runs benchmark for PR base in case benchmark result is missing. + GO_VERSION: 1.17.x jobs: bench: - strategy: - matrix: - go-version: [ 1.17.x ] runs-on: ubuntu-latest steps: - - name: Install Go + - name: Install Go stable + if: env.GO_VERSION != 'tip' uses: actions/setup-go@v2 with: - go-version: ${{ matrix.go-version }} + go-version: ${{ env.GO_VERSION }} + - name: Install Go tip + if: env.GO_VERSION == 'tip' + run: | + curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz + ls -lah gotip.tar.gz + mkdir -p ~/sdk/gotip + tar -C ~/sdk/gotip -xzf gotip.tar.gz + ~/sdk/gotip/bin/go version + echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV - name: Checkout code uses: actions/checkout@v2 with: diff --git a/templates/github/workflows/gorelease.yml b/templates/github/workflows/gorelease.yml index 64854e3..94c6966 100644 --- a/templates/github/workflows/gorelease.yml +++ b/templates/github/workflows/gorelease.yml @@ -3,18 +3,25 @@ name: gorelease on: pull_request: env: - GO111MODULE: "on" + GO_VERSION: 1.17.x jobs: gorelease: - strategy: - matrix: - go-version: [ 1.17.x ] runs-on: ubuntu-latest steps: - - name: Install Go + - name: Install Go stable + if: env.GO_VERSION != 'tip' uses: actions/setup-go@v2 with: - go-version: ${{ matrix.go-version }} + go-version: ${{ env.GO_VERSION }} + - name: Install Go tip + if: env.GO_VERSION == 'tip' + run: | + curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz + ls -lah gotip.tar.gz + mkdir -p ~/sdk/gotip + tar -C ~/sdk/gotip -xzf gotip.tar.gz + ~/sdk/gotip/bin/go version + echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV - name: Checkout code uses: actions/checkout@v2 - name: Gorelease cache diff --git a/templates/github/workflows/release-assets.yml b/templates/github/workflows/release-assets.yml index 05ce46a..523358f 100644 --- a/templates/github/workflows/release-assets.yml +++ b/templates/github/workflows/release-assets.yml @@ -8,19 +8,26 @@ on: - created env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - + GO_VERSION: 1.17.x jobs: build: name: Upload Release Assets - strategy: - matrix: - go-version: [ 1.17.x ] runs-on: ubuntu-latest steps: - - name: Install Go + - name: Install Go stable + if: env.GO_VERSION != 'tip' uses: actions/setup-go@v2 with: - go-version: ${{ matrix.go-version }} + go-version: ${{ env.GO_VERSION }} + - name: Install Go tip + if: env.GO_VERSION == 'tip' + run: | + curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz + ls -lah gotip.tar.gz + mkdir -p ~/sdk/gotip + tar -C ~/sdk/gotip -xzf gotip.tar.gz + ~/sdk/gotip/bin/go version + echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV - name: Checkout code uses: actions/checkout@v2 - name: Build artifacts diff --git a/templates/github/workflows/test-integration.yml b/templates/github/workflows/test-integration.yml index b6f272d..aab2e5b 100644 --- a/templates/github/workflows/test-integration.yml +++ b/templates/github/workflows/test-integration.yml @@ -9,15 +9,26 @@ on: env: GO111MODULE: "on" RUN_BASE_COVERAGE: "on" # Runs test for PR base in case base test coverage is missing. - DOCKER_COMPOSE_FILE: "./docker-compose.yml" + DOCKER_COMPOSE_FILE: ./docker-compose.yml + GO_VERSION: 1.17.x jobs: test: runs-on: ubuntu-latest steps: - - name: Install Go + - name: Install Go stable + if: env.GO_VERSION != 'tip' uses: actions/setup-go@v2 with: - go-version: 1.17.x + go-version: ${{ env.GO_VERSION }} + - name: Install Go tip + if: env.GO_VERSION == 'tip' + run: | + curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz + ls -lah gotip.tar.gz + mkdir -p ~/sdk/gotip + tar -C ~/sdk/gotip -xzf gotip.tar.gz + ~/sdk/gotip/bin/go version + echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV - name: Checkout code uses: actions/checkout@v2 - name: Go cache diff --git a/templates/github/workflows/test-unit.yml b/templates/github/workflows/test-unit.yml index c493b23..6442393 100644 --- a/templates/github/workflows/test-unit.yml +++ b/templates/github/workflows/test-unit.yml @@ -9,17 +9,28 @@ on: env: GO111MODULE: "on" RUN_BASE_COVERAGE: "on" # Runs test for PR base in case base test coverage is missing. + COV_GO_VERSION: 1.17.x # Version of Go to collect coverage jobs: test: strategy: matrix: - go-version: [ 1.16.x, 1.17.x ] + go-version: [ 1.16.x, 1.17.x, tip ] runs-on: ubuntu-latest steps: - - name: Install Go + - name: Install Go stable + if: matrix.go-version != 'tip' uses: actions/setup-go@v2 with: go-version: ${{ matrix.go-version }} + - name: Install Go tip + if: matrix.go-version == 'tip' + run: | + curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz + ls -lah gotip.tar.gz + mkdir -p ~/sdk/gotip + tar -C ~/sdk/gotip -xzf gotip.tar.gz + ~/sdk/gotip/bin/go version + echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV - name: Checkout code uses: actions/checkout@v2 - name: Go cache @@ -36,7 +47,7 @@ jobs: ${{ runner.os }}-go-cache - name: Restore base test coverage id: base-coverage - if: matrix.go-version == '1.17.x' + if: matrix.go-version == env.COV_GO_VERSION uses: actions/cache@v2 with: path: | @@ -44,13 +55,13 @@ jobs: # Use base sha for PR or new commit hash for master/main push in test result key. key: ${{ runner.os }}-unit-test-coverage-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }} - name: Checkout base code - if: matrix.go-version == '1.17.x' && env.RUN_BASE_COVERAGE == 'on' && steps.base-coverage.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != '' + if: matrix.go-version == env.COV_GO_VERSION && env.RUN_BASE_COVERAGE == 'on' && steps.base-coverage.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != '' uses: actions/checkout@v2 with: ref: ${{ github.event.pull_request.base.sha }} path: __base - name: Run test for base code - if: matrix.go-version == '1.17.x' && env.RUN_BASE_COVERAGE == 'on' && steps.base-coverage.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != '' + if: matrix.go-version == env.COV_GO_VERSION && env.RUN_BASE_COVERAGE == 'on' && steps.base-coverage.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != '' run: | cd __base make | grep test-unit && (make test-unit && go tool cover -func=./unit.coverprofile | sed -e 's/.go:[0-9]*:\t/.go\t/g' | sed -e 's/\t\t*/\t/g' > ../unit-base.txt) || echo "No test-unit in base" @@ -71,7 +82,7 @@ jobs: run: cp unit.txt unit-base.txt - name: Comment Test Coverage continue-on-error: true - if: matrix.go-version == '1.17.x' + if: matrix.go-version == env.COV_GO_VERSION uses: marocchino/sticky-pull-request-comment@v2 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -87,7 +98,7 @@ jobs: - name: Upload code coverage - if: matrix.go-version == '1.17.x' + if: matrix.go-version == env.COV_GO_VERSION uses: codecov/codecov-action@v1 with: file: ./unit.coverprofile