diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a0aac7f0..106afdc9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,10 +11,11 @@ on: jobs: # Label of the container job sqlite: - runs-on: ubuntu-latest strategy: matrix: go: ['1.14', '1.13'] + platform: [ubuntu-latest, macos-latest] # can not run in windows OS + runs-on: ${{ matrix.platform }} steps: - name: Set up Go 1.x @@ -25,16 +26,47 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: go mod pakcage cache + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('tests/go.mod') }} + - name: run sqlite run: GORM_DIALECT=sqlite GORM_VERBOSE=true ./tests/tests_all.sh + sqlite_windows: + strategy: + matrix: + go: ['1.14', '1.13'] + platform: [windows-latest] + runs-on: ${{ matrix.platform }} + + 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: go mod pakcage cache + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('tests/go.mod') }} + + - name: run sqlite + run: cd tests && set GORM_DIALECT=sqlite && go test $race -count=1 -v ./... #run the line in widnows's CMD, default GORM_DIALECT is sqlite mysql: - runs-on: ubuntu-latest strategy: matrix: dbversion: ['mysql:latest', 'mysql:5.7', 'mysql:5.6', 'mariadb:latest'] go: ['1.14', '1.13'] + platform: [ubuntu-latest] + runs-on: ${{ matrix.platform }} services: mysql: @@ -56,18 +88,23 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v2 - - name: show ports - run: netstat -lntp + + - name: go mod pakcage cache + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('tests/go.mod') }} - 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'] + platform: [ubuntu-latest] # can not run in macOS and widnowsOS + runs-on: ${{ matrix.platform }} services: postgres: @@ -95,18 +132,21 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v2 - - name: show ports - run: netstat -lntp + - name: go mod pakcage cache + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('tests/go.mod') }} - 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 - sqlserver: - runs-on: ubuntu-latest strategy: matrix: go: ['1.14', '1.13'] + platform: [ubuntu-latest] # can not run test in macOS and windows + runs-on: ${{ matrix.platform }} services: mssql: @@ -129,8 +169,11 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v2 - - name: show ports - run: netstat -lntp + - name: go mod pakcage cache + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('tests/go.mod') }} - name: run sqlserver run: GORM_DIALECT=sqlserver GORM_VERBOSE=true GORM_DSN="sqlserver://gorm:LoremIpsum86@localhost:9930?database=gorm" ./tests/tests_all.sh