Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: run Windows tests on a Linux container #1456

Merged
merged 2 commits into from Aug 8, 2023

Conversation

mdelapenya
Copy link
Collaborator

@mdelapenya mdelapenya commented Aug 8, 2023

What does this PR do?

It runs all the GH steps in the GH workflow for windows in an Alpine container. See https://docs.github.com/en/actions/using-jobs/running-jobs-in-a-container#example-running-a-job-within-a-container

Use jobs.<job_id>.container to create a container to run any steps in a job that don't already specify a container. If you have steps that use both script and container actions, the container actions will run as sibling containers on the same network with the same volume mounts.

If you do not set a container, all steps will run directly on the host specified by runs-on unless a step refers to an action configured to run in a container.

name: CI
on:
  push:
    branches: [ main ]
jobs:
  container-test-job:
    runs-on: ubuntu-latest
    container:
      image: node:14.16
      env:
        NODE_ENV: development
      ports:
        - 80
      volumes:
        - my_docker_volume:/volume_mount
      options: --cpus 1
    steps:
      - name: Check for dockerenv file
        run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv)

Why is it important?

Thanks to WSL, it's possible to install Docker Desktop in the baremetal host, and for that reason we can run linux containers in the Windows machine. With that, the docker socket path will be resolved to npipe, which at this moment is the main goal that we have (Windows containers are not supported yet)

At the same time, because everything runs inside a container, the workspace will be empty, so that we should not be affected by previous runs on the same self-hosted (baremetal) machine.

Follow-ups

Other tc-lang repos consuming the Windows workers should use the same strategy. cc/ @eddumelendez @cristianrgreco @HofmeisterAn

Thanks to WSL, it's possible to install Docker Desktop in the baremetal
host, and for that reason we can run linux containers in the Windows
machine. With that, the docker socket path will be resolved to npipe
@mdelapenya mdelapenya requested a review from a team as a code owner August 8, 2023 08:19
@mdelapenya mdelapenya added the chore Changes that do not impact the existing functionality label Aug 8, 2023
@mdelapenya mdelapenya self-assigned this Aug 8, 2023
@netlify
Copy link

netlify bot commented Aug 8, 2023

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit a85c000
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/64d216280947ca000898acb3
😎 Deploy Preview https://deploy-preview-1456--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

cristianrgreco
cristianrgreco previously approved these changes Aug 8, 2023
Copy link
Contributor

@cristianrgreco cristianrgreco left a comment

Choose a reason for hiding this comment

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

LGTM but I am not sure that the Docker socket will be mounted into the container

@mdelapenya
Copy link
Collaborator Author

mdelapenya commented Aug 8, 2023

LGTM but I am not sure that the Docker socket will be mounted into the container

Do you think we should mount it first? https://docs.github.com/en/actions/using-jobs/running-jobs-in-a-container#example-mounting-volumes-in-a-container

Use jobs.<job_id>.container.volumes to set an array of volumes for the container to use. You can use volumes to share data between services or other steps in a job. You can specify named Docker volumes, anonymous Docker volumes, or bind mounts on the host.

To specify a volume, you specify the source and destination path:

source:destinationPath.

The is a volume name or an absolute path on the host machine, and is an absolute path in the container.

volumes:
  - my_docker_volume:/volume_mount
  - /data/my_data
  - /source/directory:/destination/directory

Maybe:

volumes:
  - //var/run/docker.sock:/var/run/docker.sock

@sonarcloud
Copy link

sonarcloud bot commented Aug 8, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Contributor

@cristianrgreco cristianrgreco left a comment

Choose a reason for hiding this comment

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

Let's give it ago

@mdelapenya
Copy link
Collaborator Author

Merging, as it's not affecting the current tests, and we need it to verify the test execution on Windows

@mdelapenya mdelapenya merged commit 59986bb into testcontainers:main Aug 8, 2023
16 checks passed
@mdelapenya mdelapenya deleted the windows-linux-containers branch August 8, 2023 10:29
mdelapenya added a commit that referenced this pull request Aug 8, 2023
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Aug 10, 2023
* main: (29 commits)
  Add support for MongoDB testing module (testcontainers#1447)
  Support groups in dependabot updates (testcontainers#1459)
  chore: run modulegen tests on Windows (testcontainers#1478)
  Add default labels when Ryuk is disabled (testcontainers#1339)
  feat: add clickhouse module (testcontainers#1372)
  chore: increase timeout for go test and GH action steps (testcontainers#1475)
  chore: triple max timeout for the workflow run, which takes +10m (testcontainers#1474)
  chore(deps): bump github.com/aws dependencies in /modules/localstack (testcontainers#1472)
  chore(deps): bump Google emulators dependencies in /examples (testcontainers#1471)
  all: fix goroutine leaks (testcontainers#1358)
  chore(deps): bump github.com/neo4j/neo4j-go-driver/v5 in /modules/neo4j (testcontainers#1427)
  chore(deps): bump github.com/tidwall/gjson from 1.14.4 to 1.15.0 in /modules/vault (testcontainers#1428)
  chore: add a GH action for release drafter (testcontainers#1470)
  chore(deps): bump mkdocs-material from 3.2.0 to 8.2.7 (testcontainers#1468)
  Add global testcontainers header to docs (testcontainers#1308)
  Simplify dependabot updates sorting (testcontainers#1460)
  feat: use credential helper in docker config, even if auth is empty in .docker/config.json (testcontainers#1079)
  chore(deps): bump github.com/aws/aws-sdk-go-v2/service/s3 (testcontainers#1457)
  Revert "chore: run Windows tests on a Linux container (testcontainers#1456)"
  chore: run Windows tests on a Linux container (testcontainers#1456)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Changes that do not impact the existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants