Skip to content

gfunc

gfunc #500

Workflow file for this run

on:
push:
branches:
- master
pull_request:
branches:
- master
name: build
jobs:
testing:
strategy:
matrix:
go-version: [ 1.16.x,1.17.x,1.18.x,1.19.x,1.20.x,1.21.x,1.22.x ]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
services:
mysql:
image: mysql:5.5
env:
MYSQL_ROOT_PASSWORD: admin
MYSQL_DATABASE: test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis
ports:
- 6379:6379
options: --name redis
steps:
- name: Verify MYSQL connection
env:
PORT: ${{ job.services.mysql.ports[3306] }}
run: |
while ! mysqladmin ping -h"127.0.0.1" -P"$PORT" --silent; do
sleep 1
done
- name: Checkout code
uses: actions/checkout@v3
- name: Setting Up DB
run: |
mysql -h 127.0.0.1 -P 3306 --protocol=tcp -u root -padmin < .ci/tests.db.sql
- name: Install Go
if: success()
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Run tests
run: |
export GO111MODULE=on
export WORKPATH=$(pwd)
export GOPATH=$(go env GOPATH)
export SNAIL007PATH=$GOPATH/src/github.com/snail007/
mkdir -p $GOPATH/src/github.com/snail007
cd ../ && cp -R gmc $SNAIL007PATH/ && cd $SNAIL007PATH/gmc
go get -v -t -d ./...
go test ./...
codecov:
environment: gmc
name: codecov
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.5
env:
MYSQL_ROOT_PASSWORD: admin
MYSQL_DATABASE: test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis
ports:
- 6379:6379
options: --name redis
steps:
- name: Verify MYSQL connection
env:
PORT: ${{ job.services.mysql.ports[3306] }}
run: |
while ! mysqladmin ping -h"127.0.0.1" -P"$PORT" --silent; do
sleep 1
done
- name: Set up Go 1.20
uses: actions/setup-go@v3
with:
go-version: 1.20.x
id: go
- name: Checkout code
uses: actions/checkout@v3
- name: Init & Run
run: |
export WORKPATH=$(pwd)
export GOPATH=$(go env GOPATH)
export SNAIL007PATH=$GOPATH/src/github.com/snail007/
export F=gmct-linux-amd64.tar.gz
export LAST_VERSION=$(curl --silent "https://api.github.com/repos/snail007/gmct/releases/latest" | grep -Po '"tag_name": ?"\K.*?(?=")')
mkdir -p $GOPATH/src/github.com/snail007
mysql -h 127.0.0.1 -P 3306 --protocol=tcp -u root -padmin < .ci/tests.db.sql
wget -q -t 1 "https://github.com/snail007/gmct/releases/download/${LAST_VERSION}/$F"
tar zxf $F && chmod +x gmct && rm -rf $F
cd ../ && cp -R gmc $SNAIL007PATH/
cd $SNAIL007PATH/gmc/ && go get -v -t -d ./... && ./gmct cover -s -k
mv coverage.txt $WORKPATH/
- name: Upload coverage report
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
flags: unittests
name: codecov-umbrella