To run tests for the docker/awesome-compose project, follow the detailed instructions below, tailored for expert developers.

Step 1: Set Up Your Environment

Ensure you have Docker installed and your environment is set up correctly. You should already have cloned the docker/awesome-compose repository.

git clone https://github.com/docker/awesome-compose.git
cd awesome-compose

Step 2: Build the Docker Images

Navigate to the specific compose directory for the service you want to test. For instance, if you’re testing the Go backend, go into the nginx-golang directory:

cd nginx-golang

Build the Docker images as specified in the docker-compose.yml file:

docker-compose build

Step 3: Running Tests for the Go Backend

To run tests for the Go backend located in github.com/docker/awesome-compose/nginx-golang/backend, you need to execute the following command in the shell:

docker-compose run --rm backend go test ./...

This command will run all the Go tests in the backend service, cleaning up the container once the tests are complete.

Step 4: Running Tests for Other Languages

For projects containing various languages, below are the commands for running tests in different services:

TypeScript Tests

If you are working with a TypeScript service, for example, execute:

docker-compose run --rm <typescript-service> npm run test

Replace <typescript-service> with the actual service name derived from your docker-compose.yml file.

Python Tests

For a Python service, you can run:

docker-compose run --rm <python-service> pytest

Java Tests

For Java projects, use:

docker-compose run --rm <java-service> ./gradlew test

JavaScript Tests

For testing JavaScript code, execute:

docker-compose run --rm <javascript-service> npm test

Go Tests

When dealing with Go, ensure that you never include the -mod=vendor option as mentioned. The command for running tests is:

docker-compose run --rm backend go test ./...

C# Tests

If you are running C# code, use:

docker-compose run --rm <csharp-service> dotnet test

PHP Tests

For PHP services, run:

docker-compose run --rm <php-service> phpunit

Vue and SCSS Tests

For Vue.js applications, execute:

docker-compose run --rm <vue-service> npm run test

For SCSS linting and tests, you could run:

docker-compose run --rm <scss-service> stylelint '**/*.scss'

Conclusion

Ensure to substitute <service> with the designated service name from your docker-compose.yml file when executing tests. Each language and framework has its own set of dependencies and requirements, so make sure you have everything set up as needed.

Sources: docker/awesome-compose