Skip to content

Commit

Permalink
Add command to print change Go packages
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhughes934 authored and matthewhughes-uw committed Nov 22, 2024
0 parents commit 06a4f62
Show file tree
Hide file tree
Showing 40 changed files with 2,859 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
groups:
all:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
30 changes: 30 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Checks
on:
push:
branches:
- main
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: test
run: make report-coverage
- name: check-coverage
run: make check-coverage

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- uses: pre-commit/[email protected]
31 changes: 31 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release
on:
push:
tags:
- 'v*'


permissions:
# Permission for GITHUB_TOKEN to be able to create release
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/coverage.out
/go-cov.out

# goreleaser build outputs
dist/
47 changes: 47 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
run:
tests: true

linters-settings:
errcheck:
check-type-assertions: true
check-blank: true
revive:
rules:
- name: exported
disabled: true
- name: context-as-argument
disabled: false
nolintlint:
require-specific: true
errorlint:
errorf: false
gci:
sections:
- standard
- default
- localmodule
linters:
enable-all: true

disable:
# deprecated linters
- exportloopref

# conflicting/cover same issues
- forcetypeassert # covered by errcheck

# personal preference
- gocritic
- depguard
- funlen
- exhaustruct
- gochecknoglobals
- err113
- nlreturn
- paralleltest
- testpackage
- varnamelen
- wsl
# premature optimisation that creates inconsistent code (sometimes Sprintf, sometimes string concatenation)
# consider enabling _if_ you've profile performance _and_ Sprintf calls are slowing you down
- perfsprint
47 changes: 47 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines bellow are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
version: 2

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...

builds:
- id: uw-releaser
main: ./cmd/
binary: go-changed-pkgs
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip

changelog:
disable: true

release:
header: See [the changelog](https://github.com/utilitywarehouse/go-changed-pkgs/blob/{{.Tag}}/CHANGELOG.md)
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
repos:
- repo: https://github.com/matthewhughes934/pre-commit-format-markdown
rev: v0.5.0
hooks:
- id: format-markdown-docker
- repo: https://github.com/golangci/golangci-lint
rev: v1.62.0
hooks:
- id: golangci-lint-full
language_version: "1.23.0"
- repo: https://gitlab.com/matthewhughes/common-changelog
rev: v0.2.0
hooks:
- id: validate-changelog
- repo: https://github.com/matthewhughes934/golines
rev: v0.12.0
hooks:
- id: golines
exclude: testdata
- repo: https://gitlab.com/matthewhughes/go-pre-commit
rev: v0.3.0
hooks:
- id: go-mod-tidy
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.PHONY: coverage.out
coverage.out:
@go test -race -coverprofile $@ ./...

go-cov.out: coverage.out
@go run gitlab.com/matthewhughes/go-cov/cmd/go-cov add-skips $^ > go-cov.out

.PHONY: report-coverage
report-coverage: go-cov.out
@go tool cover -func=$^

.PHONY: report-coverage-html
report-coverage-html: go-cov.out
@go tool cover -html=$^

.PHONY: check-coverage
check-coverage: go-cov.out
@go run gitlab.com/matthewhughes/go-cov/cmd/go-cov report --fail-under 100 $^

.PHONY: build
build:
# --skip=validate to allow for dirty Git state during dev
# --single-target to only build for the current OS/Arch
@go run github.com/goreleaser/goreleaser build --single-target --skip=validate --clean
Loading

0 comments on commit 06a4f62

Please sign in to comment.