Browse Source

Added GitHubActionsVirtualEnvs

The generators will create GitHub Actions scripts which will set
the environment for the next steps.

Usage as follows in the commandline:

```yml
- name: Conan install
  run: conan install . -g GitHubActionsVirtualRunEnv
- name: Activate env
  run: <conan_generator_dir>/activate_github_actions_runenv.sh
- name:
  run: echo $PATH
```

Contributes to CURA-9177_Fix_CI_CD
fix_tk_recipe_env_info
j.spijker@ultimaker.com 4 years ago committed by Jelle Spijker
parent
commit
1039fa6044
No known key found for this signature in database
GPG Key ID: 6662DC033BE6B99A
  1. 27
      generators/GitHubActionsBuildEnv.py
  2. 27
      generators/GitHubActionsRunEnv.py

27
generators/GitHubActionsBuildEnv.py

@ -0,0 +1,27 @@
from pathlib import Path
from jinja2 import Template
from conan.tools.env import VirtualBuildEnv
from conans.model import Generator
class GitHubActionsBuildEnv(Generator):
@property
def filename(self):
filepath = str(Path(self.conanfile.generators_folder).joinpath("activate_github_actions_buildenv"))
if self.conanfile.settings.get_safe("os") == "Windows":
if self.conanfile.conf.get("tools.env.virtualenv:powershell", check_type = bool):
filepath += ".ps1"
else:
filepath += ".bat"
else:
filepath += ".sh"
return filepath
@property
def content(self):
template = Template("""{% for k, v in envvars.items() %}echo "{{ k }}={{ v }}" >> $GITHUB_ENV\n{% endfor %}""")
envvars = self.conanfile.buildenv_info.vars(self.conanfile)
return template.render(envvars = envvars)

27
generators/GitHubActionsRunEnv.py

@ -0,0 +1,27 @@
from pathlib import Path
from jinja2 import Template
from conan.tools.env import VirtualRunEnv
from conans.model import Generator
class GitHubActionsRunEnv(Generator):
@property
def filename(self):
filepath = str(Path(self.conanfile.generators_folder).joinpath("activate_github_actions_runenv"))
if self.conanfile.settings.get_safe("os") == "Windows":
if self.conanfile.conf.get("tools.env.virtualenv:powershell", check_type = bool):
filepath += ".ps1"
else:
filepath += ".bat"
else:
filepath += ".sh"
return filepath
@property
def content(self):
template = Template("""{% for k, v in envvars.items() %}echo "{{ k }}={{ v }}" >> $GITHUB_ENV\n{% endfor %}""")
envvars = self.conanfile.runenv_info.vars(self.conanfile, scope = "run")
return template.render(envvars = envvars)
Loading…
Cancel
Save