From fa39e12a5cb28a7b44004d6dbf52f06305dba3e2 Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Thu, 24 Mar 2022 22:13:38 +0000 Subject: [PATCH] chore: add go test action Add a github action which runs go test so we can ensure that tests are passing before we merge changes. --- .github/workflows/go-test.yml | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/go-test.yml diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml new file mode 100644 index 00000000..1086bf3a --- /dev/null +++ b/.github/workflows/go-test.yml @@ -0,0 +1,58 @@ +name: go-test +on: + push: + tags: + - v* + branches: + - master + pull_request: +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + go-version: + - '1.17.x' + - '1.18.x' + os: + - 'ubuntu-latest' + redis: + - '6.2' + - '6.0' + - '5.0' + - '4.0' + name: Test go ${{ matrix.go-version }} redis ${{ matrix.redis }} on ${{ matrix.os }} + steps: + - name: Setup redis + uses: shogo82148/actions-setup-redis@v1 + with: + redis-version: ${{ matrix.redis }} + + - name: Install Go + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go-version }} + + - name: Go Cache Paths + id: go-cache-paths + run: | + echo "::set-output name=go-build::$(go env GOCACHE)" + echo "::set-output name=go-mod::$(go env GOMODCACHE)" + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Go Build Cache + uses: actions/cache@v3 + with: + path: ${{ steps.go-cache-paths.outputs.go-build }} + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + + - name: Go Mod Cache + uses: actions/cache@v3 + with: + path: ${{ steps.go-cache-paths.outputs.go-mod }} + key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} + + - name: Go Test + run: go test -v ./...