Update the github ci action to use cache and matrix strategy

This commit is contained in:
Matthieu MOREL 2021-05-31 10:40:47 +02:00 committed by GitHub
parent df1249d9b2
commit 244adc6bdc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,56 +12,63 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
continue-on-error: true
with:
version: latest
tests-go-1-16:
test:
needs: [golangci]
strategy:
matrix:
go_version:
- '1.14'
- '1.15'
- '1.16'
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Setup go ${{ matrix.go_version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go_version }}
- name: Checkout Source
uses: actions/checkout@v2
- name: Run Tests
uses: cedrickring/golang-action@1.7.0
- uses: actions/cache@v2
with:
args: make test
tests-go-1-15:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Checkout Source
uses: actions/checkout@v2
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run Tests
uses: cedrickring/golang-action/go1.15@1.7.0
with:
args: make test
tests-go-1-14:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Checkout Source
uses: actions/checkout@v2
- name: Run Tests
uses: cedrickring/golang-action/go1.14@1.7.0
with:
args: make test
run: make test
coverage:
needs: [tests-go-1-16, tests-go-1-15, tests-go-1-14]
needs: [test]
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: '1.16'
- name: Checkout Source
uses: actions/checkout@v2
- name: Create Test Coverage
uses: cedrickring/golang-action@1.7.0
- uses: actions/cache@v2
with:
args: make test-coverage
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Create Test Coverage
run: make test-coverage
- name: Upload Test Coverage
uses: codecov/codecov-action@v1
with: