madelson / DistributedLock

A .NET library for distributed synchronization
MIT License
1.92k stars 198 forks source link

Local development and CI using test containers #207

Open Meir017 opened 6 months ago

Meir017 commented 6 months ago

Using test containers (https://dotnet.testcontainers.org/) will improve the developer experience and allow having a cross platform CI without maintaining anything in the environment (other than having docker installed)

madelson commented 6 months ago

I agree this would be a great idea, especially if it can create and easy path towards enabling a larger portion of the suite to run through GitHub actions.

@Meir017 is this something you’re interested in contributing? If so, let’s discuss what the implications would be for the code base and developer experience.

Meir017 commented 6 months ago

@madelson I'll be happy to contribute here. I was thinking of starting with the Redis provider here - I'll need to see how to enable just a subset of the test to make this be a gradual effort

From what I see on other projects using test-containers, we could just use the ubuntu image (see https://github.com/actions/runner-images/blob/ubuntu22/20240212.1/images/ubuntu/Ubuntu2204-Readme.md having docker already installed, and a working example https://github.com/filipsnastins/testcontainers-github-actions/actions/runs/7959995426/job/21728056781?pr=80)

madelson commented 6 months ago

Redis makes sense as a place to start. The tests are pretty well organized by namespace/category (and more could be done if that’s not sufficient), so it shouldn’t be terribly difficult to run just the redis tests through nunit.

douglasg14b commented 6 months ago

If you're talking about black box tests, you can standup a test environment in github actions with docker-compose, and run tests against those environments. You can add an abstraction over it with Tilt if desired.

This has the advantage of not leaking the test env into your code, but afaik is fundamentally the same as testcontainers 🤔

You end up just standup up the envs for redis, postgres....etc using their already existing images. It's quite convenient :)

Meir017 commented 6 months ago

@douglasg14b would this affect the local development experience? Would developers still need to install locally thr different dependencies?