-
Notifications
You must be signed in to change notification settings - Fork 17
57 lines (55 loc) · 2.1 KB
/
ci-go-cover.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Copyright 2020-present Montgomery Edwards⁴⁴⁸ (github.com/x448).
# This file is licensed under the MIT License. See LICENSE at https://github.com/x448/workflows for the full text.
#
# CI Go Cover 2020.1.28.
# This GitHub Actions workflow checks if Go (Golang) code coverage satisfies the required minimum.
# The required minimum is specified in the workflow name to keep badge.svg and verified minimum in sync.
#
# To help protect your privacy, this workflow avoids external services.
# This workflow simply runs `go test -short -cover` --> grep --> python.
# The python script is embedded and readable in this file.
#
# Steps to install and set minimum required coverage:
# 0. Copy this file to github.com/OWNER_NAME/REPO_NAME/.github/workflows/ci-go-cover.yml
# 1. Change workflow name from "cover 100%" to "cover ≥92.5%". Script will automatically use 92.5%.
# 2. Update README.md to use the new path to badge.svg because the path includes the workflow name.
name: cover ≥57.0%
on: [push, pull_request]
jobs:
cover:
name: Coverage
runs-on: ubuntu-latest
env:
GO111MODULE: on
CI_PIPELINE: true
steps:
- uses: actions/setup-go@v3
with:
go-version: "1.22"
- name: Checkout code
uses: actions/checkout@v2
- name: Install mockgen
run: |
go install github.com/golang/mock/[email protected]
- name: Install gopls
run: |
go install golang.org/x/tools/gopls@latest
- name: Install guru
run: |
go install golang.org/x/tools/cmd/guru@latest
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: '3.x'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: protoc-gen deps
run: |
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
go install github.com/mitchellh/[email protected]
- name: Go Coverage
run: |
go version
make coverage \
COVER_THRESHOLD=$(echo "${{ vars.GITHUB_WORKFLOW }}" | grep -o --regex '[0-9]\+\.[0-9]\+')
shell: bash