You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We lint the code snippets in the SDK guides, but the new Guides section uses a different path for the snippets that isn't being included in that linting. This is creating some inconsistency in code formatting.
With the playground embeds though, it's no longer a direct reference between the snippet file and what you see on the page. I assume the playground embeds are created from the snippets, @vikram-dagger please correct me if I'm wrong.
With the playground embeds though, it's no longer a direct reference between the snippet file and what you see on the page. I assume the playground embeds are created from the snippets, @vikram-dagger please correct me if I'm wrong.
Maybe we should do the same for the others. In Python, the linter has slightly different rules for docs, but that should be fine if their path is preserved.
With the playground embeds though, it's no longer a direct reference between the snippet file and what you see on the page. I assume the playground embeds are created from the snippets, @vikram-dagger please correct me if I'm wrong.
With the playground embeds though, it's no longer a direct reference between the snippet file and what you see on the page. I assume the playground embeds are created from the snippets, @vikram-dagger please correct me if I'm wrong.
Is linting the snippets in docs sufficient to ensure that they run successfully?
Linting is the right way of catching programmatic and stylistic errors, but not testing that the code actually runs. Maybe linting is enough for now, but I am pretty sure that we want some type of integration tests that would show failures - maybe in GitHub Actions - when the code fails. Running these snippets and ensuring that they all exit with 0 would be sufficient.
I know that my comment is not on topic. I am mostly continuing a conversation that we started with @vikram-dagger on March 28th, 2023.
Yes, two separate things. Linting is fast and easy, brings more consistency to the examples and helps us follow good practices for users to copy.
As for tests, that was discussed but don't remember when or where. What I remember is that Andrea (I think) alluded that it was a burden on CI (time and cost continually increasing when adding more docs) and maintainability (keeping tests up to date with the code).
On maintainability, with CUE it was a bit easier since it's declarative, now it's a much harder problem with the multiple languages. As for simply running a script and checking exit code, it's not that simple. For example, many guides use external services that need to be set up with proper keys (GCR, AWS...).
So I believe consensus (at least for now) is that it's not worth to automatically test the documentation snippets.
Activity
vikram-dagger commentedon Mar 30, 2023
Can you please point me to this code?
Correct, documented at https://github.com/dagger/dagger/blob/main/docs/STYLE_GUIDE.md#api-playground-embeds
helderco commentedon Mar 30, 2023
Sure!
dagger/internal/mage/docs.go
Lines 46 to 61 in b56aee2
In Python:
dagger/internal/mage/sdk/python.go
Lines 50 to 60 in b56aee2
Where
poe lint-docsis:dagger/sdk/python/pyproject.toml
Lines 82 to 83 in b56aee2
dagger/sdk/python/pyproject.toml
Lines 107 to 108 in b56aee2
Note: I actually started to fix this locally but didn't finish, to deal with other priorities.
Go seems fine because the linting is done for all go files in the repo:
dagger/internal/mage/engine.go
Lines 124 to 131 in b56aee2
Maybe we should do the same for the others. In Python, the linter has slightly different rules for docs, but that should be fine if their path is preserved.
helderco commentedon Mar 30, 2023
Nice, I forgot about that. 🙂
From that guide:
First of all, the extension for python is wrong (
.py). Secondly, snippets for nodejs have been using.mjs. Is that supported? Or even.mts?vikram-dagger commentedon Mar 31, 2023
.pyand.mjsare both supported..mtsis not. I've updated the guide with this info - thanks for pointing it out! #4874gerhard commentedon Mar 31, 2023
Is linting the snippets in docs sufficient to ensure that they run successfully?
Linting is the right way of catching programmatic and stylistic errors, but not testing that the code actually runs. Maybe linting is enough for now, but I am pretty sure that we want some type of integration tests that would show failures - maybe in GitHub Actions - when the code fails. Running these snippets and ensuring that they all exit with
0would be sufficient.I know that my comment is not on topic. I am mostly continuing a conversation that we started with @vikram-dagger on March 28th, 2023.
helderco commentedon Mar 31, 2023
Yes, two separate things. Linting is fast and easy, brings more consistency to the examples and helps us follow good practices for users to copy.
As for tests, that was discussed but don't remember when or where. What I remember is that Andrea (I think) alluded that it was a burden on CI (time and cost continually increasing when adding more docs) and maintainability (keeping tests up to date with the code).
On maintainability, with CUE it was a bit easier since it's declarative, now it's a much harder problem with the multiple languages. As for simply running a script and checking exit code, it's not that simple. For example, many guides use external services that need to be set up with proper keys (GCR, AWS...).
So I believe consensus (at least for now) is that it's not worth to automatically test the documentation snippets.
mircubed commentedon Apr 3, 2023
@vikram-dagger can we close this issue?
helderco commentedon Apr 3, 2023
It's not done.
helderco commentedon Jun 30, 2023
This was fixed in #5351
helderco commentedon Jun 30, 2023
I realized Node.js isn't fixed yet.