From 73f26d30e692cfaf50052b493696b1938b6c3ef8 Mon Sep 17 00:00:00 2001 From: Jesse Portnoy Date: Fri, 4 Aug 2023 00:50:51 +0100 Subject: [PATCH] Better CI --- .github/workflows/go.yml | 30 +++++++++++++++++++----------- .pre-commit-config.yaml | 19 ++++++++++--------- README.md | 19 +++++++++++++++---- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 5ede458..75ee3e2 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -3,11 +3,11 @@ name: Go -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] +on: [push, pull_request] + +defaults: + run: + shell: 'bash -Eeuo pipefail -x {0}' jobs: @@ -22,10 +22,18 @@ jobs: go-version: '1.20' - name: Build - run: cd examples && go mod tidy && go build syncat.go - + run: go build -v - name: Test - run: | - FMT_ISSUES=$(gofmt -l .) - if test -n "$FMT_ISSUES" ;then printf "gofmt found problems:\n$FMT_ISSUES\n";exit 11; fi - go test -v + run: | + set -e + go install github.com/go-critic/go-critic/cmd/gocritic@latest + go install golang.org/x/tools/cmd/goimports@latest + go install golang.org/x/lint/golint@latest + go install github.com/gordonklaus/ineffassign@latest + pip install pre-commit + pre-commit install + pre-commit run --all-files + go test -v + + #- name: Test + #run: go test -v diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6e1b7c3..38d88ab 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,11 @@ -- repo: https://github.com/jessp01/pre-commit-golang - rev: v0.5.3 +repos: + - repo: https://github.com/jessp01/pre-commit-golang.git + rev: v0.5.5 hooks: - - id: go-fmt - - id: go-imports - - id: go-vet - - id: go-lint - - id: go-critic - - id: go-ineffassign - #- id: go-cyclo + - id: go-fmt + - id: go-imports + - id: go-vet + - id: go-lint + - id: go-critic + - id: go-ineffassign + - id: shellcheck diff --git a/README.md b/README.md index ebc9dc4..1e7630e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # Highlight -[![Go Report Card](https://goreportcard.com/badge/github.com/jessp01/gohighlight)](https://goreportcard.com/report/github.com/jessp01/gohighlight) -[![GoDoc](https://godoc.org/github.com/jessp01/gohighlight?status.svg)](http://godoc.org/github.com/jessp01/gohighlight) -[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jessp01/gohighlight/blob/master/LICENSE) + +[![CI][badge-build]][build] +[![GoDoc][go-docs-badge]][go-docs] +[![GoReportCard][go-report-card-badge]][go-report-card] +[![License][badge-license]][license] `gohighlight` is a syntax highlighter of programming languages, config formats and UNIX commands. It allows you to pass in a string and get back all the information you need to properly highlight it.. @@ -153,7 +155,7 @@ func helloWorld() { } ``` -If you would like to automatically detect the filetype based on the filename, you can use the `DetectFiletype()` function: +If you would like to automatically detect the file type based on the filename, you can use the `DetectFiletype()` function: ```go // Name of the file @@ -180,3 +182,12 @@ They can be loaded individually: ``` Or, you can scan the dir and load them all using the `highlight.ParseSyntaxFiles(syn_dir, &defs)()` helper function. + +[license]: ./LICENSE +[badge-license]: https://img.shields.io/github/license/jessp01/gohighlight.svg +[go-docs-badge]: https://godoc.org/github.com/jessp01/gohighlight?status.svg +[go-docs]: https://godoc.org/github.com/jessp01/gohighlight +[go-report-card-badge]: https://goreportcard.com/badge/github.com/jessp01/gohighlight +[go-report-card]: https://goreportcard.com/report/github.com/jessp01/gohighlight +[badge-build]: https://github.com/jessp01/gohighlight/actions/workflows/go.yml/badge.svg +[build]: https://github.com/jessp01/gohighlight/actions/workflows/go.yml