Sourcing bash file to set environment variables (Linux)

I am trying to migrate from Travis to GitHub Actions for CI with the OpenFOAM code base with Ubuntu 20.04 as OS in Actions.

OpenFOAM uses a bash file to set up its own environment ( OpenFOAM-dev/bashrc at f60252ff7b4090de1d5bbead1736a0dda76fd634 · OpenFOAM/OpenFOAM-dev · GitHub ), however, when trying to execute this script immediately after installing the OpenFOAM package using apt-get, the process terminates with exit code 1, without further details.

Is there a way to use scripts like these without having to modify them as shown here Workflow commands for GitHub Actions - GitHub Docs , which would be quite impractical considering the complexity of the script?

As a reference, in Travis CI, this works by sourcing the file directly with:

source /usr/lib/openfoam/openfoam2012/etc/bashrc

in the “before_script” section.

Each run step gets its own shell instance, so if you want the sourced environment to be available without modifications you need to run anything that needs it in the same step. Wrapping everything in one script file may be the easiest solution if you need to run more than one or two commands after sourcing.

Ok. I have put all the instructions in the same step. I still get the process terminating with exit code 1.

Is there a way to have a more verbose output so that I can troubleshoot?

I don’t know, that’d have to be part of the script. The log should show you any output (stdout, stderr) that the script produces.

Thanks. The raw log is not descriptive:

I found a workaround though: OpenFOAM provides a preconfigured shell. Using that custom shell seems to work:

 /usr/bin/openfoam2012 <command 1>
 /usr/bin/openfoam2012 <command 2>
 ...
1 Like

Nice! In that case you could even set that as the shell for a run step, see Custom shell. :slightly_smiling_face:

Thanks! I’ll clean up the settings with that.

1 Like