From 8cae5b9e5535a4f05fc31eec2cf4e9ab664e3264 Mon Sep 17 00:00:00 2001 From: Manuel Doncel Martos Date: Mon, 18 Nov 2024 19:52:15 +0100 Subject: [PATCH] Update code (#40) * - Removing deprecated calls - Fixing some typos * - Removing deprecated calls - Fixing some typos - Adding test go matrix in github action --------- Co-authored-by: John Roesler --- .github/workflows/go_test.yml | 10 ++++++---- CONTRIBUTING.md | 2 +- README.md | 1 + SECURITY.md | 2 +- gorm_lock_test.go | 11 +++++++---- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/go_test.yml b/.github/workflows/go_test.yml index f089c15..c84fc6f 100644 --- a/.github/workflows/go_test.yml +++ b/.github/workflows/go_test.yml @@ -13,18 +13,20 @@ jobs: matrix: go-version: - "1.20" + - "1.21" + - "1.22" name: lint and test runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - - name: golangci-lint - uses: golangci/golangci-lint-action@v6.1.1 - with: - version: v1.51.2 - name: Install Go uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} + - name: golangci-lint + uses: golangci/golangci-lint-action@v6.1.1 + with: + version: v1.59.1 - name: test run: make test diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b2d3be8..7fe3ced 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,7 +8,7 @@ If you find a bug then please let the project know by opening an issue after doi - Do a quick search of the existing issues to make sure the bug isn't already reported - Try and make a minimal list of steps that can reliably reproduce the bug you are experiencing -- Collect as much information as you can to help identify what the issue is (project version, configuration files, etc) +- Collect as much information as you can to help identify what the issue is (project version, configuration files, etc.) ## Suggesting Enhancements diff --git a/README.md b/README.md index b8de789..e086763 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![golangci-lint](https://github.com/go-co-op/gocron-gorm-lock/actions/workflows/go_test.yml/badge.svg)](https://github.com/go-co-op/gocron-gorm-lock/actions/workflows/go_test.yml) # gocron-gorm-lock A gocron locker implementation using gorm diff --git a/SECURITY.md b/SECURITY.md index 74df551..e81cbfa 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -5,7 +5,7 @@ The current plan is to maintain version 1 as long as possible incorporating any necessary security patches. | Version | Supported | -| ------- | ------------------ | +|---------|--------------------| | 1.x.x | :white_check_mark: | ## Reporting a Vulnerability diff --git a/gorm_lock_test.go b/gorm_lock_test.go index a3a366f..0673b75 100644 --- a/gorm_lock_test.go +++ b/gorm_lock_test.go @@ -16,6 +16,7 @@ import ( ) func TestNewGormLocker_Validation(t *testing.T) { + t.Parallel() tests := map[string]struct { db *gorm.DB worker string @@ -26,7 +27,9 @@ func TestNewGormLocker_Validation(t *testing.T) { } for name, tc := range tests { + name, tc := name, tc t.Run(name, func(t *testing.T) { + t.Parallel() _, err := NewGormLocker(tc.db, tc.worker) if assert.Error(t, err) { assert.ErrorContains(t, err, tc.err) @@ -37,7 +40,7 @@ func TestNewGormLocker_Validation(t *testing.T) { func TestEnableDistributedLocking(t *testing.T) { ctx := context.Background() - postgresContainer, err := testcontainerspostgres.RunContainer(ctx, + postgresContainer, err := testcontainerspostgres.Run(ctx, "docker.io/postgres:16-alpine", testcontainers.WithWaitStrategy(wait.ForLog("database system is ready to accept connections"). WithOccurrence(2).WithStartupTimeout(5*time.Second))) require.NoError(t, err) @@ -97,7 +100,7 @@ func TestEnableDistributedLocking(t *testing.T) { func TestEnableDistributedLocking_DifferentJob(t *testing.T) { ctx := context.Background() - postgresContainer, err := testcontainerspostgres.RunContainer(ctx, + postgresContainer, err := testcontainerspostgres.Run(ctx, "docker.io/postgres:16-alpine", testcontainers.WithWaitStrategy(wait.ForLog("database system is ready to accept connections"). WithOccurrence(2).WithStartupTimeout(5*time.Second))) require.NoError(t, err) @@ -182,7 +185,7 @@ func TestEnableDistributedLocking_DifferentJob(t *testing.T) { func TestJobReturningExceptionWhenUnique(t *testing.T) { ctx := context.Background() - postgresContainer, err := testcontainerspostgres.RunContainer(ctx, + postgresContainer, err := testcontainerspostgres.Run(ctx, "docker.io/postgres:16-alpine", testcontainers.WithWaitStrategy(wait.ForLog("database system is ready to accept connections"). WithOccurrence(2).WithStartupTimeout(5*time.Second))) require.NoError(t, err) @@ -220,7 +223,7 @@ func TestJobReturningExceptionWhenUnique(t *testing.T) { func TestHandleTTL(t *testing.T) { ctx := context.Background() - postgresContainer, err := testcontainerspostgres.RunContainer(ctx, + postgresContainer, err := testcontainerspostgres.Run(ctx, "docker.io/postgres:16-alpine", testcontainers.WithWaitStrategy(wait.ForLog("database system is ready to accept connections"). WithOccurrence(2).WithStartupTimeout(5*time.Second))) require.NoError(t, err)