gf/.github/workflows/go.yml

91 lines
2.0 KiB
YAML
Raw Normal View History

2021-07-19 23:20:51 +08:00
name: Go
on:
push:
2021-07-21 00:02:15 +08:00
branches:
2021-07-19 23:20:51 +08:00
- master
- main
- develop
- staging
pull_request:
branches: [ master ]
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:
image: redis
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
postgres:
image: postgres:9
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: 12345678
MYSQL_DATABASE: test
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:
go: [ '1.13', '1.14','1.15','1.16' ]
2021-07-19 23:20:51 +08:00
steps:
2021-07-20 23:26:53 +08:00
- uses: szenius/set-timezone@v1.0
with:
timezoneLinux: "Asia/Shanghai"
2021-07-19 23:20:51 +08:00
- uses: actions/checkout@v2
- name: Set up Go
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
- name: Before script
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
# - name: Build
# run: go build -v ./...
2021-07-21 00:02:15 +08:00
- name: 386 mode Test
run: GOARCH=386 go test -v ./... || exit 1
- name: amd64 mode Test
run: GOARCH=amd64 go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic
- name: report coverage
run: bash <(curl -s https://codecov.io/bash)