From 242da4500d25060f58a09dbc58e64c7525661c58 Mon Sep 17 00:00:00 2001 From: Dmitrij Koniajev Date: Wed, 21 Oct 2026 19:25:56 +0300 Subject: [PATCH] Replace dead Travis CI with GitHub Actions Test on Go 1.19 (go.mod minimum), oldstable and stable with -race and -shuffle; lint with golangci-lint v2.15.0; upload coverage to Coveralls. Actions are pinned by SHA and kept fresh by Dependabot. A monthly run catches breakage when a new Go release becomes stable. Fixes #10 --- .github/dependabot.yml | 9 +++++++ .github/workflows/ci.yml | 54 ++++++++++++++++++++++++++++++++++++++++ .golangci.yml | 17 +++++++++++++ .travis.yml | 28 --------------------- Makefile | 6 ++--- README.md | 2 +- 6 files changed, 84 insertions(+), 32 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .golangci.yml delete mode 100644 .travis.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..fecd44d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + groups: + actions: + patterns: ["*"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..58af29f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + workflow_dispatch: + schedule: + - cron: "0 6 1 * *" # monthly: catch breakage when a new Go release becomes "stable" + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + test: + name: Test (Go ${{ matrix.go }}) + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + # 1.19 is the minimum from go.mod; oldstable/stable are the two supported Go releases. + go: ["1.19", "oldstable", "stable"] + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 + with: + go-version: ${{ matrix.go }} + cache: false # no dependencies to cache + - run: go vet ./... + - run: go test -race -shuffle=on -count=1 -covermode=atomic -coverprofile=coverage.out ./... + - if: matrix.go == 'stable' + uses: coverallsapp/github-action@8d6379e14d29928660c4ba802d8e85393440b329 # v2.3.8 + with: + file: coverage.out + format: golang + fail-on-error: false + + lint: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 + with: + go-version: stable + cache: false + - uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 + with: + version: v2.15.0 # not updated by Dependabot; bump manually diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..c17c813 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,17 @@ +version: "2" +linters: + exclusions: + rules: + - path: '_test\.go' + text: 'QF1010' +formatters: + enable: + - gofumpt + - goimports + settings: + gofumpt: + extra: + group-params: true + goimports: + local-prefixes: + - github.com/dimchansky/utfbom diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 703ed06..0000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: go -sudo: false -arch: - - AMD64 - - ppc64le -go: - - 1.19.x - - 1.20.x - - 1.21.x - -cache: - directories: - - $HOME/.cache/go-build - - $HOME/gopath/pkg/mod - -env: - global: - - GO111MODULE=on - -before_install: - - go get github.com/mattn/goveralls - - go get golang.org/x/tools/cmd/cover - - go get golang.org/x/tools/cmd/goimports - - go get golang.org/x/lint/golint -script: - - gofiles=$(find ./ -name '*.go') && [ -z "$gofiles" ] || unformatted=$(goimports -l $gofiles) && [ -z "$unformatted" ] || (echo >&2 "Go files must be formatted with gofmt. Following files has problem:\n $unformatted" && false) - - golint ./... # This won't break the build, just show warnings - - $HOME/gopath/bin/goveralls -service=travis-ci diff --git a/Makefile b/Makefile index ca8a8b6..9107847 100644 --- a/Makefile +++ b/Makefile @@ -9,15 +9,15 @@ test_race: test_cover: @go test -cover -covermode=atomic . +# tested with golangci-lint v2.15.0 (same version as CI) fmt: - @goimports -w -local github.com/dimchansky/utfbom . - @gofumpt -w -extra . + @golangci-lint fmt vet: @go vet . lint: - @golint ./... + @golangci-lint run fix: @go fix . diff --git a/README.md b/README.md index 9636767..76c1dee 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# utfbom [![Godoc](https://godoc.org/github.com/dimchansky/utfbom?status.png)](https://godoc.org/github.com/dimchansky/utfbom) [![License](https://img.shields.io/:license-apache-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Build Status](https://travis-ci.org/dimchansky/utfbom.svg?branch=master)](https://travis-ci.org/dimchansky/utfbom) [![Go Report Card](https://goreportcard.com/badge/github.com/dimchansky/utfbom)](https://goreportcard.com/report/github.com/dimchansky/utfbom) [![Coverage Status](https://coveralls.io/repos/github/dimchansky/utfbom/badge.svg?branch=master)](https://coveralls.io/github/dimchansky/utfbom?branch=master) +# utfbom [![Godoc](https://godoc.org/github.com/dimchansky/utfbom?status.png)](https://godoc.org/github.com/dimchansky/utfbom) [![License](https://img.shields.io/:license-apache-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![CI](https://github.com/dimchansky/utfbom/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/dimchansky/utfbom/actions/workflows/ci.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/dimchansky/utfbom)](https://goreportcard.com/report/github.com/dimchansky/utfbom) [![Coverage Status](https://coveralls.io/repos/github/dimchansky/utfbom/badge.svg?branch=master)](https://coveralls.io/github/dimchansky/utfbom?branch=master) The package utfbom implements the detection of the BOM (Unicode Byte Order Mark) and removing as necessary. It can also return the encoding detected by the BOM.