gf/.github/workflows/gf.yml

164 lines
4.0 KiB
YAML
Raw Normal View History

name: GoFrame Main CI
2021-07-19 23:20:51 +08:00
2022-02-08 23:52:29 +08:00
2021-07-19 23:20:51 +08:00
on:
push:
2021-07-21 00:02:15 +08:00
branches:
2022-01-24 16:32:59 +08:00
- master
- develop
2022-05-07 16:43:28 +08:00
- feature/**
- fix/**
2021-07-19 23:20:51 +08:00
pull_request:
2022-01-24 16:32:59 +08:00
branches:
- master
- develop
2022-05-07 16:43:28 +08:00
- feature/**
- fix/**
2022-02-08 23:52:29 +08:00
2021-12-04 23:07:54 +08:00
env:
GF_DEBUG: 0
2021-07-21 00:02:15 +08:00
2022-02-08 23:52:29 +08:00
2021-07-19 23:20:51 +08:00
jobs:
code-test:
runs-on: ubuntu-latest
2022-02-08 23:52:29 +08:00
2021-07-19 23:20:51 +08:00
# Service containers to run with `code-test`
services:
redis:
2021-08-01 09:33:12 +08:00
image : redis
2021-07-19 23:20:51 +08:00
options: >-
2021-08-01 09:33:12 +08:00
--health-cmd "redis-cli ping"
2021-07-19 23:20:51 +08:00
--health-interval 10s
2021-08-01 09:33:12 +08:00
--health-timeout 5s
--health-retries 5
2021-07-19 23:20:51 +08:00
ports:
# Maps tcp port 6379 on service container to the host
- 6379:6379
2022-02-08 23:52:29 +08:00
2021-07-19 23:20:51 +08:00
mysql:
image: mysql:5.7
env:
2021-08-01 09:33:12 +08:00
MYSQL_DATABASE : test
2021-07-19 23:20:51 +08:00
MYSQL_ROOT_PASSWORD: 12345678
ports:
# Maps tcp port 3306 on service container to the host
- 3306:3306
2021-07-22 09:29:26 +08:00
2022-02-08 23:52:29 +08:00
postgres:
image: postgres:13
env:
POSTGRES_PASSWORD: 12345678
POSTGRES_USER: root
POSTGRES_DB: test
TZ: Asia/Shanghai
ports:
2022-02-08 23:57:57 +08:00
- 5432:5432
2022-02-08 23:52:29 +08:00
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
mssql:
image: mcmoe/mssqldocker:latest
env:
ACCEPT_EULA: Y
2022-02-08 23:57:57 +08:00
SA_PASSWORD: LoremIpsum86
2022-02-08 23:52:29 +08:00
MSSQL_DB: test
MSSQL_USER: root
2022-02-08 23:57:57 +08:00
MSSQL_PASSWORD: LoremIpsum86
2022-02-08 23:52:29 +08:00
ports:
2022-02-08 23:57:57 +08:00
- 1433:1433
2022-02-08 23:52:29 +08:00
options: >-
2022-02-08 23:57:57 +08:00
--health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -l 30 -Q \"SELECT 1\" || exit 1"
2022-02-08 23:52:29 +08:00
--health-start-period 10s
--health-interval 10s
--health-timeout 5s
--health-retries 10
2022-02-23 22:51:37 +08:00
clickhouse-server:
image: yandex/clickhouse-server
ports:
- 9000:9000
- 8123:8123
- 9001:9001
2022-02-08 23:52:29 +08:00
2021-07-22 09:29:26 +08:00
# strategy set
strategy:
matrix:
go: ["1.15", "1.16", "1.17"]
2021-07-22 09:29:26 +08:00
2022-02-08 23:52:29 +08:00
2021-07-19 23:20:51 +08:00
steps:
2021-08-01 09:33:12 +08:00
- name: Set Up Timezone
uses: szenius/set-timezone@v1.0
2021-07-20 23:26:53 +08:00
with:
timezoneLinux: "Asia/Shanghai"
2021-07-19 23:20:51 +08:00
- name: Checkout Repository
2021-08-01 09:33:12 +08:00
uses: actions/checkout@v2
2021-07-19 23:20:51 +08:00
2021-08-01 09:33:12 +08:00
- name: Set Up Go
2021-07-19 23:20:51 +08:00
uses: actions/setup-go@v2
with:
2021-07-22 09:29:26 +08:00
go-version: ${{ matrix.go }}
2021-07-19 23:20:51 +08:00
2021-08-01 09:33:12 +08:00
- name: Before Script
2021-07-19 23:20:51 +08:00
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
2021-11-18 11:56:03 +08:00
echo "gofmt check pass."
2021-07-19 23:20:51 +08:00
sudo echo "127.0.0.1 local" | sudo tee -a /etc/hosts
- name: CLI Build & Test
run: |
cd cmd/gf
go mod tidy
go build ./...
go test ./...
2022-05-10 15:47:49 +08:00
GOARCH=386 go test ./... || exit 1
GOARCH=amd64 go test ./... -race -coverprofile=coverage.txt -covermode=atomic || exit 1
- name: Example Build & Test
run: |
cd example
go mod tidy
go build ./...
2022-05-10 15:47:49 +08:00
GOARCH=386 go test ./... || exit 1
GOARCH=amd64 go test ./... -race -coverprofile=coverage.txt -covermode=atomic || exit 1
- name: Contrib Build & Test
run: |
cd contrib
for file in `find . -name go.mod`; do
2022-05-10 15:47:49 +08:00
dirpath=$(dirname $file)
2022-02-08 23:52:29 +08:00
# Ignore oracle database driver build&test.
2022-05-10 15:47:49 +08:00
if [ "oracle" = $(basename $dirpath) ]; then
2022-02-08 23:52:29 +08:00
continue 1
fi
2022-05-10 15:47:49 +08:00
cd $dirpath
go mod tidy
go build ./...
2022-05-10 15:47:49 +08:00
GOARCH=386 go test ./... || exit 1
GOARCH=amd64 go test ./... -race -coverprofile=coverage.txt -covermode=atomic || exit 1
2022-02-08 23:25:33 +08:00
cd -
done
2021-08-01 09:33:12 +08:00
- name: Run i386 Arch Test
run: |
2022-05-10 15:47:49 +08:00
GOARCH=386 go test -v ./... || exit 1
2021-07-21 00:02:15 +08:00
2021-08-01 09:33:12 +08:00
- name: Run amd64 Arch Test
run: |
GOARCH=amd64 go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic || exit 1
2021-07-21 00:02:15 +08:00
2021-08-01 09:33:12 +08:00
- name: Report Coverage
2021-09-19 10:36:43 +08:00
uses: codecov/codecov-action@v2
with:
flags: go-${{ matrix.go }}
2021-07-21 00:02:15 +08:00