Cache Open MPI Build?


I’m still at the neophyte stage of GitHub Actions, but I’m trying to learn. My current issue is I want to add CI for a project that uses MPI (and Fortran).

Now, being lazy I did try a apt install openmpi-bin libopenmpi-dev for my test, but it fails to work for me. Why? The Fortran I need to use (gfortran-9) was not the gfortran that the Open MPI package was built with. Thus use mpi fails.

Now, I have no problem building Open MPI (I’ve done it often), but it’s a long tedious build and as such I’d like to do it once rather than every time CI is spun up. I previously managed to hack my way into getting TravisCI to do this in ~/local and then had Travis cache ~/local.

Is something like this possible with GitHub Actions? That is, pay the price once to build Open MPI with gfortran-9 and then use actions/cache to pull this pre-build Open MPI? I know I could roll my own Docker image to have this, but I want to see if I can learn caching instead.


Sure, you can use the cache action to do that in your workflows. The caching feature on GitHub Actions is designed to speed up time to get the outputs or downloaded dependencies that often reused in the workflow runs.

Generally, when you want to reuse dependencies that don’t change often between jobs or workflow runs, you can use caching.

To view more detailed information about caching, please see the official documentation below: