diff --git a/.github/workflows/go-cross.yml b/.github/workflows/go-cross.yml new file mode 100644 index 0000000..cd7a79b --- /dev/null +++ b/.github/workflows/go-cross.yml @@ -0,0 +1,45 @@ +name: Go Matrix +on: [push, pull_request] + +jobs: + + cross: + name: Go + runs-on: ${{ matrix.os }} + env: + CGO_ENABLED: 0 + + strategy: + matrix: + go-version: [ 1.14, 1.15, 1.x ] + os: [ubuntu-latest, macos-latest, windows-latest] + + steps: + # https://github.com/marketplace/actions/setup-go-environment + - name: Set up Go ${{ matrix.go-version }} + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + # https://github.com/marketplace/actions/checkout + - name: Checkout code + uses: actions/checkout@v2 + + # https://github.com/marketplace/actions/cache + - name: Cache Go modules + uses: actions/cache@v2 + with: + path: | + ~/go/pkg/mod # Module download cache + ~/.cache/go-build # Build cache (Linux) + ~/Library/Caches/go-build # Build cache (Mac) + '%LocalAppData%\go-build' # Build cache (Windows) + key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.go-version }}-go- + + - name: Test + run: go test -v -cover ./... + + - name: Build + run: go build -v -ldflags "-s -w" -trimpath diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..2e13130 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,88 @@ +name: Main + +on: + push: + branches: + - master + tags: + - v* + pull_request: + +jobs: + + main: + name: Main Process + runs-on: ubuntu-latest + env: + GO_VERSION: 1.15 + GOLANGCI_LINT_VERSION: v1.33.0 + SEIHON_VERSION: v0.5.1 + CGO_ENABLED: 0 + + steps: + + # https://github.com/marketplace/actions/setup-go-environment + - name: Set up Go ${{ env.GO_VERSION }} + uses: actions/setup-go@v2 + with: + go-version: ${{ env.GO_VERSION }} + + # https://github.com/marketplace/actions/checkout + - name: Check out code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + # https://github.com/marketplace/actions/cache + - 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: Check and get dependencies + run: | + go mod tidy + git diff --exit-code go.mod + git diff --exit-code go.sum + go mod download + + # https://golangci-lint.run/usage/install#other-ci + - name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }} + run: | + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION} + golangci-lint --version + + - name: Make + run: make + + # Install Docker image multi-arch builder + - name: Install seihon ${{ env.SEIHON_VERSION }} + if: startsWith(github.ref, 'refs/tags/v') + run: | + curl -sSfL https://raw.githubusercontent.com/ldez/seihon/master/godownloader.sh | sh -s -- -b $(go env GOPATH)/bin "${GOPATH}/bin" ${SEIHON_VERSION} + seihon --version + + - name: Docker Login + if: startsWith(github.ref, 'refs/tags/v') + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: | + echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin + + - name: Deploy Docker Images (seihon) + if: startsWith(github.ref, 'refs/tags/v') + run: make publish-images + + # https://goreleaser.com/ci/actions/ + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + if: startsWith(github.ref, 'refs/tags/v') + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN_REPO }} diff --git a/.golangci.toml b/.golangci.toml index f222b89..c045d56 100644 --- a/.golangci.toml +++ b/.golangci.toml @@ -30,11 +30,15 @@ "prealloc", "scopelint", "wsl", + "nlreturn", "gomnd", "testpackage", + "paralleltest", + "tparallel", "goerr113", - "nlreturn", + "wrapcheck", "exhaustive", + "exhaustivestruct", ] [issues] diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e332c3e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,64 +0,0 @@ -language: go - -dist: xenial - -notifications: - email: - on_success: never - on_failure: change - -cache: - directories: - - $GOPATH/pkg/mod - -jobs: - fast_finish: true - include: - - go: 1.15.x - env: STABLE=true - - go: 1.x - - go: tip - allow_failures: - - go: tip - -env: - global: - - GO111MODULE=on - -services: - - docker - -before_install: - # Install linters and misspell - - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin ${GOLANGCI_LINT_VERSION} - - golangci-lint --version - # Install Docker image multi-arch builder - - curl -sfL https://raw.githubusercontent.com/ldez/seihon/master/godownloader.sh | bash -s -- -b "${GOPATH}/bin" ${SEIHON_VERSION} - - seihon --version - -install: - - go mod tidy - - git diff --exit-code go.mod - - git diff --exit-code go.sum - - go mod download - -before_deploy: - - > - if ! [ "$BEFORE_DEPLOY_RUN" ]; then - export BEFORE_DEPLOY_RUN=1; - echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin - fi - -deploy: - - provider: script - skip_cleanup: true - script: curl -sL https://git.io/goreleaser | bash - on: - tags: true - condition: $STABLE = true - - provider: script - skip_cleanup: true - script: make publish-images - on: - tags: true - condition: $STABLE = true diff --git a/hook/hook.go b/hook/hook.go index e09ba40..6634d84 100644 --- a/hook/hook.go +++ b/hook/hook.go @@ -34,7 +34,7 @@ func execute(command string) error { fmt.Println(string(output)) } - if ctxCmd.Err() == context.DeadlineExceeded { + if errors.Is(ctxCmd.Err(), context.DeadlineExceeded) { return errors.New("hook timed out") } diff --git a/readme.md b/readme.md index 4303d07..c01a44f 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,7 @@ # traefik-certs-dumper [![GitHub release](https://img.shields.io/github/release/ldez/traefik-certs-dumper.svg)](https://github.com/ldez/traefik-certs-dumper/releases/latest) -[![Build Status](https://travis-ci.com/ldez/traefik-certs-dumper.svg?branch=master)](https://travis-ci.com/ldez/traefik-certs-dumper) +[![Build Status](https://github.com/ldez/traefik-certs-dumper/workflows/Main/badge.svg?branch=master)](https://github.com/ldez/traefik-certs-dumper/actions) [![Docker Information](https://images.microbadger.com/badges/image/ldez/traefik-certs-dumper.svg)](https://hub.docker.com/r/ldez/traefik-certs-dumper/) [![Go Report Card](https://goreportcard.com/badge/github.com/ldez/traefik-certs-dumper)](https://goreportcard.com/report/github.com/ldez/traefik-certs-dumper)