
use golangci/golangci-lint-action instead of reviewdog/action-golangci-lint as the second was not reporting any failures even if there was some. Report code coverage with codecov/codecov-action I have set some flags per dialect and go version Several linters has been fixed, some disabled so the build can pass
221 lines
5.8 KiB
YAML
221 lines
5.8 KiB
YAML
name: tests
|
|
|
|
on:
|
|
push:
|
|
branches-ignore:
|
|
- 'gh-pages'
|
|
pull_request:
|
|
branches-ignore:
|
|
- 'gh-pages'
|
|
|
|
jobs:
|
|
lint:
|
|
name: runner / golangci-lint
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Setup go
|
|
uses: actions/setup-go@v2
|
|
with:
|
|
go-version: '1.17'
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Setup golangci-lint
|
|
uses: golangci/golangci-lint-action@v2
|
|
with:
|
|
version: latest
|
|
args: --verbose
|
|
|
|
# Label of the container job
|
|
sqlite:
|
|
needs: lint
|
|
strategy:
|
|
matrix:
|
|
go: ['1.17', '1.16']
|
|
platform: [ubuntu-latest] # can not run in windows OS
|
|
runs-on: ${{ matrix.platform }}
|
|
|
|
steps:
|
|
- name: Set up Go ${{ matrix.go }}
|
|
uses: actions/setup-go@v2
|
|
with:
|
|
go-version: ${{ matrix.go }}
|
|
|
|
- name: Check out code into the Go module directory
|
|
uses: actions/checkout@v2
|
|
|
|
- name: go mod package cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('tests/go.mod') }}
|
|
|
|
- name: Tests
|
|
run: GORM_DIALECT=sqlite ./tests/tests_all.sh
|
|
|
|
- name: Upload Code Coverage
|
|
uses: codecov/codecov-action@v2
|
|
with:
|
|
name: sqlite
|
|
flags: sqlite,go-${{ matrix.go }}
|
|
fail_ci_if_error: true
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
|
|
mysql:
|
|
needs: lint
|
|
strategy:
|
|
matrix:
|
|
dbversion: ['mysql:latest', 'mysql:5.7', 'mariadb:latest']
|
|
go: ['1.17', '1.16']
|
|
platform: [ubuntu-latest]
|
|
runs-on: ${{ matrix.platform }}
|
|
|
|
services:
|
|
mysql:
|
|
image: ${{ matrix.dbversion }}
|
|
env:
|
|
MYSQL_DATABASE: gorm
|
|
MYSQL_USER: gorm
|
|
MYSQL_PASSWORD: gorm
|
|
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
|
|
ports:
|
|
- 9910:3306
|
|
options: >-
|
|
--health-cmd "mysqladmin ping -ugorm -pgorm"
|
|
--health-interval 10s
|
|
--health-start-period 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
|
|
steps:
|
|
- name: Set up Go ${{ matrix.go }}
|
|
uses: actions/setup-go@v2
|
|
with:
|
|
go-version: ${{ matrix.go }}
|
|
|
|
- name: Check out code into the Go module directory
|
|
uses: actions/checkout@v2
|
|
|
|
- name: go mod package cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('tests/go.mod') }}
|
|
|
|
- name: Tests
|
|
run: GORM_DIALECT=mysql GORM_DSN="gorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True" ./tests/tests_all.sh
|
|
|
|
- name: Upload Code Coverage
|
|
uses: codecov/codecov-action@v2
|
|
with:
|
|
name: mysql
|
|
flags: mysql,go-${{ matrix.go }}
|
|
fail_ci_if_error: true
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
|
|
postgres:
|
|
needs: lint
|
|
strategy:
|
|
matrix:
|
|
dbversion: ['postgres:latest', 'postgres:13', 'postgres:12', 'postgres:11', 'postgres:10']
|
|
go: ['1.17', '1.16']
|
|
platform: [ubuntu-latest] # can not run in macOS and Windows
|
|
runs-on: ${{ matrix.platform }}
|
|
|
|
services:
|
|
postgres:
|
|
image: ${{ matrix.dbversion }}
|
|
env:
|
|
POSTGRES_PASSWORD: gorm
|
|
POSTGRES_USER: gorm
|
|
POSTGRES_DB: gorm
|
|
TZ: Asia/Shanghai
|
|
ports:
|
|
- 9920:5432
|
|
# Set health checks to wait until postgres has started
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
|
|
steps:
|
|
- name: Set up Go ${{ matrix.go }}
|
|
uses: actions/setup-go@v2
|
|
with:
|
|
go-version: ${{ matrix.go }}
|
|
|
|
- name: Check out code into the Go module directory
|
|
uses: actions/checkout@v2
|
|
|
|
- name: go mod package cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('tests/go.mod') }}
|
|
|
|
- name: Tests
|
|
run: GORM_DIALECT=postgres GORM_DSN="user=gorm password=gorm dbname=gorm host=localhost port=9920 sslmode=disable TimeZone=Asia/Shanghai" ./tests/tests_all.sh
|
|
|
|
- name: Upload Code Coverage
|
|
uses: codecov/codecov-action@v2
|
|
with:
|
|
name: postgres
|
|
flags: postgres,go-${{ matrix.go }}
|
|
fail_ci_if_error: true
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
|
|
sqlserver:
|
|
needs: lint
|
|
strategy:
|
|
matrix:
|
|
go: ['1.17', '1.16']
|
|
platform: [ubuntu-latest] # can not run test in macOS and windows
|
|
runs-on: ${{ matrix.platform }}
|
|
|
|
services:
|
|
mssql:
|
|
image: mcmoe/mssqldocker:latest
|
|
env:
|
|
ACCEPT_EULA: Y
|
|
SA_PASSWORD: LoremIpsum86
|
|
MSSQL_DB: gorm
|
|
MSSQL_USER: gorm
|
|
MSSQL_PASSWORD: LoremIpsum86
|
|
ports:
|
|
- 9930:1433
|
|
options: >-
|
|
--health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -l 30 -Q \"SELECT 1\" || exit 1"
|
|
--health-start-period 10s
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
|
|
steps:
|
|
- name: Set up Go ${{ matrix.go }}
|
|
uses: actions/setup-go@v2
|
|
with:
|
|
go-version: ${{ matrix.go }}
|
|
|
|
- name: Check out code into the Go module directory
|
|
uses: actions/checkout@v2
|
|
|
|
- name: go mod package cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('tests/go.mod') }}
|
|
|
|
- name: Tests
|
|
run: GORM_DIALECT=sqlserver GORM_DSN="sqlserver://gorm:LoremIpsum86@localhost:9930?database=gorm" ./tests/tests_all.sh
|
|
|
|
- name: Upload Code Coverage
|
|
uses: codecov/codecov-action@v2
|
|
with:
|
|
name: sqlserver
|
|
flags: sqlserver,go-${{ matrix.go }}
|
|
fail_ci_if_error: true
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|