Skip to content

Commit

Permalink
Use nhatthm/gh-actions (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatthm authored Jan 21, 2024
1 parent fe06260 commit 9823789
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 143 deletions.
44 changes: 10 additions & 34 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,51 +1,27 @@
---
name: lint

on:
push:
branches:
- master
pull_request:

env:
GO_VERSION: "1.19.x"

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout code
uses: nhatthm/gh-actions/checkout@master

- id: vars
run: |
make $GITHUB_OUTPUT
- name: Setup
uses: nhatthm/gh-actions/find-go-version@master

- name: lint
uses: golangci/golangci-lint-action@v3
- name: Install Go
uses: nhatthm/gh-actions/setup-go@master
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: ${{ steps.vars.outputs.GOLANGCI_LINT_VERSION }}

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0
args: --timeout=5m

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the action will use pre-installed Go.
# skip-go-installation: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true
go-version: ${{ env.GO_LATEST_VERSION }}

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
- name: Lint
uses: nhatthm/gh-actions/golangci-lint@master
50 changes: 29 additions & 21 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,53 @@ on:

env:
GO111MODULE: "on"
GO_LATEST_VERSION: "1.19.x"

jobs:
setup:
runs-on: ubuntu-latest
outputs:
go-latest-version: ${{ steps.find-go-version.outputs.go-latest-version }}
go-supported-versions: ${{ steps.find-go-version.outputs.go-supported-versions }}
steps:
- name: Checkout code
uses: nhatthm/gh-actions/checkout@master

- id: find-go-version
name: Find Go version
uses: nhatthm/gh-actions/find-go-version@master

test:
strategy:
fail-fast: false
matrix:
go-version: [ 1.18.x, 1.19.x, 1.20.x ]
go-version: ${{ fromJson(needs.setup.outputs.go-supported-versions) }}
runs-on: ubuntu-latest
needs: [setup]
env:
GO_LATEST_VERSION: ${{ needs.setup.outputs.go-latest-version }}
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v4
uses: nhatthm/gh-actions/checkout@master

- name: Go cache
uses: actions/cache@v4
- name: Install Go
uses: nhatthm/gh-actions/setup-go@master
with:
# In order:
# * Module download cache
# * Build cache (Linux)
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ matrix.go-version }}-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-cache
go-version: ${{ matrix.go-version }}

- name: Test
id: test
run: |
make test
- name: Upload code coverage (unit)
if: matrix.go-version == env.GO_LATEST_VERSION
uses: codecov/codecov-action@v3
uses: nhatthm/gh-actions/codecov@master
with:
files: ./unit.coverprofile
flags: unittests-${{ runner.os }}

#- name: Upload code coverage (features)
# if: matrix.go-version == env.GO_LATEST_VERSION
# uses: nhatthm/gh-actions/codecov@master
# with:
# file: ./features.coverprofile
# flags: featurestests-${{ runner.os }}
18 changes: 4 additions & 14 deletions .github/workflows/update-registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,11 @@ on:
jobs:
notify:
runs-on: ubuntu-latest
strategy:
matrix:
registry: [ go.nhat.io, go-staging.nhat.io ]
steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: nhatthm/gh-actions/checkout@master

- id: vars
run: |
make $GITHUB_OUTPUT
- name: notify ${{ matrix.registry }}
uses: benc-uk/workflow-dispatch@v121
- name: Notify registries
uses: nhatthm/gh-actions/notify-go-registries@master
with:
workflow: build
repo: nhatthm/${{ matrix.registry }}
token: ${{ secrets.REGISTRY_TOKEN }}
inputs: '{"modules": "${{ steps.vars.outputs.MODULE_NAME }}"}'
ref: 'master'
7 changes: 6 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# See https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
run:
tests: true
timeout: 10m

linters-settings:
errcheck:
Expand All @@ -21,6 +22,7 @@ linters:
enable-all: true
disable:
- deadcode
- depguard
- exhaustivestruct
- exhaustruct
- forbidigo
Expand All @@ -36,18 +38,21 @@ linters:
- ireturn
- lll
- maligned
- nolintlint # https://github.com/golangci/golangci-lint/issues/3063
- nonamedreturns
- nosnakecase
- nolintlint # https://github.com/golangci/golangci-lint/issues/3063
- paralleltest
- scopelint
- structcheck
- tagliatelle
- testifylint
- testpackage
- varcheck
- varnamelen
- wrapcheck

issues:
max-same-issues: 20
exclude-use-default: false
exclude-rules:
- linters:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ MODULE_NAME=testcontainers-extra

VENDOR_DIR = vendor

GOLANGCI_LINT_VERSION ?= v1.52.2
GOLANGCI_LINT_VERSION ?= v1.55.2

GO ?= go
GOLANGCI_LINT ?= $(shell go env GOPATH)/bin/golangci-lint-$(GOLANGCI_LINT_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Boost `testcontainers/testcontainers-go` with some jet fuel! 🚀

## Prerequisites

- `Go >= 1.17`
- `Go >= 1.20`

## Install

Expand Down
56 changes: 31 additions & 25 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,58 +1,64 @@
module go.nhat.io/testcontainers-extra

go 1.19
go 1.20

require (
github.com/docker/distribution v2.8.2+incompatible
github.com/docker/docker v24.0.7+incompatible
github.com/distribution/reference v0.5.0
github.com/docker/docker v25.0.0+incompatible
github.com/docker/go-connections v0.5.0
github.com/stretchr/testify v1.8.4
github.com/testcontainers/testcontainers-go v0.26.0
github.com/testcontainers/testcontainers-go v0.27.0
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/hcsshim v0.11.1 // indirect
github.com/Microsoft/hcsshim v0.11.4 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/containerd/containerd v1.7.7 // indirect
github.com/containerd/containerd v1.7.12 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/lufia/plan9stats v0.0.0-20231016141302-07b5767bb0ed // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/user v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
github.com/opencontainers/runc v1.1.7 // indirect
github.com/opencontainers/image-spec v1.1.0-rc6 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/shirou/gopsutil/v3 v3.23.9 // indirect
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/stretchr/objx v0.5.1 // indirect
github.com/tklauser/go-sysconf v0.3.13 // indirect
github.com/tklauser/numcpus v0.7.0 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.9.1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
google.golang.org/grpc v1.57.1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0 // indirect
go.opentelemetry.io/otel v1.22.0 // indirect
go.opentelemetry.io/otel/metric v1.22.0 // indirect
go.opentelemetry.io/otel/trace v1.22.0 // indirect
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/tools v0.17.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect
google.golang.org/grpc v1.60.1 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 9823789

Please sign in to comment.