From 9fbfc18911c9747a7b97c0e109f06786809a1077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matou=C5=A1=20Dzivjak?= Date: Thu, 16 May 2024 15:44:32 +0200 Subject: [PATCH] feat: more ci updates --- .github/workflows/ci.yml | 58 ++++++++++++++++++++++++++++++++++++++ .github/workflows/lint.yml | 12 -------- .github/workflows/test.yml | 28 ------------------ Makefile | 21 ++++++++------ README.md | 1 - 5 files changed, 71 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..cb6df03 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,58 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +env: + GOLANGCI_LINT_VERSION: v1.58 + +jobs: + test: + name: Test + runs-on: ubuntu-latest + strategy: + matrix: + version: ["1.20", "1.21", "1.22"] + steps: + - uses: actions/checkout@v4.1.5 + - uses: actions/setup-go@v5.0.1 + with: + go-version: ${{ matrix.version }} + - name: Test + run: make test + + benchmark: + name: Benchmark + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.5 + - uses: actions/setup-go@v5.0.1 + - uses: actions/setup-go@v2 + with: + go-version-file: './go.mod' + - name: Benchmark + run: make bench + + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.5 + - name: golangci-lint + uses: golangci/golangci-lint-action@v6.0.1 + with: + version: ${{ env.GOLANGCI_LINT_VERSION }} + - name: tidy + run: | + make download + git diff-index HEAD + git diff --minimal --color=always --compact-summary --exit-code HEAD || FAILED=true ; + if [[ $FAILED ]]; + then echo "❗️please run \"go mod tidy\" locally and commit the changes" + exit 1 + fi diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 50d7253..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Lint -on: [push] -jobs: - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: golangci-lint - uses: golangci/golangci-lint-action@v2 - with: - version: v1.39 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 456045c..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Tests -on: [push] -jobs: - test: - name: Test - runs-on: ubuntu-latest - strategy: - matrix: - version: ["1.20", "1.21", "1.22"] - steps: - - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.version }} - - uses: actions/checkout@v2 - - name: Test - run: make test - - benchmark: - name: Benchmark - runs-on: ubuntu-latest - steps: - - uses: actions/setup-go@v2 - with: - go-version: 1.15.2 - id: go - - uses: actions/checkout@v2 - - name: Benchmark - run: make bench diff --git a/Makefile b/Makefile index 234c654..946c643 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,21 @@ +# Make this makefile self-documented with target `help` .PHONY: help - -help: ## Show help/documentation for the Makefile +.DEFAULT_GOAL := help +help: ## Show help @grep -Eh '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' -configure: ## Download dependencies - go mod download - -lint: configure ## Lint the repository with golang-ci lint +.PHONY: lint +lint: download ## Lint the repository with golang-ci lint golangci-lint run --max-same-issues 0 --max-issues-per-linter 0 $(if $(CI),--out-format code-climate > gl-code-quality-report.json 2>golangci-stderr-output) -test: configure ## Run all tests +.PHONY: test +test: download ## Run all tests go test -v -bench: configure ## Run all benchmarks +.PHONY: bench +bench: download ## Run all benchmarks go test -bench=. + +.PHONY: download +download: ## Download dependencies + go mod download diff --git a/README.md b/README.md index 6cb8367..98d728a 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ [![GitHub issues](https://img.shields.io/github/issues/matoous/go-nanoid.svg)](https://github.com/matoous/go-nanoid/issues) [![License](https://img.shields.io/badge/license-MIT%20License-blue.svg)](https://github.com/matoous/go-nanoid/LICENSE) - This package is Go implementation of [ai's](https://github.com/ai) [nanoid](https://github.com/ai/nanoid)! **Safe.** It uses cryptographically strong random generator.