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

refactor!: require the builder pattern for module initalisation #161

Merged

Conversation

CommanderStorm
Copy link
Contributor

@CommanderStorm CommanderStorm commented Jul 7, 2024

This PR makes sure that the way structs are constructed is consistent and encourages the builder pattern.
It is based on this question: #156 (comment)

For the changelog:

We now require you to use the builder pattern (instead of some structs being unit structs) for all modules.
This ensures that if we add a field in the future that this will not break your existing code.

This change is breaking for these modules:

Module before after
cncf_distribution::CncfDistribution CncfDistribution.start() CncfDistribution::default().start()
dynamodb_local::DynamoDb DynamoDb.start() DynamoDb::default().start()
elasticmq::ElasticMq ElasticMq.start() ElasticMq::default().start()
mongo::Mongo (see #143) Mongo.start() Mongo::default().start()
kwok::KwokCluster KwokCluster.start() KwokCluster::default().start()
rabbitmq::RabbitMq RabbitMq.start() RabbitMq::default().start()
redis::stack::RedisStack RedisStack.start() RedisStack::default().start()
redis::standalone::Redis Redis.start() Redis::default().start()
victoria_metrics::VictoriaMetrics VictoriaMetrics.start() VictoriaMetrics::default().start()

@CommanderStorm CommanderStorm force-pushed the consistent-struct-initialisation branch from e4e0a17 to 6045cb7 Compare July 7, 2024 16:47
Copy link
Contributor

@DDtKey DDtKey left a comment

Choose a reason for hiding this comment

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

I think we can use refactor instead of chore here

Thank you for the PR! ❤️

@CommanderStorm CommanderStorm changed the title chore!: require the builder pattern for module initalisation refactor!: require the builder pattern for module initalisation Jul 7, 2024
@CommanderStorm CommanderStorm force-pushed the consistent-struct-initialisation branch 2 times, most recently from 596faf7 to ed7a50b Compare July 7, 2024 18:28
@CommanderStorm
Copy link
Contributor Author

Let's clean this up (rustfmt & etc)

Sorry for that part. Forgot to do rustfmt after doing the (apparently missing doctests) testing run

@CommanderStorm
Copy link
Contributor Author

I don't know why the test for mssql_server added in #72 is failing.

Cannot debug this locally.
@kymmt90 I am assuming you are using this in your testing infra. Is this flaky for you too?

@DDtKey
Copy link
Contributor

DDtKey commented Jul 7, 2024

It's definitely not related to this PR and seems flaky - yes. For some reason, I think it happens only on nightly channel (might be coincidence though) 🤔

Need to address this but in separate PR for sure

@CommanderStorm CommanderStorm force-pushed the consistent-struct-initialisation branch from ed7a50b to 54c2d9f Compare July 20, 2024 19:57
@DDtKey DDtKey merged commit 7b05300 into testcontainers:main Sep 25, 2024
4 of 6 checks passed
@CommanderStorm CommanderStorm deleted the consistent-struct-initialisation branch September 25, 2024 16:34
This was referenced Sep 25, 2024
DDtKey pushed a commit that referenced this pull request Sep 25, 2024
## 🤖 New release
* `testcontainers-modules`: 0.10.0 -> 0.11.0 (⚠️ API breaking changes)

### ⚠️ `testcontainers-modules` breaking changes

```
--- failure unit_struct_changed_kind: unit struct changed kind ---

Description:
A public unit struct has been changed to a normal (curly-braces) struct, which cannot be constructed using the same struct literal syntax.
        ref: rust-lang/cargo#10871
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.35.0/src/lints/unit_struct_changed_kind.ron

Failed in:
  struct DynamoDb in /tmp/.tmpSZARLK/testcontainers-rs-modules-community/src/dynamodb_local/mod.rs:8
  struct KwokCluster in /tmp/.tmpSZARLK/testcontainers-rs-modules-community/src/kwok/mod.rs:36
  struct CncfDistribution in /tmp/.tmpSZARLK/testcontainers-rs-modules-community/src/cncf_distribution/mod.rs:30
  struct Redis in /tmp/.tmpSZARLK/testcontainers-rs-modules-community/src/redis/standalone.rs:37
  struct RabbitMq in /tmp/.tmpSZARLK/testcontainers-rs-modules-community/src/rabbitmq/mod.rs:33
  struct ElasticMq in /tmp/.tmpSZARLK/testcontainers-rs-modules-community/src/elasticmq/mod.rs:7
  struct VictoriaMetrics in /tmp/.tmpSZARLK/testcontainers-rs-modules-community/src/victoria_metrics/mod.rs:36
  struct RedisStack in /tmp/.tmpSZARLK/testcontainers-rs-modules-community/src/redis/stack.rs:35
```

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [0.11.0] - 2024-09-25

### Bug Fixes

- Update version to fix crashes in CI
([#219](#219))
- [**breaking**] Make EULA acception explicit
([#218](#218))

### Documentation

- Add docs for the ganachecli module
([#190](#190))

### Features

- Add ability to enable properties-config for testcontainers
- [**breaking**] Update testcontainers to `0.23.0`
([#216](#216))

### Miscellaneous Tasks

- Update redis requirement from 0.26.0 to 0.27.2
([#211](#211))
- Exclude all-features test run
([#174](#174))
- Update async-nats requirement from 0.35.0 to 0.36.0
([#206](#206))

### Refactor

- [**breaking**] Require the builder pattern for module initalisation
([#161](#161))

### Testing

- Correct password usage

<!-- generated by git-cliff -->
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants