NicholeGit / ActionsDemo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[toc]

ActionsDemo

Go Release codecov

github actions

Actions yml文件语法

  • 当代码推送到 master和 release分支的时候触发构建
on:
  push:
    branches:
    - master
    - release/*
  • 当只有 pull_request被合并到 master分支的时候:
on:
  pull_request:
    branches:
    - master
  • 比如星期一到星期五的每天2点构建任务呢:
on:
  schedule:
  - cron: 0 2 * * 1-5

goreleaser 生成

go install github.com/goreleaser/goreleaser@latest
goreleaser init
goreleaser build --single-target
goreleaser release --snapshot 

徽章

CI&CD 徽章

Go

https://github.com/NicholeGit/ActionsDemo/workflows/Go/badge.svg
  • https://github.com/NicholeGit/ActionsDemo/ 是项目的地址
  • workflows/Go/badge.svg 中间的 Go 是 https://github.com/NicholeGit/ActionsDemo/actions 下的名称。需要注意区分大小写

Release 徽章

Release

  • 需要创建 release 版本才出现

测试覆盖率 徽章

codecov

  • 编写.travis.yml 文件
language: go # 使用语言.
go: 
  - 1.15.6  # 版本号, 支持多种版本号

sudo: required #  #有定制化开发环境需要,默认false,不开启容器,编译效率高 

os:            # 使用的操作系统 
  - linux
  - osx

notifications:  # 邮箱通知
  email: freeit@126.com

go_import_path: # 使用Go需要导入的包. 
  - github.com/gin-gonic/gin
  - github.com/pkg/errors
  - github.com/smartystreets/goconvey

before_install: # 主要安装一些系统依赖,
  - go mod tidy

install: true # 安装, true跳过

script: # 脚本执行.
  - echo "run"
  - go test -race -coverprofile=coverage.txt -covermode=atomic
  - go test -v ./...

after_success: # 上传测试报告
  - bash <(curl -s https://codecov.io/bash)

About


Languages

Language:Go 100.0%