Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// README at: https://github.com/devcontainers/templates/tree/main/src/go
{
"name": "Go",
"image": "mcr.microsoft.com/devcontainers/go:1.24-trixie",
"image": "mcr.microsoft.com/devcontainers/go:1.25-trixie",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
Expand Down
27 changes: 1 addition & 26 deletions .github/workflows/ci-lint-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,10 @@ jobs:
cache-dependency-path: "${{ inputs.project-directory == '' && '.' || inputs.project-directory }}/go.sum"
id: go

- name: Determine golangci-lint version
id: linter-version
working-directory: ./${{ inputs.project-directory == '' && '.' || inputs.project-directory }}
shell: bash
run: |
# golangci-lint must be built with a Go version >= the module's go directive.
MODULE_GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
MODULE_MAJOR_MINOR=$(echo "${MODULE_GO_VERSION}" | grep -oE '^[0-9]+\.[0-9]+')

case "${MODULE_MAJOR_MINOR}" in
1.24)
LINTER_VERSION=v2.0.2
;;
1.25)
LINTER_VERSION=v2.9.0
;;
*)
echo "::error::No golangci-lint version mapped for Go ${MODULE_GO_VERSION}. Please update ci-lint-go.yml."
exit 1
;;
esac

echo "version=${LINTER_VERSION}" >> "$GITHUB_OUTPUT"
echo "Module requires Go ${MODULE_GO_VERSION}, using golangci-lint ${LINTER_VERSION}"

- name: golangci-lint
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
with:
version: ${{ steps.linter-version.outputs.version }}
version: v2.9.0
# Optional: working directory, useful for monorepos
working-directory: ${{ inputs.project-directory }}

Expand Down
39 changes: 7 additions & 32 deletions .github/workflows/ci-test-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,11 @@ jobs:
cache-dependency-path: '${{ inputs.project-directory }}/go.sum'
id: go

- name: Check Go version compatibility
id: go-compat
working-directory: ./${{ inputs.project-directory == '' && '.' || inputs.project-directory }}
shell: bash
run: |
# Read the minimum Go version required by the module
MODULE_GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
RUNNER_GO_VERSION=$(go env GOVERSION | sed 's/^go//')
echo "Module requires Go ${MODULE_GO_VERSION}, runner has Go ${RUNNER_GO_VERSION}"

# Extract major.minor for comparison
MODULE_MAJOR_MINOR=$(echo "${MODULE_GO_VERSION}" | grep -oE '^[0-9]+\.[0-9]+')
RUNNER_MAJOR_MINOR=$(echo "${RUNNER_GO_VERSION}" | grep -oE '^[0-9]+\.[0-9]+')

if [ "$(printf '%s\n' "${MODULE_MAJOR_MINOR}" "${RUNNER_MAJOR_MINOR}" | sort -V | head -n1)" = "${MODULE_MAJOR_MINOR}" ]; then
echo "compatible=true" >> $GITHUB_OUTPUT
else
echo "compatible=false" >> $GITHUB_OUTPUT
echo "::warning::Skipping tests: module requires Go ${MODULE_GO_VERSION} but runner has Go ${RUNNER_GO_VERSION}"
fi

- name: ensure compilation
if: steps.go-compat.outputs.compatible == 'true'
working-directory: ./${{ inputs.project-directory }}
run: go build ./...

- name: Install dependencies
if: steps.go-compat.outputs.compatible == 'true'
shell: bash
run: |
SCRIPT_PATH="./.github/scripts/${{ inputs.project-directory }}/install-dependencies.sh"
Expand All @@ -111,25 +88,23 @@ jobs:

# Setup Testcontainers Cloud Client right before your Testcontainers tests
- name: Setup Testcontainers Cloud Client
if: ${{ steps.go-compat.outputs.compatible == 'true' && inputs.testcontainers-cloud }}
if: ${{ inputs.testcontainers-cloud }}
uses: atomicjar/testcontainers-cloud-setup-action@c335bdbb570ec7c48f72c7d450c077f0a002293e # v1.3
with:
token: ${{ secrets.TCC_TOKEN }}

- name: go test
if: steps.go-compat.outputs.compatible == 'true'
working-directory: ./${{ inputs.project-directory }}
timeout-minutes: 30
run: make test-unit

- name: Run checker
if: steps.go-compat.outputs.compatible == 'true'
run: |
./scripts/check_environment.sh

# (Optionally) When you don't need Testcontainers Cloud anymore, you could terminate sessions eagerly
- name: Terminate Testcontainers Cloud Client active sessions
if: ${{ steps.go-compat.outputs.compatible == 'true' && inputs.testcontainers-cloud }}
if: ${{ inputs.testcontainers-cloud }}
uses: atomicjar/testcontainers-cloud-setup-action@c335bdbb570ec7c48f72c7d450c077f0a002293e # v1.3
with:
action: terminate
Expand All @@ -138,12 +113,12 @@ jobs:
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
with:
paths: "**/${{ inputs.project-directory }}/TEST-unit*.xml"
if: ${{ always() && steps.go-compat.outputs.compatible == 'true' }}
if: always()

- name: Decide if Sonar must be run
if: ${{ steps.go-compat.outputs.compatible == 'true' && matrix.platform == 'ubuntu-latest' }}
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
if [[ "1.24.x" == "${{ inputs.go-version }}" ]] && \
if [[ "1.25.x" == "${{ inputs.go-version }}" ]] && \
[[ "true" != "${{ inputs.rootless-docker }}" ]] && \
[[ "true" != "${{ inputs.testcontainers-cloud }}" ]] && \
[[ "true" != "${{ inputs.ryuk-disabled }}" ]] && \
Expand All @@ -153,7 +128,7 @@ jobs:
fi

- name: Set Sonar Cloud environment variables
if: ${{ steps.go-compat.outputs.compatible == 'true' && env.SHOULD_RUN_SONAR == 'true' }}
if: ${{ env.SHOULD_RUN_SONAR == 'true' }}
run: |
echo "PROJECT_VERSION=$(grep 'latest_version' mkdocs.yml | cut -d':' -f2 | tr -d ' ')" >> $GITHUB_ENV
if [ "${{ inputs.project-directory }}" == "" ]; then
Expand All @@ -169,7 +144,7 @@ jobs:
fi

- name: SonarQube Scan
if: ${{ steps.go-compat.outputs.compatible == 'true' && env.SHOULD_RUN_SONAR == 'true' }}
if: ${{ env.SHOULD_RUN_SONAR == 'true' }}
uses: SonarSource/sonarqube-scan-action@aa494459d7c39c106cc77b166de8b4250a32bb97 # v5.1.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
# We don't want to fail the build the soonest but identify which modules passed and failed.
fail-fast: false
matrix:
go-version: [1.24.x, 1.25.x]
go-version: [1.25.x, 1.26.x]
module: ${{ fromJSON(needs.detect-modules.outputs.modules) }}
permissions:
contents: read # for actions/checkout to fetch code
Expand All @@ -88,7 +88,7 @@ jobs:
# We don't want to fail the build the soonest but identify which modules passed and failed.
fail-fast: false
matrix:
go-version: [1.24.x, 1.25.x]
go-version: [1.25.x, 1.26.x]
uses: ./.github/workflows/ci-test-go.yml
with:
go-version: ${{ matrix.go-version }}
Expand All @@ -109,7 +109,7 @@ jobs:
name: "Test with reaper off"
strategy:
matrix:
go-version: [1.24.x, 1.25.x]
go-version: [1.25.x, 1.26.x]
uses: ./.github/workflows/ci-test-go.yml
with:
go-version: ${{ matrix.go-version }}
Expand All @@ -130,7 +130,7 @@ jobs:
name: "Test with Rootless Docker"
strategy:
matrix:
go-version: [1.24.x, 1.25.x]
go-version: [1.25.x, 1.26.x]
uses: ./.github/workflows/ci-test-go.yml
with:
go-version: ${{ matrix.go-version }}
Expand Down
9 changes: 9 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ linters:
- thelper
- usestdlibvars
exclusions:
rules:
- linters:
- revive
path: "^exec/"
text: "var-naming: avoid package names that conflict with Go standard library package names"
- linters:
- revive
path: "^log/"
text: "var-naming: avoid package names that conflict with Go standard library package names"
presets:
- comments
- common-false-positives
Expand Down
10 changes: 5 additions & 5 deletions AI.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ This is a **Go monorepo** containing:
## Environment Setup

### Go Version
- **Required**: Go 1.24.7
- **Required**: Go 1.25.7
- **Tool**: Use [gvm](https://github.com/andrewkroh/gvm) for version management
- **CRITICAL**: Always run this before ANY Go command:
```bash
# For Apple Silicon (M1/M2/M3)
eval "$(gvm 1.24.7 --arch=arm64)"
eval "$(gvm 1.25.7 --arch=arm64)"

# For Intel/AMD (x86_64)
eval "$(gvm 1.24.7 --arch=amd64)"
eval "$(gvm 1.25.7 --arch=amd64)"
```

### Project Structure
Expand Down Expand Up @@ -171,14 +171,14 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
### When Tests Fail
1. **Read the error message carefully** - it usually tells you exactly what's wrong
2. **Check if it's a lint issue** - run `make pre-commit` first
3. **Verify Go version** - ensure using Go 1.24.7
3. **Verify Go version** - ensure using Go 1.25.7
4. **Check Docker** - some tests require Docker daemon running

## Common Pitfalls to Avoid

### Code Issues
- ❌ Using interface types as return values
- ❌ Forgetting to run `eval "$(gvm 1.24.7 --arch=arm64)"`
- ❌ Forgetting to run `eval "$(gvm 1.25.7 --arch=arm64)"`
- ❌ Not handling errors from built-in options
- ❌ Using module-specific container names (`PostgresContainer`)
- ❌ Calling `.Customize()` method instead of direct function call
Expand Down
2 changes: 1 addition & 1 deletion commons-test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ define go_install
endef

$(GOBIN)/golangci-lint:
$(call go_install,github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2)
$(call go_install,github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.9.0)
Comment on lines 8 to +9

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, find the commons-test.mk file
find . -name "commons-test.mk" -type f

Repository: testcontainers/testcontainers-go

Length of output: 93


🏁 Script executed:

cat -n commons-test.mk

Repository: testcontainers/testcontainers-go

Length of output: 1893


Use explicit path to ensure the installed golangci-lint version is invoked.

The lint target depends on $(GOBIN)/golangci-lint but invokes the bare golangci-lint command on line 33, which resolves via PATH and may pick up a globally installed binary instead of the pinned v2.9.0.

Fix
 lint: $(GOBIN)/golangci-lint
-	golangci-lint run --verbose -c $(ROOT_DIR)/.golangci.yml --fix
+	$(GOBIN)/golangci-lint run --verbose -c $(ROOT_DIR)/.golangci.yml --fix

The v2.9.0 version is correct for Go 1.25 in this repository.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@commons-test.mk` around lines 8 - 9, The lint target currently invokes the
bare golangci-lint command which can resolve to a global binary; update the lint
target to call the installed binary at $(GOBIN)/golangci-lint (the existing
dependency target $(GOBIN)/golangci-lint) so the pinned v2.9.0 form is used
consistently; locate the lint target and replace the bare invocation of
golangci-lint with $(GOBIN)/golangci-lint and ensure the dependency on
$(GOBIN)/golangci-lint remains.


$(GOBIN)/gotestsum:
$(call go_install,gotest.tools/gotestsum@latest)
Expand Down
3 changes: 2 additions & 1 deletion container.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ import (
"github.com/testcontainers/testcontainers-go/wait"
)

// Deprecated: Use [Container]
//
// DeprecatedContainer shows methods that were supported before, but are now deprecated
// Deprecated: Use Container
type DeprecatedContainer interface {
GetHostEndpoint(ctx context.Context, port string) (string, string, error)
GetIPAddress(ctx context.Context) (string, error)
Expand Down
2 changes: 1 addition & 1 deletion docs/system_requirements/ci/aws_codebuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ version: 0.2
phases:
install:
runtime-versions:
golang: 1.24
golang: 1.25
build:
commands:
- go test ./...
Expand Down
2 changes: 1 addition & 1 deletion docs/system_requirements/ci/circle_ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ workflows:
- tests:
matrix:
parameters:
go-version: ["1.24.7", "1.25.1"]
go-version: ["1.25.7", "1.26.1"]

```

Expand Down
2 changes: 1 addition & 1 deletion docs/system_requirements/ci/concourse_ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
start_docker

cd repo
docker run -it --rm -v "$PWD:$PWD" -w "$PWD" -v /var/run/docker.sock:/var/run/docker.sock golang:1.24 go test ./...
docker run -it --rm -v "$PWD:$PWD" -w "$PWD" -v /var/run/docker.sock:/var/run/docker.sock golang:1.25 go test ./...
```

Finally, you can use Concourse's [fly CLI](https://concourse-ci.org/fly.html) to set the pipeline and trigger the job:
Expand Down
4 changes: 2 additions & 2 deletions docs/system_requirements/ci/dind_patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $ tree .
└── platform
└── integration_test.go

$ docker run -it --rm -v $PWD:$PWD -w $PWD -v /var/run/docker.sock:/var/run/docker.sock golang:1.24 go test ./... -v
$ docker run -it --rm -v $PWD:$PWD -w $PWD -v /var/run/docker.sock:/var/run/docker.sock golang:1.25 go test ./... -v
```

Where:
Expand All @@ -45,7 +45,7 @@ The same can be achieved with Docker Compose:

```yaml
tests:
image: golang:1.24
image: golang:1.25
stop_signal: SIGKILL
stdin_open: true
tty: true
Expand Down
2 changes: 1 addition & 1 deletion docs/system_requirements/ci/gitlab_ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ variables:
DOCKER_DRIVER: overlay2

test:
image: golang:1.24
image: golang:1.25
stage: test
script: go test ./... -v
```
2 changes: 1 addition & 1 deletion docs/system_requirements/ci/tekton.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
- name: source
steps:
- name: read
image: golang:1.24
image: golang:1.25
workingDir: $(workspaces.source.path)
script: go test ./... -v
volumeMounts:
Expand Down
4 changes: 2 additions & 2 deletions examples/nginx/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/testcontainers/testcontainers-go/examples/nginx

go 1.24.0
go 1.25.0

toolchain go1.24.7
toolchain go1.25.7

require (
github.com/stretchr/testify v1.11.1
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/testcontainers/testcontainers-go

go 1.24.0
go 1.25.0

toolchain go1.24.7
toolchain go1.25.7

require (
dario.cat/mergo v1.0.2
Expand Down
4 changes: 2 additions & 2 deletions modulegen/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/testcontainers/testcontainers-go/modulegen

go 1.24.0
go 1.25.0

toolchain go1.24.7
toolchain go1.25.7

require (
github.com/spf13/cobra v1.10.2
Expand Down
4 changes: 2 additions & 2 deletions modules/aerospike/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/testcontainers/testcontainers-go/modules/aerospike

go 1.24.0
go 1.25.0

toolchain go1.24.7
toolchain go1.25.7

require (
github.com/aerospike/aerospike-client-go/v8 v8.2.0
Expand Down
4 changes: 2 additions & 2 deletions modules/arangodb/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/testcontainers/testcontainers-go/modules/arangodb

go 1.24.0
go 1.25.0

toolchain go1.24.7
toolchain go1.25.7

require (
github.com/arangodb/go-driver/v2 v2.1.3
Expand Down
4 changes: 2 additions & 2 deletions modules/artemis/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/testcontainers/testcontainers-go/modules/artemis

go 1.24.0
go 1.25.0

toolchain go1.24.7
toolchain go1.25.7

require (
github.com/docker/go-connections v0.6.0
Expand Down
4 changes: 2 additions & 2 deletions modules/azure/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/testcontainers/testcontainers-go/modules/azure

go 1.24.0
go 1.25.0

toolchain go1.24.7
toolchain go1.25.7

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0
Expand Down
Loading
Loading