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-19 23:20:51 +08:00
|
|
|
env:
|
|
|
|
GF_DEBUG: 1
|
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:36:43 +08:00
|
|
|
go: ["1.14", "1.15", "1.16", "1.17"]
|
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
|
|
|
|
git diff --name-only --exit-code || exit 1
|
|
|
|
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
|
|
|
|