Skip to content

Commit

Permalink
update go.mod, CI, coverage, badges (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgreben authored Sep 26, 2024
1 parent 0357004 commit d9853b6
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 10 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/gocover.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Go coverage badge # The name of the workflow that will appear on Github

on:
push:
branches: [master]
pull_request:
branches: [master]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
go: [1.23]
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

- name: Build
run: go install

- name: Test
run: |
go test -v -cover ./... -coverprofile coverage.out -coverpkg ./...
go tool cover -func coverage.out -o coverage.out # Replaces coverage.out with the analysis of coverage.out
- name: Go Coverage Badge
uses: tj-actions/coverage-badge-go@v2
if: ${{ runner.os == 'Linux' && matrix.go == '1.23' }} # Runs this on only one of the ci builds.
with:
green: 80
filename: coverage.out
link: https://github.com/sgreben/flagvar/actions/workflows/gocover.yaml

- uses: stefanzweifel/git-auto-commit-action@v5
id: auto-commit-action
with:
commit_message: Apply Code Coverage Badge
skip_fetch: true
skip_checkout: true
file_pattern: ./README.md

- name: Push Changes
if: steps.auto-commit-action.outputs.changes_detected == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ github.token }}
branch: ${{ github.ref }}
23 changes: 15 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@ name: Test

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

jobs:
test:
build:
runs-on: ubuntu-latest
container:
image: golang:1.13.11-alpine3.10
steps:
- name: Install cgo dependencies
run: apk add --no-cache build-base
- name: Checkout
uses: actions/checkout@master
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23"

- name: Build
run: go build -v ./...

- name: Test
run: go test ./...
run: go test -v ./...
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# flagvar

[![](https://godoc.org/github.com/sgreben/flagvar?status.svg)](http://godoc.org/github.com/sgreben/flagvar) ![Test](https://github.com/sgreben/flagvar/workflows/Test/badge.svg) [![](https://goreportcard.com/badge/github.com/sgreben/flagvar/goreportcard)](https://goreportcard.com/report/github.com/sgreben/flagvar)
[![Coverage](https://img.shields.io/badge/Coverage-95.5%25-brightgreen)](https://github.com/sgreben/flagvar/actions/workflows/gocover.yaml)

[![Test](https://github.com/sgreben/flagvar/workflows/Test/badge.svg)](https://github.com/sgreben/flagvar/actions/workflows/test.yml)
[![Go Reference](https://pkg.go.dev/badge/github.com/sgreben/flagvar.svg)](https://pkg.go.dev/github.com/sgreben/flagvar)
[![Go Report Card](https://goreportcard.com/badge/github.com/sgreben/flagvar)](https://goreportcard.com/report/github.com/sgreben/flagvar)


A collection of CLI argument types for the `flag` package.

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/sgreben/flagvar

go 1.14
go 1.23

require github.com/gobwas/glob v0.2.3

0 comments on commit d9853b6

Please sign in to comment.