-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c952d3
commit 2e48ce5
Showing
5 changed files
with
64 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# 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 ≥89% | ||
on: [push] | ||
jobs: | ||
|
||
# Verify minimum coverage is reached using `go test -short -cover` on latest-ubuntu with default version of Go. | ||
# The grep expression can't be too strict, it needed to be relaxed to work with different versions of Go. | ||
cover: | ||
name: Coverage | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Install test cases | ||
run: make install | ||
- name: Go Coverage | ||
run: | | ||
go version | ||
go test -short -cover | grep "^.*coverage:.*of statements$" | python -c "import os,re,sys; cover_rpt = sys.stdin.read(); print(cover_rpt) if len(cover_rpt) != 0 and len(cover_rpt.splitlines()) == 1 else sys.exit(1); min_cover = float(re.findall(r'\d*\.\d+|\d+', os.environ['GITHUB_WORKFLOW'])[0]); cover = float(re.findall(r'\d*\.\d+|\d+', cover_rpt)[0]); sys.exit(1) if (cover > 100) or (cover < min_cover) else sys.exit(0)" | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# GitHub Actions - CI for Go to build & test. See ci-go-cover.yml and linters.yml for code coverage and linters. | ||
# Taken from: https://github.com/fxamacker/cbor/workflows/ci.yml (thanks!) | ||
name: ci | ||
on: [push] | ||
jobs: | ||
|
||
# Test on various OS with default Go version. | ||
tests: | ||
name: Test on ${{matrix.os}} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
- name: Get dependencies | ||
run: go get -v -t -d ./... | ||
- name: Build project | ||
run: go build . | ||
- name: Install test cases | ||
run: make install | ||
- name: Run tests | ||
run: | | ||
go version | ||
go test -short -race -v . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters