-
-
Notifications
You must be signed in to change notification settings - Fork 511
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
feat: provide a tool to generate examples from code #618
Conversation
Not adding value to the example
.github/workflows/ci.yml
Outdated
@@ -47,6 +47,10 @@ jobs: | |||
if: ${{ matrix.platform == 'ubuntu-latest' }} | |||
run: make test-e2e | |||
|
|||
- name: Run Example tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm tempted to have a dedicated pipeline for each example, instead of adding build time to the main one. Wdyt? If that's the case, should the checks be mandatory for the review?
@eddumelendez and I had a chat on this PR, and we are going to merge as is, creating follow-up PRs adding more examples. |
* main: Add toxiproxy example (testcontainers#643) Add spanner example (testcontainers#642) chore: sync governance files (testcontainers#641) Add pubsub example (testcontainers#640) chore: adjust generator for the docs site (testcontainers#639) Add datastore example (testcontainers#638) Add firestore example (#637) fix: avoid panics when checking container state and container.raw is nil (#635) feat: provide a tool to generate examples from code (#618) chore: bump version in mkdocs (#630) docs: remove code snippets from main README (#631) docs: document replace directive for Docker Compose (#632)
What does this PR do?
It moves the existing examples' code (cockroachDB, nginx, pulsar and redis) to separate example Go modules that will be automatically included into the docs site.
Besides, we have provided a command line tool to generate the scaffolding for the code of a new example. This tool will generate:
gotestsum
) used to build/run the example.This tool is not doing the following:
You have to manually add the markdown entry in the docs to theImplemented in this PR 🚀mkdocs.yml
file in the root directory of the project. It will generate the navigation menu for the docs website.In this PR we are adding a Make goal to run all the examples' tests, in order to check if they are still valid and not outdated. The make goal, which calls each example's Makefile, is used in the CI pipeline for each example.
Why is it important?
Examples embedded into the docs could get outdated and they could not even compile. With this approach, the tests will be part of the test suite.
We expect the code generation tool will simplify how to start an example, creating the scaffolding for it.
Related issues
Follow-up questions