Skip to content

Commit

Permalink
Add gotip to CI (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop authored Dec 20, 2021
1 parent 759590c commit 83ca606
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 27 deletions.
18 changes: 13 additions & 5 deletions templates/github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 13 additions & 6 deletions templates/github/workflows/gorelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 13 additions & 6 deletions templates/github/workflows/release-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions templates/github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 18 additions & 7 deletions templates/github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -36,21 +47,21 @@ 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: |
unit-base.txt
# 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"
Expand All @@ -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 }}
Expand All @@ -87,7 +98,7 @@ jobs:
</details>
- 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
Expand Down

0 comments on commit 83ca606

Please sign in to comment.