Refactor github actions

This commit is contained in:
Jinzhu 2020-06-22 22:51:54 +08:00
parent 60d1e68567
commit 71ae2ddbee
1 changed files with 75 additions and 98 deletions

View File

@ -8,16 +8,68 @@ on:
jobs: jobs:
# Label of the container job # Label of the container job
tests: sqlite:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
go: [ '1.14', '1.13' ] go: ['1.14', '1.13']
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: run sqlite
run: GORM_DIALECT=sqlite GORM_VERBOSE=true ./tests/tests_all.sh
mysql:
runs-on: ubuntu-latest
strategy:
matrix:
dbversion: ['mysql:latest', 'mysql:5.7', 'mysql:5.6', 'mariadb:latest']
go: ['1.14', '1.13']
services:
mysql:
image: ${{ matrix.dbversion }}
env:
MYSQL_DATABASE: gorm
MYSQL_USER: gorm
MYSQL_PASSWORD: gorm
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
ports:
- 9910:3306
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: show ports
run: netstat -lntp
- name: run mysql
run: GORM_DIALECT=mysql GORM_VERBOSE=true GORM_DSN="gorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True" ./tests/tests_all.sh
postgres:
runs-on: ubuntu-latest
strategy:
matrix:
dbversion: ['postgres:latest', 'postgres:11', 'postgres:10']
go: ['1.14', '1.13']
services: services:
# start postgres
postgres: postgres:
image: postgres:latest image: ${{ matrix.dbversion }}
env: env:
POSTGRES_PASSWORD: gorm POSTGRES_PASSWORD: gorm
POSTGRES_USER: gorm POSTGRES_USER: gorm
@ -32,80 +84,29 @@ jobs:
--health-timeout 5s --health-timeout 5s
--health-retries 5 --health-retries 5
postgres11: steps:
image: postgres:11 - name: Set up Go 1.x
env: uses: actions/setup-go@v2
POSTGRES_PASSWORD: gorm with:
POSTGRES_USER: gorm go-version: ${{ matrix.go }}
POSTGRES_DB: gorm
TZ: Asia/Shanghai
ports:
- 9921:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres10: - name: Check out code into the Go module directory
image: postgres:10 uses: actions/checkout@v2
env:
POSTGRES_PASSWORD: gorm
POSTGRES_USER: gorm
POSTGRES_DB: gorm
TZ: Asia/Shanghai
ports:
- 9922:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
# start mysql - name: show ports
mysql: run: netstat -lntp
image: mysql:latest
env:
MYSQL_DATABASE: gorm
MYSQL_USER: gorm
MYSQL_PASSWORD: gorm
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
ports:
- 9910:3306
mysql57: - name: run postgres
image: mysql:5.7 run: GORM_DIALECT=postgres GORM_VERBOSE=true GORM_DSN="user=gorm password=gorm DB.name=gorm port=9920 sslmode=disable TimeZone=Asia/Shanghai" ./tests/tests_all.sh
env:
MYSQL_DATABASE: gorm
MYSQL_USER: gorm
MYSQL_PASSWORD: gorm
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
ports:
- 9911:3306
mysql56:
image: mysql:5.6
env:
MYSQL_DATABASE: gorm
MYSQL_USER: gorm
MYSQL_PASSWORD: gorm
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
ports:
- 9912:3306
mariadb: sqlserver:
image: mariadb:latest runs-on: ubuntu-latest
env: strategy:
MYSQL_DATABASE: gorm matrix:
MYSQL_USER: gorm go: ['1.14', '1.13']
MYSQL_PASSWORD: gorm
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
ports:
- 9913:3306
# start mssql services:
mssql: mssql:
image: mcmoe/mssqldocker:latest image: mcmoe/mssqldocker:latest
env: env:
@ -129,29 +130,5 @@ jobs:
- name: show ports - name: show ports
run: netstat -lntp run: netstat -lntp
- name: run sqlite - name: run sqlserver
run: GORM_DIALECT=sqlite GORM_VERBOSE=true ./tests/tests_all.sh run: GORM_DIALECT=sqlserver GORM_VERBOSE=true GORM_DSN="sqlserver://gorm:LoremIpsum86@localhost:9930?database=gorm" ./tests/tests_all.sh
- name: run mysql
run: GORM_DIALECT=mysql GORM_VERBOSE=true GORM_DSN="gorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True" ./tests/tests_all.sh
- name: run mysql57
run: GORM_DIALECT=mysql GORM_VERBOSE=true GORM_DSN="gorm:gorm@tcp(localhost:9911)/gorm?charset=utf8&parseTime=True" ./tests/tests_all.sh
- name: run mysql56
run: GORM_DIALECT=mysql GORM_VERBOSE=true GORM_DSN="gorm:gorm@tcp(localhost:9912)/gorm?charset=utf8&parseTime=True" ./tests/tests_all.sh
- name: run mariadb
run: GORM_DIALECT=mysql GORM_VERBOSE=true GORM_DSN="gorm:gorm@tcp(localhost:9913)/gorm?charset=utf8&parseTime=True" ./tests/tests_all.sh
- name: run postgres
run: GORM_DIALECT=postgres GORM_VERBOSE=true GORM_DSN="user=gorm password=gorm DB.name=gorm port=9920 sslmode=disable TimeZone=Asia/Shanghai" ./tests/tests_all.sh
- name: run postgres11
run: GORM_DIALECT=postgres GORM_VERBOSE=true GORM_DSN="user=gorm password=gorm DB.name=gorm port=9921 sslmode=disable TimeZone=Asia/Shanghai" ./tests/tests_all.sh
- name: run postgres10
run: GORM_DIALECT=postgres GORM_VERBOSE=true GORM_DSN="user=gorm password=gorm DB.name=gorm port=9922 sslmode=disable TimeZone=Asia/Shanghai" ./tests/tests_all.sh
- name: run mssql
run: GORM_DIALECT=mssql GORM_VERBOSE=true GORM_DSN="sqlserver://gorm:LoremIpsum86@localhost:9930?database=gorm" ./tests/tests_all.sh