Skip to content

ci: 1

ci: 1 #16

Workflow file for this run

name: CI
on:
push:
branches:
- staging
tags:
- 'v*'
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
# 确保同一时间只运行一个工作流
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: read
jobs:
test:
# 避免在 PR 和 push 时重复运行
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/staging') ||
(github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
cache: true
- name: Install dependencies
run: go mod download
- name: Run Tests
run: |
go test -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: success()
with:
file: ./coverage.txt
flags: unittests
fail_ci_if_error: false