-
-
Notifications
You must be signed in to change notification settings - Fork 656
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
Add a "setup:" setting to allow running setup scripts before any command? #204
Comments
Hi @jooola, Can you explain more why you think this'd be useful? Perhaps an example... |
When developing a Python project within a Virtual environment with all its dependencies, we always need to activate this virtual environment in order to run project tasks like testing, linting, building. To set up the environment by hand, we run the following commands (where python3 -m venv venv
source venv/bin/activate
pip -q install --upgrade -r requirements.txt Since the The option should also all to run all the dependencies in the same shell. Sorry for my previous message, I clearly wasn't describing my problem enough. |
You can do this today as a multi-line command, but you need to somehow duplicate the setup of venv to each command, e.g. as a template variable, or just copy-paste, which ever is easier. |
It would be something like this I guess ? vars:
VENV: |-
test -d venv || python3 -m venv venv
source venv/bin/activate
tasks:
setup:
cmds:
- |
{{.VENV}}
pip -q install --upgrade -r requirements.txt
But dependencies inheritance cannot work in this case, that was the point of chaining dependencies. But this work around could work, I'll try it out. Thanks |
👍 Remember to also add a vars:
VENV: |-
test -d venv || python3 -m venv venv
source venv/bin/activate
tasks:
setup:
cmds:
- |
set -e
{{.VENV}}
pip -q install --upgrade -r requirements.txt |
No it can't. Dependencies, or any other cmd, can never change the environment in task, which is what would be needed for that to work. The environment now, is evaluated/generated from scratch every-time before a task is run. At an early stage of task, there was a |
As @smyrman said, multi-line strings should solve this use case. The downside is that you have to concat the setup stage in each needed command. Maybe we could add a version: '2'
setup:
- set -e
- rbenv init
tasks:
# ... Sharing state between command calls for a single task would be possible, but it'd be likely confusing. |
This comment was marked as off-topic.
This comment was marked as off-topic.
@stephencheng Interesting idea, worth studying the possibility. Thanks for sharing. |
This is ideal but while we're waiting on this feature is there a file like |
@ProfessorManhattan Interesting idea, but no, we do not support that. |
I really like the idea to allow a configurable list of commands to run before each shell task, |
Good point Sorin
…On Tue, May 24, 2022 at 2:52 AM Sorin Sbarnea ***@***.***> wrote:
I really like the idea to allow a configurable list of commands to run
before each shell task, set -e being an obvious use case.
—
Reply to this email directly, view it on GitHub
<#204 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOJRHXKRV6A5CMUACUJFTIDVLR4CTANCNFSM4HNPTDIA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
Regards,
Brian Zalewski
(412) 345-3338
|
Idea: just like the |
#1115 is a complement to this. Both should probably be implemented together. |
tasks:
foo:
cmds:
- echo "do something"
preconditions:
- op document get "TLS Cert" --output=./test.crt --force && step certificate needs-renewal --expires-in 48h --bundle test.crt This leaves a |
I'm looking for a tool that can run
source venv/bin/activate
and run the commands in that same shell. It is not cleanly doable using make, and so I tried Task.It appears we can't do this using Task. Is there a way to have a workaround or add an option to run all commands in the same shell ?
The text was updated successfully, but these errors were encountered: