Fortran compiler setup for GitHub actions

Some while ago I created a setup-fortran action for usage in CI with GitHub actions, which apparently is already in use around the Fortran ecosystem. Turns out I never properly announced it in our discourse, so here we go:


Currently the action allows to setup gfortran (gcc), ifort (intel-classic) and ifx (intel):

jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        toolchain: [{compiler: gcc, version: 11}]
        include:
          - os: ubuntu-latest
            toolchain: {compiler: intel, version: '2023.1'}
          - os: ubuntu-latest
            toolchain: {compiler: intel-classic, version: '2021.9'}
          - os: macos-latest
            toolchain: {compiler: intel-classic, version: '2021.9'}

    steps:
      - uses: awvwgk/setup-fortran@v1
        with:
          compiler: ${{ matrix.toolchain.compiler }}
          version: ${{ matrix.toolchain.version }}

      - run: ${{ env.FC }} --version

Support for the GCC toolchains:

runner 5 6 7 8 9 10 11 12
macos-11
macos-12
ubuntu-20.04
ubuntu-22.04
windows-2019
windows-2022

Supported Intel toolchains (the version refers to the compiler version in the output not the version of the oneapi release, read more about this here):

runner compiler version
ubuntu-* intel 2023.1, 2023.0,
2022.2.1, 2022.2, 2022.1, 2022.0,
2021.4, 2021.3, 2021.2, 2021.1.2, 2021.1
ubuntu-* intel-classic 2021.9, 2021.8,
2021.7.1, 2021.7, 2021.6, 2021.5,
2021.4, 2021.3, 2021.2, 2021.1.2, 2021.1
macos-* intel-classic 2021.9, 2021.8,
2021.7.1, 2021.7, 2021.6, 2021.5,
2021.4, 2021.3, 2021.2, 2021.1

Looking for help with other toolchains, like

23 Likes

This is awesome - exactly what we need to stress test the fpm system libraries implementation!

Thanks, it is great. It would be nice to have something similar on gitlab too.

I’m not much of a GitLab user, but the setup steps are mainly collected in one big script at setup-fortran/setup-fortran.sh at main · awvwgk/setup-fortran · GitHub and should be reusable. There are some GitHub actions specific steps like making the Intel setup persistent between workflow steps, which could be guarded by checking for GHA specific env vars. Is there an equivalent to custom GHA for providing steps in a GitLab pipeline?

Hello. Thanks @awvwgk for sharing the setup-fortran action. I’m using in my workflows and it has worked great.

Since this morning I am seeing worfkflows failing with erorr: Error: Unable to resolve action. Repository not found: awvwgk/setup-fortran. Posting here to check fi this is a general problem. Has the action been migrated? The usage instructions on github marketplace have not changed for what I can tell.

The repo moved yesterday to GitHub - fortran-lang/setup-fortran: GitHub action to setup Fortran compiler and toolchain, and it seems like the GH Action doesn’t automatically redirect. Does it work if you change the “awvwgk” part with “fortran-lang”?

1 Like

@milancurcic I saw in the repo this comment:

Note: version 13 of the GNU toolchain is not yet available on Windows.

Does it use the mingw 64 tool chain? if so, version 13.2 is already available
https://packages.msys2.org/package/mingw-w64-x86_64-gcc-fortran

And I guess the readme should be updated as it still points to “awvwgk/setup-fortran@v1” in the “Usage” section

Thanks for confirming @milancurcic . Indeed I had tried replacing with fortran-lang/ and it works. Does it help if I send a PR to update the usage note?

1 Like

Hi -

Thanks, this looks neat. I’m curious about the use with gfortran? For Github runners based on Ubuntu 22.04, gfortran-10, -11, and -12 are available default (see this example).

Another possible compiler for which support would be useful is the Nvidia HPC toolkit (i.e. nvfortran). I’m using my own home-built containers for this and the Intel compilers. A Github action that let me skip the containers is/would be the bomb.

In addition to fortran-lang/setup-fortran (thank @awvwgk and contributors), I use the following scripts for the GitHub Actions of PRIMA to install Fortran compilers on GitHub-hosted runners.

I also have scripts to install sunf95 and g95 on GitHub-hosted runners even though these compilers are discontinued.

The scripts are naive (e.g., call apt install to install oneapi), and they may take a few minutes to run, which is tolerable in my case.

Here is a concrete workflow that applies them:

https://github.com/s-prima/prima/blob/main/.github/workflows/lint_hosted.yml#L87-L117,

where the Fortran source code of PRIMA is compiled using eight compilers (gfortran, ifort, ifx, nvfortran, AOCC flang, Classic flang, sunf95, and g95) with strict debug options to make sure that no error (of course) or warning is raised (PRIMA does not tolerate any warning).

N.B.: Do not use the scripts on your own computers before examining them. They may make unwanted changes to your system.

4 Likes

Just would like to add that with multiarch images one can run in github Actions also ARM Fortran@aarch64 and the free version of IBM XL@ppc64le.

1 Like