Skip to content

Commit 5440de4

Browse files
committed
Merge branch 'main' into dependabot/go_modules/golang.org/x/sys-0.13.0
* main: (27 commits) docs: remove OpenSSF scorecard (#1823) Auto-cleanup of k6 build cache (#1788) Add OpenSSF Scorecards GitHub Action (#1795) chore(deps): bump google.golang.org/grpc from 1.57.0 to 1.57.1 (#1822) chore: expose SessionID (#1793) chore: use HTTP calls to invoke the lambda from the tests (#1794) wait for log producer to really stop inside StopLogProducer func (#1701) chore(deps): bump github.com/nats-io/nats-server/v2 in /modules/nats (#1784) chore(deps): bump urllib3 from 2.0.6 to 2.0.7 (#1781) chore: add an example of using localstack alongside AWS lambdas (#1790) chore(deps): combine and bump compose dependencies (#1787) feat: support for replacing images with custom substitutions (#1719) fix: data race in docker client `Info()` (#1779) Use correct formatting directive for errors in lifecycle logs (#1780) chore(deps): bump golang.org/x/mod from 0.12.0 to 0.13.0 in /modules/{elasticsearch,kafka} and /modulegen (#1778) chore(deps): bump github.com/rabbitmq/amqp091-go in /modules/rabbitmq (#1728) chore(deps): bump github.com/ClickHouse/clickhouse-go/v2 (#1732) ignore patterns defined in dockerignore (#1725) Fix wrong module names (#1776) docs: add default options to k6 module (#1744) ...
2 parents cd7a4d3 + 3d3a9a7 commit 5440de4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+2168
-630
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ updates:
6565
day: sunday
6666
open-pull-requests-limit: 3
6767
rebase-strategy: disabled
68+
- package-ecosystem: gomod
69+
directory: /modules/cassandra
70+
schedule:
71+
interval: monthly
72+
day: sunday
73+
open-pull-requests-limit: 3
74+
rebase-strategy: disabled
6875
- package-ecosystem: gomod
6976
directory: /modules/clickhouse
7077
schedule:

.github/workflows/ci-test-go.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ jobs:
5353
steps:
5454
- name: Setup rootless Docker
5555
if: ${{ inputs.rootless-docker }}
56-
uses: ScribeMD/rootless-docker@0.2.2
56+
uses: ScribeMD/rootless-docker@6bd157a512c2fafa4e0243a8aa87d964eb890886 # v0.2.2
5757

5858
- name: Remove Docket root socket
5959
if: ${{ inputs.rootless-docker }}
6060
run: sudo rm -rf /var/run/docker.sock
6161

6262
- name: Check out code into the Go module directory
63-
uses: actions/checkout@v4
63+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
6464

6565
- name: Set up Go
66-
uses: actions/setup-go@v4
66+
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4
6767
with:
6868
go-version: '${{ inputs.go-version }}'
6969
cache-dependency-path: '${{ inputs.project-directory }}/go.sum'
@@ -72,7 +72,7 @@ jobs:
7272
- name: golangci-lint
7373
# TODO: Remove each example/module once it passes the golangci-lint
7474
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) }}
75-
uses: golangci/golangci-lint-action@v3
75+
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3
7676
with:
7777
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
7878
version: v1.54.1
@@ -110,7 +110,7 @@ jobs:
110110
111111
- name: Upload SonarCloud files
112112
if: ${{ github.ref_name == 'main' && github.repository_owner == 'testcontainers' && inputs.run-tests && !inputs.rootless-docker }}
113-
uses: actions/upload-artifact@v3
113+
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
114114
with:
115115
name: sonarcloud
116116
path: |
@@ -123,7 +123,7 @@ jobs:
123123
./scripts/check_environment.sh
124124
125125
- name: Test Summary
126-
uses: test-summary/action@62bc5c68de2a6a0d02039763b8c754569df99e3f
126+
uses: test-summary/action@62bc5c68de2a6a0d02039763b8c754569df99e3f # v2
127127
with:
128128
paths: "**/${{ inputs.project-directory }}/TEST-unit*.xml"
129129
if: always()

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ jobs:
106106
matrix:
107107
go-version: [1.20.x, 1.x]
108108
platform: [ubuntu-latest, macos-latest]
109-
module: [artemis, clickhouse, compose, couchbase, elasticsearch, gcloud, k3s, k6, kafka, localstack, mariadb, mongodb, mysql, nats, neo4j, postgres, pulsar, rabbitmq, redis, redpanda, vault]
109+
module: [artemis, cassandra, clickhouse, compose, couchbase, elasticsearch, gcloud, k3s, k6, kafka, localstack, mariadb, mongodb, mysql, nats, neo4j, postgres, pulsar, rabbitmq, redis, redpanda, vault]
110+
exclude:
111+
- go-version: 1.20.x
112+
module: compose
110113
uses: ./.github/workflows/ci-test-go.yml
111114
with:
112115
go-version: ${{ matrix.go-version }}

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646

4747
steps:
4848
- name: Checkout repository
49-
uses: actions/checkout@v4
49+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
5050

5151
# Initializes the CodeQL tools for scanning.
5252
- name: Initialize CodeQL
@@ -64,7 +64,7 @@ jobs:
6464
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
6565
# If this step fails, then you should remove it and run the build manually (see below)
6666
- name: Autobuild
67-
uses: github/codeql-action/autobuild@v2
67+
uses: github/codeql-action/autobuild@49abf0ba24d0b7953cb586944e918a0b92074c80 # v2
6868

6969
# ℹ️ Command-line programs to run using the OS shell.
7070
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -77,6 +77,6 @@ jobs:
7777
# ./location_of_script_within_repo/buildscript.sh
7878

7979
- name: Perform CodeQL Analysis
80-
uses: github/codeql-action/analyze@v2
80+
uses: github/codeql-action/analyze@49abf0ba24d0b7953cb586944e918a0b92074c80 # v2
8181
with:
8282
category: "/language:${{matrix.language}}"

.github/workflows/scorecards.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Scorecard analysis workflow
2+
on:
3+
# Only the default branch is supported.
4+
branch_protection_rule:
5+
push:
6+
branches: [ main ]
7+
8+
# Declare default permissions as read only.
9+
permissions: read-all
10+
11+
jobs:
12+
analysis:
13+
name: Scorecard analysis
14+
runs-on: ubuntu-latest
15+
permissions:
16+
# Needed if using Code scanning alerts
17+
security-events: write
18+
# Needed for GitHub OIDC token if publish_results is true
19+
id-token: write
20+
21+
steps:
22+
- name: "Checkout code"
23+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
24+
with:
25+
persist-credentials: false
26+
27+
- name: "Run analysis"
28+
uses: ossf/scorecard-action@80e868c13c90f172d68d1f4501dee99e2479f7af # v2.1.3
29+
with:
30+
results_file: results.sarif
31+
results_format: sarif
32+
# (Optional) fine-grained personal access token. Uncomment the `repo_token` line below if:
33+
# - you want to enable the Branch-Protection check on a *public* repository, or
34+
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-fine-grained-pat-optional.
35+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
36+
37+
# Publish the results for public repositories to enable scorecard badges. For more details, see
38+
# https://github.com/ossf/scorecard-action#publishing-results.
39+
# For private repositories, `publish_results` will automatically be set to `false`, regardless
40+
# of the value entered here.
41+
publish_results: true
42+
43+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
44+
# format to the repository Actions tab.
45+
- name: "Upload artifact"
46+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
47+
with:
48+
name: SARIF file
49+
path: results.sarif
50+
retention-days: 5
51+
52+
# required for Code scanning alerts
53+
- name: "Upload SARIF results to code scanning"
54+
uses: github/codeql-action/upload-sarif@83f0fe6c4988d98a455712a27f0255212bba9bd4 # v2.3.6
55+
with:
56+
sarif_file: results.sarif

.vscode/.testcontainers-go.code-workspace

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
"name": "module / artemis",
2626
"path": "../modules/artemis"
2727
},
28+
{
29+
"name": "module / cassandra",
30+
"path": "../modules/cassandra"
31+
},
2832
{
2933
"name": "module / clickhouse",
3034
"path": "../modules/clickhouse"

Pipfile.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,27 @@
22

33
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=141451032&machine=standardLinux32gb&devcontainer_path=.devcontainer%2Fdevcontainer.json&location=EastUs)
44

5+
**Builds**
6+
57
[![Main pipeline](https://github.com/testcontainers/testcontainers-go/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/testcontainers/testcontainers-go/actions/workflows/ci.yml)
6-
[![Go Report Card](https://goreportcard.com/badge/github.com/testcontainers/testcontainers-go)](https://goreportcard.com/report/github.com/testcontainers/testcontainers-go)
8+
9+
**Documentation**
10+
711
[![GoDoc Reference](https://camo.githubusercontent.com/8609cfcb531fa0f5598a3d4353596fae9336cce3/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f79616e6777656e6d61692f686f772d746f2d6164642d62616467652d696e2d6769746875622d726561646d653f7374617475732e737667)](https://pkg.go.dev/github.com/testcontainers/testcontainers-go)
812

13+
**Social**
14+
15+
[![Slack](https://img.shields.io/badge/Slack-4A154B?logo=slack)](https://testcontainers.slack.com/)
16+
17+
**Code quality**
18+
19+
[![Go Report Card](https://goreportcard.com/badge/github.com/testcontainers/testcontainers-go)](https://goreportcard.com/report/github.com/testcontainers/testcontainers-go)
20+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=testcontainers_testcontainers-go&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=testcontainers_testcontainers-go)
21+
22+
**License**
23+
24+
[![License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/testcontainers/testcontainers-go/blob/main/LICENSE)
25+
926
_Testcontainers for Go_ is a Go package that makes it simple to create and clean up container-based dependencies for
1027
automated integration/smoke tests. The clean, easy-to-use API enables developers to programmatically define containers
1128
that should be run as part of a test and clean up those resources when the test is done.

commons-test.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test-%:
1818
--packages="./..." \
1919
--junitfile TEST-unit.xml \
2020
-- \
21-
-coverprofile=coverage.out \
21+
-coverprofile=coverage.out \
2222
-timeout=30m
2323

2424
.PHONY: tools

container.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"io"
8+
"os"
89
"path/filepath"
910
"strings"
1011
"time"
@@ -16,6 +17,7 @@ import (
1617
"github.com/docker/docker/pkg/archive"
1718
"github.com/docker/go-connections/nat"
1819
"github.com/google/uuid"
20+
"github.com/moby/patternmatcher/ignorefile"
1921

2022
tcexec "github.com/testcontainers/testcontainers-go/exec"
2123
"github.com/testcontainers/testcontainers-go/internal/testcontainersdocker"
@@ -96,6 +98,7 @@ type ContainerFile struct {
9698
type ContainerRequest struct {
9799
FromDockerfile
98100
Image string
101+
ImageSubstitutors []ImageSubstitutor
99102
Entrypoint []string
100103
Env map[string]string
101104
ExposedPorts []string // allow specifying protocol info
@@ -188,14 +191,32 @@ func (c *ContainerRequest) GetContext() (io.Reader, error) {
188191
}
189192
c.Context = abs
190193

191-
buildContext, err := archive.TarWithOptions(c.Context, &archive.TarOptions{})
194+
excluded, err := parseDockerIgnore(abs)
195+
if err != nil {
196+
return nil, err
197+
}
198+
buildContext, err := archive.TarWithOptions(c.Context, &archive.TarOptions{ExcludePatterns: excluded})
192199
if err != nil {
193200
return nil, err
194201
}
195202

196203
return buildContext, nil
197204
}
198205

206+
func parseDockerIgnore(targetDir string) ([]string, error) {
207+
// based on https://github.com/docker/cli/blob/master/cli/command/image/build/dockerignore.go#L14
208+
fileLocation := filepath.Join(targetDir, ".dockerignore")
209+
var excluded []string
210+
if f, openErr := os.Open(fileLocation); openErr == nil {
211+
var err error
212+
excluded, err = ignorefile.ReadAll(f)
213+
if err != nil {
214+
return excluded, fmt.Errorf("error reading .dockerignore: %w", err)
215+
}
216+
}
217+
return excluded, nil
218+
}
219+
199220
// GetBuildArgs returns the env args to be used when creating from Dockerfile
200221
func (c *ContainerRequest) GetBuildArgs() map[string]*string {
201222
return c.FromDockerfile.BuildArgs

0 commit comments

Comments
 (0)