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

Add "anyci/conditional_exec.py" addon #59

Open
jcfr opened this issue Nov 14, 2017 · 2 comments
Open

Add "anyci/conditional_exec.py" addon #59

jcfr opened this issue Nov 14, 2017 · 2 comments

Comments

@jcfr
Copy link
Contributor

jcfr commented Nov 14, 2017

This add-on will be adapted from https://stackoverflow.com/a/33012308/1539918 and will allow to conditionally execute a command based on the value of env. variable.

Motivation

Perform conditional execution of command with tox. See NeurodataWithoutBorders/pynwb#245

Usage

Usage:
  python conditional_exec.py ENVVAR1==ENVVALUE1 ... -- command arg1 ...

Example of use:

ci_addons --install ../addons
python ../addons/anyci/conditional_exec.py DO_COVERAGE==true -- coverage run --source src test.py --pynwb
python ../addons/anyci/conditional_exec.py DO_COVERAGE==true -- codecov -F pynwb
@thewtex
Copy link
Member

thewtex commented Nov 14, 2017

@jcfr I think this would be useful 👍 . Environmental variables are a standard, cross-platform way for passing state / settings in these CI systems.

A tweak to the syntax that would be helpful:

  python ../addons/anyci/conditional_exec.py DO_COVERAGE -- codecov -F pynwb

Where DO_COVERAGE is evaluated, and used if "truthy". Expression evaluation gets tricky. If supported, it should probably be based on Python expressions so it is cross platform. In this case true -> True.

@dorukozturk
Copy link

Since tox have more of a "declarative" syntax it is not really feasible to do condtionals based on environment variables. Instead creating a new environment in tox and selecting that environment on the appropriate platform (such as CI or local) with -e flag, is easier. See this as an example implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants