From 413798afdd7988763687930eb0a49bce1bdc40a4 Mon Sep 17 00:00:00 2001 From: Nicholas Wiersma Date: Mon, 26 Jul 2021 16:01:37 +0200 Subject: [PATCH] chore: switch ci and update linter (#4) --- .github/dependabot.yml | 7 ++++++ .github/workflows/test.yml | 49 ++++++++++++++++++++++++++++++++++++++ .golangci.yml | 38 +++++++++++++++++++++++++++++ .travis.yml | 29 ---------------------- LICENCE | 2 +- README.md | 4 ++-- doc.go | 2 ++ internal/gen/gen.go | 4 ++-- intersect.go | 2 +- 9 files changed, 102 insertions(+), 35 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/test.yml create mode 100644 .golangci.yml delete mode 100644 .travis.yml create mode 100644 doc.go diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d921d0f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: +- package-ecosystem: gomod + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ae4f1b8 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,49 @@ +on: + push: + branches: + - master + pull_request: + +name: run tests +jobs: + test: + + strategy: + matrix: + go-version: [ 1.15, 1.16 ] + runs-on: ubuntu-latest + env: + GOLANGCI_LINT_VERSION: v1.41.1 + + steps: + - name: Install Go + if: success() + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Cache Go modules + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Run linter + uses: golangci/golangci-lint-action@v2 + with: + version: ${{ env.GOLANGCI_LINT_VERSION }} + + - name: Run tests + run: go test -covermode=count -coverprofile=coverage.out ./... + + - name: Convert coverage.out to coverage.lcov + uses: jandelgado/gcov2lcov-action@v1.0.6 + - name: Coveralls + uses: coverallsapp/github-action@v1.1.2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: coverage.lcov diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..e6a579d --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,38 @@ +run: + tests: false + timeout: 5m + +linters-settings: + cyclop: + max-complexity: 20 + skip-tests: true + gofumpt: + extra-rules: true + +linters: + enable-all: true + disable: + - interfacer # deprecated + - scopelint # deprecated + - maligned # deprecated + - golint # deprecated + - dupl + - exhaustive + - exhaustivestruct + - forcetypeassert + - funlen + - gochecknoglobals + - gochecknoinits + - goerr113 + - gomnd + - lll + - nlreturn + - wrapcheck + - wsl + +issues: + exclude-use-default: false + exclude-rules: + - path: ptr.go + linters: + - gosec diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 43a01e2..0000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: go -go: - - "1.13.x" - - "1.14.x" - - "1.x" - -env: - - GO111MODULE=on GOFLAGS=-mod=readonly GOPROXY=https://proxy.golang.org - -cache: - directories: - - $GOPATH/pkg/mod - -before_install: - - go generate ./... && git diff --exit-code; code=$?; (exit $code) - - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $GOPATH/bin - - go mod download - - go get github.com/mattn/goveralls - -script: - - golangci-lint run ./... - - go vet ./... - - go test -covermode=count -coverprofile=profile.cov ./... - - goveralls -coverprofile=profile.cov -service=travis-ci - -notifications: - email: - on_success: never - on_failure: always \ No newline at end of file diff --git a/LICENCE b/LICENCE index 597a1a4..077af63 100644 --- a/LICENCE +++ b/LICENCE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Nicholas Wiersma +Copyright (c) 2021 Nicholas Wiersma Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index fe7ea7c..ee4f8d4 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ ![Logo](http://svg.wiersma.co.za/hamba/project?title=slices&tag=Slice%20helper%20functions) [![Go Report Card](https://goreportcard.com/badge/github.com/hamba/slices)](https://goreportcard.com/report/github.com/hamba/slices) -[![Build Status](https://travis-ci.com/hamba/slices.svg?branch=master)](https://travis-ci.com/hamba/slices) +[![Build Status](https://github.com/hamba/cmd/actions/workflows/test.yml/badge.svg)](https://github.com/hamba/cmd/actions) [![Coverage Status](https://coveralls.io/repos/github/hamba/slices/badge.svg?branch=master)](https://coveralls.io/github/hamba/slices?branch=master) -[![GoDoc](https://godoc.org/github.com/hamba/slices?status.svg)](https://godoc.org/github.com/hamba/slices) +[![Go Reference](https://pkg.go.dev/badge/github.com/hamba/slices.svg)](https://pkg.go.dev/github.com/hamba/slices) [![GitHub release](https://img.shields.io/github/release/hamba/slices.svg)](https://github.com/hamba/slices/releases) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/hamba/slices/master/LICENSE) diff --git a/doc.go b/doc.go new file mode 100644 index 0000000..c4f0181 --- /dev/null +++ b/doc.go @@ -0,0 +1,2 @@ +// Package slices implements fast slice operations. +package slices diff --git a/internal/gen/gen.go b/internal/gen/gen.go index 7172ebf..f78f974 100644 --- a/internal/gen/gen.go +++ b/internal/gen/gen.go @@ -3,8 +3,8 @@ package main import ( "bytes" "go/format" - "io/ioutil" "log" + "os" "text/template" ) @@ -113,7 +113,7 @@ func main() { log.Fatal(err) } - if err = ioutil.WriteFile("ops.gen.go", source, 0666); err != nil { + if err = os.WriteFile("ops.gen.go", source, 0600); err != nil { log.Fatal(err) } } diff --git a/intersect.go b/intersect.go index 29cf5fc..6fb3c5d 100644 --- a/intersect.go +++ b/intersect.go @@ -6,7 +6,7 @@ import ( type intersectFn func(sptr, optr unsafe.Pointer) interface{} -// Intersection returns a slice with the intersection of slice and other. +// Intersect returns a slice with the intersection of slice and other. // When the slices are the same, slice is returned. func Intersect(slice, other interface{}) interface{} { fn, ok := intersectOf(slice, other)