From 376809baef1a7d8da7b1b70f2c7d9e7edb649b6c Mon Sep 17 00:00:00 2001 From: Olivier Sechet Date: Tue, 6 Aug 2024 09:37:16 +0200 Subject: [PATCH] ci: configure github actions --- .github/workflows/go.yml | 38 ++++++++++++++++++++++++++++++++++++++ .golangci.yml | 19 +++++++++++++++++++ .travis.yml | 15 --------------- LICENSE | 2 +- README.md | 8 +++----- 5 files changed, 61 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/go.yml create mode 100644 .golangci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..2af2927 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,38 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Go + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.59 + + - name: Test + run: go test -v -race -coverprofile=coverage.out -covermode=atomic + + - name: Code Coverage + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..49c68da --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,19 @@ +run: + go: "1.20" +linters: + enable: + - stylecheck +linters-settings: + stylecheck: + # STxxxx checks in https://staticcheck.io/docs/configuration/options/#checks + # checks: ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022"] + checks: ["all", "-ST1000", "-ST1016"] + # https://staticcheck.io/docs/configuration/options/#dot_import_whitelist + # Default: ["github.com/mmcloughlin/avo/build", "github.com/mmcloughlin/avo/operand", "github.com/mmcloughlin/avo/reg"] + dot-import-whitelist: [] + # https://staticcheck.io/docs/configuration/options/#initialisms + # Default: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"] + initialisms: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"] + # https://staticcheck.io/docs/configuration/options/#http_status_code_whitelist + # Default: ["200", "400", "404", "500"] + http-status-code-whitelist: [] diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 667a919..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: go - -go: -- 1.11.x -- 1.12.x -- 1.14.x -- 1.15.x - -script: - - go fmt $(go list ./... | grep -v /vendor/) - - go vet $(go list ./... | grep -v /vendor/) - - go test -v -race -coverprofile=coverage.txt -covermode=atomic $(go list ./... | grep -v /vendor/) - -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/LICENSE b/LICENSE index f3e6767..c32979e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License -Copyright (c) 2017 Olivier Sechet. +Copyright (c) 2024 Olivier Sechet. 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 c74d160..aa7afce 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ # timex - A Go time extension library -[![Build Status](https://www.travis-ci.org/osechet/timex.svg?branch=master)](https://www.travis-ci.org/osechet/timex) +[![Build Status](https://github.com/osechet/timex/actions/workflows/go.yml/badge.svg)](https://github.com/osechet/timex/actions) [![codecov](https://codecov.io/gh/osechet/timex/branch/master/graph/badge.svg)](https://codecov.io/gh/osechet/timex) - ## Install -``` +```sh go get github.com/osechet/timex ``` @@ -16,10 +15,9 @@ The purpose of the library is to provide several extensions to the standard Go t ## Example - ### GPS -``` +```go // Display the GPS time of the current time, in microseconds fmt.Println(int64(timex.GpsTime(time.Now()).Gps() / time.Microsecond)) ```