Skip to content

Commit

Permalink
workflow: init docker test
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Oct 17, 2023
1 parent ba1efcc commit e73b433
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 4 deletions.
37 changes: 37 additions & 0 deletions .github/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: '3'

services:
mysql:
image: 'mysql/mysql-server:latest'
ports:
- 9910:3306
environment:
- MYSQL_DATABASE=goravel
- MYSQL_USER=goravel
- MYSQL_PASSWORD=GoravelTest123
- MYSQL_RANDOM_ROOT_PASSWORD="yes"
postgres:
image: 'postgres:latest'
ports:
- 9920:5432
environment:
- TZ=Asia/Shanghai
- POSTGRES_DB=goravel
- POSTGRES_USER=goravel
- POSTGRES_PASSWORD=GoravelTest123
mssql:
image: '${MSSQL_IMAGE:-mcmoe/mssqldocker}:latest'
ports:
- 9930:1433
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=GoravelTest123
- MSSQL_DB=goravel
- MSSQL_USER=goravel
- MSSQL_PASSWORD=GoravelTest123
redis:
image: 'redis:latest'
ports:
- 9940:6379
environment:
- REDIS_PASSWORD=GoravelTest123
3 changes: 3 additions & 0 deletions .github/docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash -e

echo "OK"
134 changes: 134 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Test

on:
push:
branches: [ master ]
pull_request:

jobs:
# Label of the container job
sqlite:
strategy:
matrix:
go:
- "stable"
- "oldstable"
platform:
- ubuntu-latest
runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- name: Run tests
run: GORAVEL_DATABASE=sqlite bash .github/docker.sh

mysql:
strategy:
matrix:
dbversion: [ 'mysql:latest' ]
go:
- "stable"
- "oldstable"
platform:
- ubuntu-latest
runs-on: ${{ matrix.platform }}

services:
mysql:
image: ${{ matrix.dbversion }}
env:
MYSQL_DATABASE: goravel
MYSQL_USER: goravel
MYSQL_PASSWORD: GoravelTest123
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
ports:
- 9910:3306
options: >-
--health-cmd "mysqladmin ping -u${MYSQL_USER} -p${MYSQL_PASSWORD}"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- name: Run tests
run: GORAVEL_DATABASE=mysql bash .github/docker.sh

postgres:
strategy:
matrix:
dbversion: [ 'postgres:latest' ]
go:
- "stable"
- "oldstable"
platform:
- ubuntu-latest
runs-on: ${{ matrix.platform }}

services:
postgres:
image: ${{ matrix.dbversion }}
env:
POSTGRES_PASSWORD: GoravelTest123
POSTGRES_USER: goravel
POSTGRES_DB: goravel
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:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- name: Run tests
run: GORAVEL_DATABASE=postgres bash .github/docker.sh

sqlserver:
strategy:
matrix:
go:
- "stable"
- "oldstable"
platform:
- ubuntu-latest
runs-on: ${{ matrix.platform }}

services:
mssql:
image: mcmoe/mssqldocker:latest
env:
ACCEPT_EULA: Y
SA_PASSWORD: GoravelTest123
MSSQL_DB: goravel
MSSQL_USER: goravel
MSSQL_PASSWORD: GoravelTest123
ports:
- 9930:1433
options: >-
--health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SA_PASSWORD} -l 30 -Q \"SELECT 1\" || exit 1"
--health-start-period 10s
--health-interval 10s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- name: Run tests
run: GORAVEL_DATABASE=sqlserver bash .github/docker.sh
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
strategy:
matrix:
go:
- "1.20"
- "1.21"
- "stable"
- "oldstable"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -25,8 +25,8 @@ jobs:
strategy:
matrix:
go:
- "1.20"
- "1.21"
- "stable"
- "oldstable"
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
Expand Down

0 comments on commit e73b433

Please sign in to comment.