-
-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df8c549
commit 7eb1c07
Showing
1 changed file
with
49 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,18 +6,59 @@ | |
Your CircleCI configuration should use a dedicated VM for Testcontainers to work. You can achieve this by specifying the | ||
executor type in your `.circleci/config.yml` to be `machine` instead of the default `docker` executor (see [Choosing an Executor Type](https://circleci.com/docs/executor-intro/) for more info). | ||
|
||
Here is a sample CircleCI configuration that does a checkout of a project and runs Maven: | ||
Here is a sample CircleCI configuration that does a checkout of a project and runs `go test` for a project. Go is installed for the `tests` job using [`gvm`](https:/andrewkroh/gvm), and a workflow matrix has been defined to run the job with different Go versions. Go steps are finally executed from the `go` orb. | ||
|
||
```yml | ||
version: 2.1 | ||
|
||
orbs: | ||
go: circleci/[email protected] | ||
|
||
executors: | ||
machine_executor_amd64: | ||
machine: | ||
image: ubuntu-2204:2024.01.2 | ||
environment: | ||
architecture: "amd64" | ||
platform: "linux/amd64" | ||
|
||
jobs: | ||
build: | ||
# Check https://circleci.com/docs/executor-intro#linux-vm for more details | ||
machine: true | ||
image: ubuntu-2204:2023.04.2 | ||
tests: | ||
executor: machine_executor_amd64 | ||
parameters: | ||
go-version: | ||
type: string | ||
steps: | ||
# install Go 1.x | ||
# checkout the project | ||
- run: go test./... | ||
- run: | ||
name: Install GVM | ||
command: | | ||
mkdir ~/gvmbin | ||
curl -sL -o ~/gvmbin/gvm https:/andrewkroh/gvm/releases/download/v0.5.2/gvm-linux-amd64 | ||
chmod +x ~/gvmbin/gvm | ||
echo 'export PATH=$PATH:~/gvmbin' >> "$BASH_ENV" | ||
- run: | ||
name: Install Go | ||
command: | | ||
eval "$(gvm << parameters.go-version >>)" | ||
echo 'eval "$(gvm << parameters.go-version >>)"' >> "$BASH_ENV" | ||
go version | ||
- checkout # checkout source code | ||
- go/load-cache # Load cached Go modules. | ||
- go/mod-download # Run 'go mod download'. | ||
- go/save-cache # Save Go modules to cache. | ||
- go/test: # Runs 'go test ./...' but includes extensive parameterization for finer tuning. | ||
covermode: atomic | ||
failfast: true | ||
race: true | ||
|
||
workflows: | ||
build-and-test: | ||
jobs: | ||
- tests: | ||
matrix: | ||
parameters: | ||
go-version: ["1.21.7", "1.22.3"] | ||
|
||
``` | ||
|
||
You can learn more about the best practices of using Testcontainers together with CircleCI in [this article](https://www.atomicjar.com/2022/12/testcontainers-with-circleci/) for Java. |