mirror of
https://gitee.com/johng/gf.git
synced 2024-12-03 20:58:47 +08:00
167 lines
4.1 KiB
YAML
167 lines
4.1 KiB
YAML
name: GoFrame Main CI
|
|
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- develop
|
|
- feature/**
|
|
- fix/**
|
|
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
- develop
|
|
- feature/**
|
|
- fix/**
|
|
|
|
env:
|
|
GF_DEBUG: 0
|
|
|
|
|
|
jobs:
|
|
code-test:
|
|
runs-on: ubuntu-latest
|
|
|
|
# Service containers to run with `code-test`
|
|
services:
|
|
# Redis backend server.
|
|
redis:
|
|
image : loads/redis:latest
|
|
options: >-
|
|
--health-cmd "redis-cli ping"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
# Maps tcp port 6379 on service container to the host
|
|
- 6379:6379
|
|
|
|
# MySQL backend server.
|
|
mysql:
|
|
image: loads/mysql:5.7
|
|
env:
|
|
MYSQL_DATABASE : test
|
|
MYSQL_ROOT_PASSWORD: 12345678
|
|
ports:
|
|
# Maps tcp port 3306 on service container to the host
|
|
- 3306:3306
|
|
|
|
# PostgreSQL backend server.
|
|
postgres:
|
|
image: loads/postgres:13
|
|
env:
|
|
POSTGRES_PASSWORD: 12345678
|
|
POSTGRES_USER: root
|
|
POSTGRES_DB: test
|
|
TZ: Asia/Shanghai
|
|
ports:
|
|
- 5432:5432
|
|
# Set health checks to wait until postgres has started
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
|
|
# MSSQL backend server.
|
|
mssql:
|
|
image: loads/mssqldocker:latest
|
|
env:
|
|
ACCEPT_EULA: Y
|
|
SA_PASSWORD: LoremIpsum86
|
|
MSSQL_DB: test
|
|
MSSQL_USER: root
|
|
MSSQL_PASSWORD: LoremIpsum86
|
|
ports:
|
|
- 1433: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
|
|
|
|
# ClickHouse backend server.
|
|
clickhouse-server:
|
|
image: loads/clickhouse-server:latest
|
|
ports:
|
|
- 9000:9000
|
|
- 8123:8123
|
|
- 9001:9001
|
|
|
|
polaris:
|
|
image: houseme/polaris-server-with-config:latest
|
|
ports:
|
|
- 8090:8090
|
|
- 8091:8091
|
|
|
|
#oracle 11g server
|
|
oracle-server:
|
|
image: loads/oracle-xe-11g-r2:latest
|
|
env:
|
|
ORACLE_ALLOW_REMOTE: true
|
|
ORACLE_SID: XE
|
|
ORACLE_DB_USER_NAME: system
|
|
ORACLE_DB_PASSWORD: oracle
|
|
ports:
|
|
- 1521:1521
|
|
|
|
|
|
|
|
strategy:
|
|
matrix:
|
|
go: [ "1.15", "1.16", "1.17" ]
|
|
goarch: [ "386", "amd64" ]
|
|
|
|
|
|
steps:
|
|
- name: Set Up Timezone
|
|
uses: szenius/set-timezone@v1.0
|
|
with:
|
|
timezoneLinux: "Asia/Shanghai"
|
|
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Set Up Go
|
|
uses: actions/setup-go@v2
|
|
with:
|
|
go-version: ${{ matrix.go }}
|
|
|
|
- name: Before Script
|
|
run: |
|
|
find . -name "*.go" | xargs gofmt -w
|
|
git diff --name-only --exit-code || if [ $? != 0 ]; then echo "Notice: gofmt check failed,please gofmt before pr." && exit 1; fi
|
|
echo "gofmt check pass."
|
|
sudo echo "127.0.0.1 local" | sudo tee -a /etc/hosts
|
|
|
|
- name: Build & Test
|
|
run: |
|
|
GOARCH=${{ matrix.goarch }}
|
|
for file in `find . -name go.mod`; do
|
|
dirpath=$(dirname $file)
|
|
|
|
if [ "oracle" = $(basename $dirpath) ]; then
|
|
if ! go version|grep -q "1.17"; then
|
|
continue 1
|
|
fi
|
|
fi
|
|
|
|
cd $dirpath
|
|
go mod tidy
|
|
go build ./...
|
|
go test ./... -race -coverprofile=coverage.out -covermode=atomic -coverpkg=./...,github.com/gogf/gf/... || exit 1
|
|
if grep -q "/gogf/gf/.*/v2" go.mod; then
|
|
sed -i "s/gogf\/gf\(\/.*\)\/v2/gogf\/gf\/v2\1/g" coverage.out
|
|
fi
|
|
cd -
|
|
done
|
|
|
|
- name: Report Coverage
|
|
uses: codecov/codecov-action@v2
|
|
with:
|
|
flags: go-${{ matrix.go }}-${{ matrix.goarch }}
|
|
|