gf/.github/workflows/go.yml

73 lines
1.7 KiB
YAML
Raw Normal View History

2021-08-01 09:33:12 +08:00
name: GoFrame CI
2021-07-19 23:20:51 +08:00
on:
push:
2021-07-21 00:02:15 +08:00
branches:
2021-07-19 23:20:51 +08:00
- master
- develop
pull_request:
2021-08-01 09:33:12 +08:00
branches: [master, develop]
2021-07-21 00:02:15 +08:00
2021-07-19 23:20:51 +08:00
jobs:
code-test:
runs-on: ubuntu-latest
# 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
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
# strategy set
strategy:
matrix:
2021-09-19 10:50:31 +08:00
go: ["1.14", "1.15", "1.16"]
2021-07-22 09:29:26 +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
2021-08-01 09:33:12 +08:00
- name: Checkout Repositary
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: |
2021-07-20 23:26:53 +08:00
date
2021-07-19 23:20:51 +08:00
find . -name "*.go" | xargs gofmt -w
2021-11-18 11:56:03 +08:00
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."
2021-07-19 23:20:51 +08:00
sudo echo "127.0.0.1 local" | sudo tee -a /etc/hosts
2021-08-01 09:33:12 +08:00
- name: Run i386 Arch Test
2021-07-21 00:02:15 +08:00
run: GOARCH=386 go test -v ./... || exit 1
2021-08-01 09:33:12 +08:00
- name: Run amd64 Arch Test
2021-07-21 00:02:15 +08:00
run: GOARCH=amd64 go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic
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