Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update repo from template #73

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 10 additions & 40 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
name: CI

on:
workflow_call:
pull_request:
push:
branches:
- main
tags:
- v*

concurrency:
group: ${{ github.ref }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions: read-all
permissions: {}

jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
matrix:
os:
Expand All @@ -40,6 +41,8 @@ jobs:
cov:
name: CodeCov
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout Code
Expand All @@ -57,10 +60,13 @@ jobs:
uses: codecov/codecov-action@v4
with:
files: ./coverage.out
token: ${{ secrets.CODECOV_TOKEN }}

lint:
name: Lint
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout Code
Expand All @@ -78,39 +84,3 @@ jobs:
uses: golangci/golangci-lint-action@v6
with:
version: latest

release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write

needs:
- test
- cov
- lint

if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Fetch Existing Tags
run: git fetch --force --tags

- name: Parse Release Version
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Publish Draft Release
uses: release-drafter/release-drafter@v6
with:
version: ${{ steps.version.outputs.version }}
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

permissions: {}

jobs:
ci:
name: CI
uses: FollowTheProcess/msg/.github/workflows/CI.yml@main
secrets: inherit
permissions:
contents: read

release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read

needs:
- ci

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Fetch Existing Tags
run: git fetch --force --tags

- name: Parse Release Version
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT

- name: Publish Draft Release
uses: release-drafter/release-drafter@v6
with:
version: ${{ steps.version.outputs.version }}
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

MIT License

Copyright (c) 2023, Tom Fleet
Copyright (c) 2024, Tom Fleet

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
35 changes: 0 additions & 35 deletions Makefile

This file was deleted.

66 changes: 66 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# https://taskfile.dev

version: "3"

vars:
COV_DATA: coverage.out

tasks:
default:
desc: List all available tasks
silent: true
cmd: task --list

tidy:
desc: Tidy dependencies in go.mod and go.sum
cmd: go mod tidy

fmt:
desc: Run go fmt on all source files
cmd: go fmt ./...

test:
desc: Run the test suite
cmd: go test -race ./... {{ .CLI_ARGS }}

bench:
desc: Run all project benchmarks
cmd: go test ./... -run None -benchmem -bench . {{ .CLI_ARGS }}

lint:
desc: Run the linters and auto-fix if possible
cmd: golangci-lint run --fix
preconditions:
- sh: command -v golangci-lint
msg: golangci-lint not installed, see https://golangci-lint.run/usage/install/#local-installation

doc:
desc: Render the pkg docs locally
cmd: pkgsite -open
preconditions:
- sh: command -v pkgsite
msg: pkgsite not installed, run go install golang.org/x/pkgsite/cmd/pkgsite@latest

cov:
desc: Calculate test coverage and render the html
generates:
- "{{ .COV_DATA }}"
cmds:
- go test -race -cover -covermode atomic -coverprofile {{ .COV_DATA }} ./...
- go tool cover -html {{ .COV_DATA }}

check:
desc: Run tests and linting in one
cmds:
- task: test
- task: lint

sloc:
desc: Print lines of code
cmd: fd . -e go | xargs wc -l | sort -nr | head

clean:
desc: Remove build artifacts and other clutter
cmds:
- go clean ./...
- rm -rf {{ .COV_DATA }}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ require github.com/fatih/color v1.17.0
require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/sys v0.22.0 // indirect
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
Loading