123 lines
3.3 KiB
YAML
123 lines
3.3 KiB
YAML
name: UnitTest
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
env:
|
|
# 象传服务配置
|
|
XIANG_MODE: debug
|
|
XIANG_SOURCE: ${{ github.WORKSPACE }}/xiang
|
|
XIANG_ROOT: fs://${{ github.WORKSPACE }}/xiang/app
|
|
|
|
# 服务配置
|
|
XIANG_SERVICE_DEBUG: true
|
|
XIANG_SERVICE_ALLOW: "xiang.yao.run:3000|xiang.yao.run:3001"
|
|
XIANG_SERVICE_HOST: 0.0.0.0
|
|
XIANG_SERVICE_PORT: 5099
|
|
|
|
# 数据库配置
|
|
XIANG_DB_DEBUG: true
|
|
XIANG_DB_DRIVER: "mysql"
|
|
XIANG_DB_AESKEY: "ZLX:XzT&f6refeCh-ro*r@"
|
|
|
|
# JWT配置
|
|
XIANG_JWT_DEBUG: true
|
|
XIANG_JWT_SECRET: "bLp@bi!oqo-2U+hoTRUG"
|
|
|
|
# 存储配置
|
|
XIANG_STOR_DEBUG: true
|
|
XIANG_STOR_PATH: "fs://${{ github.WORKSPACE }}/xiang/upload"
|
|
|
|
# 日志配置
|
|
XIANG_LOG_ACCESS: "fs://${{ github.WORKSPACE }}/xiang/logs/access.log"
|
|
XIANG_LOG_ERROR: "fs://${{ github.WORKSPACE }}/xiang/logs/error.log"
|
|
XIANG_LOG_DB: "fs://${{ github.WORKSPACE }}/xiang/logs/db.log"
|
|
XIANG_LOG_PLUGIN: "fs://${{ github.WORKSPACE }}/xiang/logs/plugin.log"
|
|
|
|
jobs:
|
|
unit-test:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
go: [1.17]
|
|
db: [SQLite3]
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Checkout Kun
|
|
uses: actions/checkout@v2
|
|
with:
|
|
repository: yaoapp/kun
|
|
path: kun
|
|
|
|
- name: Checkout Xun
|
|
uses: actions/checkout@v2
|
|
with:
|
|
repository: yaoapp/xun
|
|
path: xun
|
|
|
|
- name: Checkout Gou
|
|
uses: actions/checkout@v2
|
|
with:
|
|
repository: yaoapp/gou
|
|
path: gou
|
|
token: ${{ secrets.TOKEN }}
|
|
|
|
- name: Checkout Xiang
|
|
uses: actions/checkout@v2
|
|
with:
|
|
path: xiang
|
|
|
|
- name: Setup ${{ matrix.db }}
|
|
uses: ./.github/actions/setup-db
|
|
with:
|
|
kind: "${{ matrix.db }}"
|
|
db: "xun"
|
|
user: "xun"
|
|
password: ${{ secrets.UNIT_PASS }}
|
|
|
|
- name: Setup Go ${{ matrix.go }}
|
|
uses: actions/setup-go@v2
|
|
with:
|
|
go-version: ${{ matrix.go }}
|
|
|
|
- name: Setup Go Tools
|
|
run: |
|
|
if [[ "${GO111MODULE}" = "on" ]]; then go mod download; fi
|
|
if [[ "${GO111MODULE}" = "on" ]]; then export PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"; fi
|
|
if [[ "${GO111MODULE}" = "on" ]]; then make tools; fi
|
|
|
|
- name: Setup ENV & Host
|
|
run: |
|
|
sudo echo "127.0.0.1 local.iqka.com" | sudo tee -a /etc/hosts
|
|
echo "XIANG_DB_DRIVER=$DB_DRIVER" >> $GITHUB_ENV
|
|
ls -l .
|
|
ls -l $GITHUB_WORKSPACE
|
|
ls -l ..
|
|
|
|
- name: Run Test
|
|
env:
|
|
PASSWORD: ${{ secrets.UNIT_PASS }}
|
|
run: |
|
|
if [ "$DB_DRIVER" = "mysql" ]; then
|
|
XIANG_DB_PRIMARY="$DB_USER:$PASSWORD@$DB_HOST" make test
|
|
elif [ "$DB_DRIVER" = "postgres" ]; then
|
|
XIANG_DB_PRIMARY="postgres://$DB_USER:$PASSWORD@$DB_HOST" make test
|
|
else
|
|
XIANG_DB_PRIMARY="$DB_HOST" make test
|
|
fi
|
|
|
|
cd xiang && make vet
|
|
cd xiang && make fmt-check
|
|
cd xiang && make misspell-check
|
|
cd xiang && make plugin
|
|
cd xiang && make migrate
|
|
cd xiang && make test
|
|
|
|
- name: Codecov Report
|
|
uses: codecov/codecov-action@v2
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
|