catalog
catalog copied to clipboard
Add a script to help managing embedded scripts externally
The idea of this script is if you have inside your script something like this :
It will replace this #include with the content of python/script.py
This make it easier to write your tasks and use linters/code checkers from your editor on your included script.
This sparked from @afrittoli discussion here https://github.com/tektoncd/catalog/discussions/715
Currently this is a helper so this would be up to the contributor to uses it before commit but i think we can maybe think on how to do this post merge so to be transparent.
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by:
To complete the pull request process, please assign chmouel
You can assign the PR to them by writing /assign @chmouel
in a comment when ready.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve
in a comment
Approvers can cancel approval by writing /approve cancel
in a comment
a script to trigger this and write the output in the right place
how would that work tho?
In main we have the "#include script.py" template files? But users (including ides/tkn hub or even curl people) would expect to be able to run the task directly from main branch, isnt it ?
maybe we can have both, we could have a comment above the script:
which would tell how to replace the script field to the CI jobs at post merge time, it would not matter the script content because the source of truth would be the #include script content.
Maybe that's a bit confusing, so let me rephrase my thinking :
- Dev have task/foo/0.1/task.yaml
- task.yaml has something like this :
steps:
- name: foo
#include foo.py
script : |
#!/usr/bin/env python
print("helo world")
- dev do some changes inside the foo.py and submit as PR,
- test-runner sees the #include and automatically test it with the new content from foo.py in script
- We merge the PR
- A post merge job would replace the script portion with the content from foo.py and commit back to catalog.
This allows user to have the latest task working directly and devs being able to develop into a real file for the script portion.
Let me know if that make sense 🙇🏻
a script to trigger this and write the output in the right place
how would that work tho?
In main we have the "#include script.py" template files? But users (including ides/tkn hub or even curl people) would expect to be able to run the task directly from main branch, isnt it ?
maybe we can have both, we could have a comment above the
script:
which would tell how to replace the script field to the CI jobs at post merge time, it would not matter the script content because the source of truth would be the #include script content.Maybe that's a bit confusing, so let me rephrase my thinking :
- Dev have task/foo/0.1/task.yaml
- task.yaml has something like this :
steps: - name: foo #include foo.py script : | #!/usr/bin/env python print("helo world")
- dev do some changes inside the foo.py and submit as PR,
- test-runner sees the #include and automatically test it with the new content from foo.py in script
- We merge the PR
- A post merge job would replace the script portion with the content from foo.py and commit back to catalog.
I don't like this approach too much because it means that we need two commits to do a change, and in between commits the repo is in an inconsistent state.
This allows user to have the latest task working directly and devs being able to develop into a real file for the script portion.
Let me know if that make sense 🙇🏻
The workflow I had in mind is very much similar to what we have to generated golang files in pipeline
and other repos.
- Dev creates / updates the task in
task/foo/0.1/task.yaml.template
- task.yaml.template has something like this :
steps:
- name: foo
#include foo.py
script : |
#!/usr/bin/env python
print("helo world")
-
Dev creates / updates the script in
task/foo/0.1/foo.py
-
Before committing, dev runs
tools/embed-scripts.sh
, which generatestask/foo/0.1/task.yaml
-
CI runs
tools/embed-scripts.sh
and diffs. If differences are found it fails. Differences could happen if:- if the dev updated the script and did not run the embed tool
- if the dev made changes into the generated
task.yaml
instead of the template / script
-
task/foo/0.1/task.yaml
alone is published to the bundle -
users only ever refer to
task/foo/0.1/task.yaml
The paths / naming might change, we could have the template defined in a subfolder for instance, to "hide" it from users.
@tektoncd/catalog-maintainers it would be nice to move forward on this - can we have a second reviewer?
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale
with a justification.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close
with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen
with a justification.
/lifecycle stale
Send feedback to tektoncd/plumbing.
/remove-lifecycle stale
i didnt see your review @vinamra28 🙇🏻
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale
with a justification.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close
with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen
with a justification.
/lifecycle stale
Send feedback to tektoncd/plumbing.
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten
with a justification.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close
with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen
with a justification.
/lifecycle rotten
Send feedback to tektoncd/plumbing.
Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen
with a justification.
Mark the issue as fresh with /remove-lifecycle rotten
with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen
with a justification.
/close
Send feedback to tektoncd/plumbing.
@tekton-robot: Closed this PR.
In response to this:
Rotten issues close after 30d of inactivity. Reopen the issue with
/reopen
with a justification. Mark the issue as fresh with/remove-lifecycle rotten
with a justification. If this issue should be exempted, mark the issue as frozen with/lifecycle frozen
with a justification./close
Send feedback to tektoncd/plumbing.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
/remove-lifecycle rotten /lifecycle frozen /reopen @chmouel any updates on this?
@vinamra28: Reopened this PR.
In response to this:
/remove-lifecycle rotten /lifecycle frozen /reopen @chmouel any updates on this?
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
@chmouel: The following test failed, say /retest
to rerun them all:
Test name | Commit | Details | Rerun command |
---|---|---|---|
pull-tekton-catalog-integration-tests | 3d32e30e86d477f8447338560d98cbb45492d550 | link | /test pull-tekton-catalog-integration-tests |
Full PR test history. Your PR dashboard.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.
I don't think it's trivial to do this, this will broke the "kuebctl apply -f https://github.com/tektoncd/catalog/path/to/task.yaml" maybe with this TEP which split the structure from the implementation we may be able to achive that but this probably need something extras on the hub end...
I don't think it's trivial to do this, this will broke the "kuebctl apply -f https://github.com/tektoncd/catalog/path/to/task.yaml"
Not necessarily, it depends on how it's implemented. My suggestion would be:
- store in the catalog the template (YAML without the scripts), the script and the rendered version
- the rendered version would be stored in the same location as today
- add a CI job that renders the final task (template + script) and checks that it matches the rendered version in the repo
- provide catalog authors with a script to run to update all rendered tasks
maybe with this TEP which split the structure from the implementation we may be able to achive that but this probably need something extras on the hub end...
Not necessarily, it depends on how it's implemented. My suggestion would be:
store in the catalog the template (YAML without the scripts), the script and the rendered version the rendered version would be stored in the same location as today add a CI job that renders the final task (template + script) and checks that it matches the rendered version in the repo
I think it may be a bit cumbersome for non frequent contributor, we have generation on cli for mans/golden etc.. and it's already a source of annoyances since it's easy to forget to run the command before sending the iteration.
What about CI job commiting to the repo the final rendered version directly to a branch?
alternatively if hub could do this transparently and we say that hub is the "only" trusted source, then we would not have to store the yaml in repo.
provide catalog authors with a script to run to update all rendered tasks