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

Support new flag: opam env --bare for use with GitHub actions #5791

Open
shayne-fletcher opened this issue Jan 22, 2024 · 3 comments · May be fixed by #6316
Open

Support new flag: opam env --bare for use with GitHub actions #5791

shayne-fletcher opened this issue Jan 22, 2024 · 3 comments · May be fixed by #6316

Comments

@shayne-fletcher
Copy link

shayne-fletcher commented Jan 22, 2024

Environment variables can be made available to steps in a GitHub workflow job by writing the variable definitions to the $GITHUB_ENV file.

  • opam env prints an environment in terms of bash commands
  • opam env --sexp prints an environment as an s-expression

If there existed a flag --bare (say) that printed an environment as exactlyVAR=VALUE lines e.g.

  OPAM_SWITCH_PREFIX=/home/foo-user/.opam/default
  CAML_LD_LIBRARY_PATH=/home/foo-user/.opam/default/lib/ocaml/stublibs:/home/foo-user/.opam/default/lib/ocaml
  ...

that is, equivalent to

  opam env | sed -e "s/ export .*//g" -e "s/'//g" -e "s/\;//g"

then, a github action to configure an OPAM environment could be very simply written as just

  - run: opam env --bare >> $GITHUB_ENV
@kit-ty-kate
Copy link
Member

the feature request sound fine to me on its own, however for its use-case opam exec -- ... is most commonly used instead. How does that compare in terms of usability/complexity compared to using $GITHUB_ENV?

@shayne-fletcher
Copy link
Author

shayne-fletcher commented Jan 22, 2024

significantly less convenient for us. using $GITHUB_ENV we can configure all subsequent job shells to implicitly be OPAM environments in the same way users are encouraged to add eval $(opam env) to their bash initialization file. set it and forget it.

@kit-ty-kate
Copy link
Member

fair enough. We don’t have time to implement it until after the final release of opam 2.2.0 and even after larger works will most likely take priority but at least we’ll be more free to look at it.
If you want to have a stab at it (e.g. following the path of the --sexp option) you’re most than welcome to in the meantime

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

Successfully merging a pull request may close this issue.

3 participants