Skip to content

Commit

Permalink
Merge branch 'main' into user-defined-lifecycle-hooks
Browse files Browse the repository at this point in the history
* main: (25 commits)
  chore(deps): bump github.com/dvsekhvalnov/jose2go in /modules/pulsar (testcontainers#2136)
  fix: skip-host-cache option removed in latest MySQL 8.3.0 version (testcontainers#2130)
  chore: skip assertions for Docker Rootless (testcontainers#2135)
  pin Docker images version (testcontainers#2129)
  enable golangci-lint for examples (testcontainers#2128)
  chore(deps): bump github.com/neo4j/neo4j-go-driver/v5 in /modules/neo4j (testcontainers#2098)
  enable golangci-lint for redis module (testcontainers#2126)
  Go install gotestsum and golangci-lint  (testcontainers#2127)
  improve OSSF score (testcontainers#2125)
  chore: run make lint on new modules (testcontainers#2122)
  enable golangci-lint for pulsar (testcontainers#2121)
  lint: enable testifylint (testcontainers#2120)
  chore(deps): bump github.com/nats-io/nats.go in /modules/nats (testcontainers#2094)
  chore(deps): bump golang.org/x/sys from 0.15.0 to 0.16.0 (testcontainers#2104)
  Revert "chore(deps): bump actions/upload-artifact from 3.1.3 to 4.0.0 (testcontainers#2088)"
  chore(deps): bump actions/upload-artifact from 3.1.3 to 4.0.0 (testcontainers#2088)
  chore(deps): bump cloud.google.com/go/spanner from 1.54.0 to 1.55.0, google.golang.org/api from 0.154.0 to 0.156.0 in /modules/gcloud (testcontainers#2115)
  chore(deps): bump github.com/aws/aws-sdk-go-v2/config from 1.25.10 to 1.26.3, github.com/aws/aws-sdk-go from 1.48.13 to 1.49.19 in /modules/localstack (testcontainers#2114)
  chore(deps): bump github.com/docker/go-connections from 0.4.0 to 0.5.0 (testcontainers#2113)
  Adding mockserver module (testcontainers#2085)
  ...
  • Loading branch information
mdelapenya committed Jan 24, 2024
2 parents 474ddea + 12ad0ab commit 88e1961
Show file tree
Hide file tree
Showing 132 changed files with 1,662 additions and 830 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ updates:
day: sunday
open-pull-requests-limit: 3
rebase-strategy: disabled
- package-ecosystem: gomod
directory: /modules/mockserver
schedule:
interval: monthly
day: sunday
open-pull-requests-limit: 3
rebase-strategy: disabled
- package-ecosystem: gomod
directory: /modules/mongodb
schedule:
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/ci-test-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ jobs:

- name: golangci-lint
# TODO: Remove each example/module once it passes the golangci-lint
if: ${{ inputs.platform == 'ubuntu-latest' && inputs.go-version == '1.20.x' && !contains(fromJSON('["examples/cockroachdb", "examples/toxiproxy", "modules/compose", "modules/pulsar", "modules/redis"]'), inputs.project-directory) }}
if: ${{ inputs.platform == 'ubuntu-latest' && inputs.go-version == '1.20.x' && !contains(fromJSON('["modules/compose"]'), inputs.project-directory) }}
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.54.1
version: v1.55.2
# Optional: working directory, useful for monorepos
working-directory: ${{ inputs.project-directory }}
# Optional: golangci-lint command line arguments.
Expand Down Expand Up @@ -104,9 +104,7 @@ jobs:
if: ${{ inputs.run-tests }}
working-directory: ./${{ inputs.project-directory }}
timeout-minutes: 30
run: |
go install gotest.tools/gotestsum@latest
make test-unit
run: make test-unit

- name: Upload SonarCloud files
if: ${{ github.ref_name == 'main' && github.repository_owner == 'testcontainers' && inputs.run-tests && !inputs.rootless-docker }}
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ci-windows-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ on:
issue_comment:
types: [created]

permissions:
contents: read

jobs:
windows-test-command-trigger:
permissions:
pull-requests: write # for peter-evans/slash-command-dispatch to create PR reaction
runs-on: ubuntu-22.04

steps:
- name: Trigger windows-test command
uses: peter-evans/slash-command-dispatch@v3
uses: peter-evans/slash-command-dispatch@f996d7b7aae9059759ac55e978cff76d91853301 # v3.0.2
with:
token: ${{ secrets.WINDOWS_WORKERS_TOKEN }}
# The command to trigger the pipeline: e.g. /windows-test
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
timeout-minutes: 30
steps:
- name: Create pending status
uses: actions/github-script@v7.0.1
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand All @@ -27,7 +27,7 @@ jobs:
})
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
Expand All @@ -50,12 +50,10 @@ jobs:

- name: go test
timeout-minutes: 30
run: |
go install gotest.tools/gotestsum@latest
gotestsum --format short-verbose --rerun-fails=5 --packages="./..." --junitfile TEST-unit.xml -- -timeout=30m
run: make test-unit

- name: Create success status
uses: actions/github-script@v7.0.1
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: success()
with:
github-token: ${{secrets.GITHUB_TOKEN}}
Expand All @@ -70,7 +68,7 @@ jobs:
})
- name: Create failure status
uses: actions/github-script@v7.0.1
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: failure()
with:
github-token: ${{secrets.GITHUB_TOKEN}}
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ jobs:
ryuk-disabled: false

# The job below is a copy of the job above, but with ryuk disabled.
# It's executed in a secondary stage to avoid concurrency issues.
# It's executed in the first stage to avoid concurrency issues.
test-reaper-off:
# do not run this job if it's a PR from dependabot that is not approved yet
if: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.state != 'approved' && github.triggering_actor == 'dependabot[bot]') }}
name: "Test with reaper off"
needs: test
strategy:
matrix:
go-version: [1.20.x, 1.x]
Expand All @@ -61,12 +60,11 @@ jobs:
ryuk-disabled: true

# The job below is a copy of the job above, but with Docker rootless.
# It's executed in a secondary stage to avoid concurrency issues.
# It's executed in the first stage to avoid concurrency issues.
test-rootless-docker:
# do not run this job if it's a PR from dependabot that is not approved yet
if: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.state != 'approved' && github.triggering_actor == 'dependabot[bot]') }}
name: "Test with Rootless Docker"
needs: test
strategy:
matrix:
go-version: [1.20.x, 1.x]
Expand Down Expand Up @@ -106,7 +104,7 @@ jobs:
matrix:
go-version: [1.20.x, 1.x]
platform: [ubuntu-latest, macos-latest]
module: [artemis, cassandra, clickhouse, compose, couchbase, elasticsearch, gcloud, k3s, k6, kafka, localstack, mariadb, mongodb, mssql, mysql, nats, neo4j, postgres, pulsar, rabbitmq, redis, redpanda, vault]
module: [artemis, cassandra, clickhouse, compose, couchbase, elasticsearch, gcloud, k3s, k6, kafka, localstack, mariadb, mockserver, mongodb, mssql, mysql, nats, neo4j, postgres, pulsar, rabbitmq, redis, redpanda, vault]
exclude:
- go-version: 1.20.x
module: compose
Expand Down Expand Up @@ -138,22 +136,25 @@ jobs:
ryuk-disabled: false

sonarcloud:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for sonarsource/sonarcloud-github-action to determine which PR to decorate
if: ${{ github.ref_name == 'main' && github.repository_owner == 'testcontainers' }}
needs: test-examples
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: sonarcloud

- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
uses: sonarsource/sonarcloud-github-action@49e6cd3b187936a73b8280d59ffd9da69df63ec9 # v2.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3 changes: 3 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ on:
schedule:
- cron: '40 6 * * 5'

permissions:
contents: read

jobs:
analyze:
name: Analyze
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ on:
branches:
- main

permissions:
contents: read

jobs:
update_release_draft:
permissions:
contents: write # for release-drafter/release-drafter to create a github release
pull-requests: write # for release-drafter/release-drafter to add label to PR
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@09c613e259eb8d4e7c81c2cb00618eb5fc4575a7 # v5.19.0
Expand Down
16 changes: 16 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ linters:
- gofumpt
- misspell
- nonamedreturns
- testifylint

linters-settings:
errorlint:
Expand All @@ -23,5 +24,20 @@ linters-settings:
- standard
- default
- prefix(github.com/testcontainers)
testifylint:
disable:
- compares
- float-compare
- go-require
enable:
- bool-compare
- empty
- error-is-as
- error-nil
- expected-actual
- len
- require-error
- suite-dont-use-pkg
- suite-extra-assert-call
run:
timeout: 5m
4 changes: 4 additions & 0 deletions .vscode/.testcontainers-go.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
"name": "module / mariadb",
"path": "../modules/mariadb"
},
{
"name": "module / mockserver",
"path": "../modules/mockserver"
},
{
"name": "module / mongodb",
"path": "../modules/mongodb"
Expand Down
7 changes: 4 additions & 3 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 22 additions & 4 deletions commons-test.mk
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
GOBIN= $(GOPATH)/bin

define go_install
go install $(1)
endef

$(GOBIN)/golangci-lint:
$(call go_install,github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2)

$(GOBIN)/gotestsum:
$(call go_install,gotest.tools/gotestsum@latest)

.PHONY: install
install: $(GOBIN)/golangci-lint $(GOBIN)/gotestsum

.PHONY: clean
clean:
rm $(GOBIN)/golangci-lint
rm $(GOBIN)/gotestsum

.PHONY: dependencies-scan
dependencies-scan:
@echo ">> Scanning dependencies in $(CURDIR)..."
go list -json -m all | docker run --rm -i sonatypecommunity/nancy:latest sleuth --skip-update-check

.PHONY: lint
lint:
lint: $(GOBIN)/golangci-lint
golangci-lint run --out-format=github-actions --path-prefix=. --verbose -c $(ROOT_DIR)/.golangci.yml --fix

.PHONY: test-%
test-%:
test-%: $(GOBIN)/gotestsum
@echo "Running $* tests..."
gotestsum \
--format short-verbose \
Expand All @@ -26,8 +45,7 @@ tools:
go mod download

.PHONY: test-tools
test-tools:
go install gotest.tools/gotestsum@latest
test-tools: $(GOBIN)/gotestsum

.PHONY: tools-tidy
tools-tidy:
Expand Down
2 changes: 1 addition & 1 deletion docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ func (c *DockerContainer) CopyToContainer(ctx context.Context, fileContent []byt
return err
}

err = c.provider.client.CopyToContainer(ctx, c.ID, filepath.Dir(containerFilePath), buffer, types.CopyToContainerOptions{})
err = c.provider.client.CopyToContainer(ctx, c.ID, "/", buffer, types.CopyToContainerOptions{})
if err != nil {
return err
}
Expand Down

0 comments on commit 88e1961

Please sign in to comment.