diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 567a066..23513fd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,23 +20,66 @@ jobs: fail-fast: false matrix: os: [ubuntu-22.04, ubuntu-20.04, macos-12, macos-11, windows-2022, windows-2019] - compiler: [gcc] - version: [12, 11, 10, 9, 8, 7, 6, 5] + toolchain: + - {compiler: gcc, version: 12} + - {compiler: gcc, version: 11} + - {compiler: gcc, version: 10} + - {compiler: gcc, version: 9} + - {compiler: gcc, version: 8} + - {compiler: gcc, version: 7} + - {compiler: gcc, version: 6} + # {compiler: gcc, version: 5} + include: + - {os: ubuntu-22.04, toolchain: {compiler: intel, version: '2023.1'}} + # {os: ubuntu-22.04, toolchain: {compiler: intel, version: '2023.0'}} + - {os: ubuntu-22.04, toolchain: {compiler: intel, version: '2022.2.1'}} + # {os: ubuntu-22.04, toolchain: {compiler: intel, version: '2022.2'}} + # {os: ubuntu-22.04, toolchain: {compiler: intel, version: '2022.1'}} + # {os: ubuntu-22.04, toolchain: {compiler: intel, version: '2022.0'}} + - {os: ubuntu-22.04, toolchain: {compiler: intel, version: '2021.4'}} + # {os: ubuntu-22.04, toolchain: {compiler: intel, version: '2021.3'}} + # {os: ubuntu-22.04, toolchain: {compiler: intel, version: '2021.2'}} + # {os: ubuntu-22.04, toolchain: {compiler: intel, version: '2021.1.2'}} + # {os: ubuntu-22.04, toolchain: {compiler: intel, version: '2021.1'}} + + - {os: ubuntu-22.04, toolchain: {compiler: intel-classic, version: '2021.9'}} + # {os: ubuntu-22.04, toolchain: {compiler: intel-classic, version: '2021.8'}} + - {os: ubuntu-22.04, toolchain: {compiler: intel-classic, version: '2021.7.1'}} + # {os: ubuntu-22.04, toolchain: {compiler: intel-classic, version: '2021.7'}} + # {os: ubuntu-22.04, toolchain: {compiler: intel-classic, version: '2021.6'}} + # {os: ubuntu-22.04, toolchain: {compiler: intel-classic, version: '2021.5'}} + - {os: ubuntu-22.04, toolchain: {compiler: intel-classic, version: '2021.4'}} + # {os: ubuntu-22.04, toolchain: {compiler: intel-classic, version: '2021.3'}} + # {os: ubuntu-22.04, toolchain: {compiler: intel-classic, version: '2021.2'}} + # {os: ubuntu-22.04, toolchain: {compiler: intel-classic, version: '2021.1.2'}} + # {os: ubuntu-22.04, toolchain: {compiler: intel-classic, version: '2021.1'}} + + - {os: macos-12, toolchain: {compiler: intel-classic, version: '2021.9'}} + # {os: macos-12, toolchain: {compiler: intel-classic, version: '2021.8'}} + - {os: macos-12, toolchain: {compiler: intel-classic, version: '2021.7.1'}} + # {os: macos-12, toolchain: {compiler: intel-classic, version: '2021.7'}} + # {os: macos-12, toolchain: {compiler: intel-classic, version: '2021.6'}} + # {os: macos-12, toolchain: {compiler: intel-classic, version: '2021.5'}} + - {os: macos-12, toolchain: {compiler: intel-classic, version: '2021.4'}} + # {os: macos-12, toolchain: {compiler: intel-classic, version: '2021.3'}} + # {os: macos-12, toolchain: {compiler: intel-classic, version: '2021.2'}} + # {os: macos-12, toolchain: {compiler: intel-classic, version: '2021.1'}} + steps: - name: Checkout repository uses: actions/checkout@v3 - name: Setup Fortran - continue-on-error: true + continue-on-error: ${{ matrix.toolchain.compiler == 'gcc' }} id: setup-fortran uses: ./ with: - compiler: ${{ matrix.compiler }} - version: ${{ matrix.version }} + compiler: ${{ matrix.toolchain.compiler }} + version: ${{ matrix.toolchain.version }} - name: Check compiler version - if: steps.setup-fortran.outcome == 'success' + if: ${{ steps.setup-fortran.outcome == 'success' }} shell: bash env: FC: ${{ steps.setup-fortran.outputs.fc }} @@ -48,14 +91,14 @@ jobs: echo $fcv echo $ccv - fcv=$(echo "${fcv##*)}" | xargs) - ccv=$(echo "${ccv##*)}" | xargs) + fcv=$(echo "$fcv" | grep -woE '[0123456789.]+' | head -n 1) + ccv=$(echo "$ccv" | grep -woE '[0123456789.]+' | head -n 1) - [[ $fcv == ${{ matrix.version }}* ]] || (echo "unexpected Fortran compiler version: $fcv"; exit 1) - [[ $ccv == ${{ matrix.version }}* ]] || (echo "unexpected C compiler version: $ccv"; exit 1) + [[ $fcv == ${{ matrix.toolchain.version }}* ]] || (echo "unexpected Fortran compiler version: $fcv"; exit 1) + [[ $ccv == ${{ matrix.toolchain.version }}* ]] || (echo "unexpected C compiler version: $ccv"; exit 1) - name: Test compile program (bash) - if: steps.setup-fortran.outcome == 'success' + if: ${{ steps.setup-fortran.outcome == 'success' }} shell: bash env: FC: ${{ steps.setup-fortran.outputs.fc }} @@ -66,7 +109,7 @@ jobs: [[ "$output" == *"hello world"* ]] && echo "$output" || (echo "Unexpected output: $output"; exit 1) - name: Test compile program (Powershell Core) - if: steps.setup-fortran.outcome == 'success' && runner.os == 'Windows' + if: ${{ steps.setup-fortran.outcome == 'success' && runner.os == 'Windows' }} shell: pwsh env: FC: ${{ steps.setup-fortran.outputs.fc }} @@ -83,7 +126,7 @@ jobs: } - name: Test compile program (Powershell Desktop) - if: steps.setup-fortran.outcome == 'success' && runner.os == 'Windows' + if: ${{ steps.setup-fortran.outcome == 'success' && runner.os == 'Windows' }} shell: powershell env: FC: ${{ steps.setup-fortran.outputs.fc }} @@ -100,7 +143,7 @@ jobs: } - name: Test compile program (cmd) - if: steps.setup-fortran.outcome == 'success' && runner.os == 'Windows' + if: ${{ steps.setup-fortran.outcome == 'success' && runner.os == 'Windows' }} shell: cmd env: FC: ${{ steps.setup-fortran.outputs.fc }} @@ -126,10 +169,11 @@ jobs: fi mkdir compat - prefix="${{ matrix.os }},${{ matrix.compiler }},${{ matrix.version }}" + prefix="${{ matrix.os }},${{ matrix.toolchain.compiler }},${{ matrix.toolchain.version }}" echo "$prefix,$support" >> "compat/${prefix//,/_}.csv" - name: Upload compatibility report + if: ${{ matrix.toolchain.compiler == 'gcc' }} uses: actions/upload-artifact@v3 with: name: compat @@ -206,7 +250,7 @@ jobs: fi - name: Update README - if: steps.diff.outputs.diff == 'true' && github.event_name == 'push' + if: ${{ steps.diff.outputs.diff == 'true' && github.event_name == 'push' }} shell: python run: | import re @@ -220,12 +264,12 @@ jobs: readme_path.open('w').write(r.sub(chunk, readme)) - name: Print README diff - if: steps.diff.outputs.diff == 'true' && github.event_name == 'push' + if: ${{ steps.diff.outputs.diff == 'true' && github.event_name == 'push' }} run: | git diff README.md - name: Create pull request - if: steps.diff.outputs.diff == 'true' && github.event_name == 'push' + if: ${{ steps.diff.outputs.diff == 'true' && github.event_name == 'push' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | diff --git a/README.md b/README.md index 302db9a..20c6c37 100644 --- a/README.md +++ b/README.md @@ -29,24 +29,39 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] + toolchain: + - {compiler: gcc, version: 11} + - {compiler: intel-classic, version: '2021.9'} + include: + - os: ubuntu-latest + toolchain: {compiler: intel, version: '2023.1'} + exclude: + - os: windows-latest + toolchain: {compiler: intel-classic, version: '2021.9'} steps: - - uses: awvwgk/setup-fortran@main - id: setup-fortran - with: - compiler: gcc - version: 11 - - - run: ${{ env.FC }} --version - env: - FC: ${{ steps.setup-fortran.outputs.fc }} + - uses: awvwgk/setup-fortran@v1 + id: setup-fortran + with: + compiler: ${{ matrix.toolchain.compiler }} + version: ${{ matrix.toolchain.version }} + + - run: ${{ env.FC }} --version + env: + FC: ${{ steps.setup-fortran.outputs.fc }} ``` ## Options -- *compiler*: Compiler toolchain to setup, available options are *gcc* -- *version*: Version of the compiler toolchain, available options for *gcc* are *5-12* +- *compiler*: Compiler toolchain to setup, available options are + - *gcc* (for `gfortran`) + - *intel* (for `ifx`) + - *intel-classic* (for `ifort`) +- *version*: Version of the compiler toolchain, available options are + - *5–12* for *gcc* + - *2021.1–2023.1* for *intel* + - *2021.1–2021.9* for *intel-classic* ## Outputs @@ -83,6 +98,15 @@ Support for the GCC toolchain varies across GitHub-hosted runner images. +Supported Intel toolchains: + +| 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 | + + ## License Licensed under the Apache License, Version 2.0 (the “License”); diff --git a/action.yml b/action.yml index c8e1d9b..9605ce1 100644 --- a/action.yml +++ b/action.yml @@ -34,30 +34,17 @@ runs: case $compiler in gcc) version=${VERSION:-11} + install_gcc $platform ;; - *) - exit 1 - ;; - esac - - case $platform in - linux*) - install_gcc_apt - ;; - darwin*) - install_gcc_brew - ;; - mingw*) - install_gcc_choco - ;; - msys*) - install_gcc_choco + intel-classic) + version=${VERSION:-2023.1.0} + install_intel $platform true ;; - cygwin*) - install_gcc_choco + intel) + version=${VERSION:-2023.1.0} + install_intel $platform false ;; *) - echo "Unsupported platform: $platform" exit 1 ;; esac diff --git a/setup-fortran.sh b/setup-fortran.sh index 1378933..3a59907 100755 --- a/setup-fortran.sh +++ b/setup-fortran.sh @@ -2,6 +2,19 @@ set -ex +require_fetch() +{ + if command -v curl > /dev/null 2>&1; then + fetch="curl -L" + elif command -v wget > /dev/null 2>&1; then + fetch="wget -O -" + else + echo "No download mechanism found. Install curl or wget first." + exit 1 + fi +} + + install_gcc_brew() { brew install gcc@${version} @@ -109,15 +122,7 @@ install_gcc_winlibs() ;; esac - if command -v curl > /dev/null 2>&1; then - fetch="curl -L" - elif command -v wget > /dev/null 2>&1; then - fetch="wget -O -" - else - echo "No download mechanism found. Install curl or wget first." - exit 1 - fi - + require_fetch $fetch "$repo/$tag/$zip" > gcc.zip unzip -qo gcc.zip "mingw64/bin/*" -d / @@ -126,3 +131,253 @@ install_gcc_winlibs() export CC="gcc" export CXX="g++" } + +install_gcc() +{ + local platform=$1 + case $platform in + linux*) + install_gcc_apt + ;; + darwin*) + install_gcc_brew + ;; + mingw*) + install_gcc_choco + ;; + msys*) + install_gcc_choco + ;; + cygwin*) + install_gcc_choco + ;; + *) + echo "Unsupported platform: $platform" + exit 1 + ;; + esac +} + +export_intel_vars() +{ + cat >> $GITHUB_ENV <> $GITHUB_PATH + done +} + +intel_version_map_l() +{ + local actual_version=$1 + local classic=$2 + if $classic; then + case $actual_version in + 2021.9.0 | 2021.9) + version=2023.1.0 + ;; + 2021.8.0 | 2021.8) + version=2023.0.0 + ;; + 2021.7.1) + version=2022.2.1 + ;; + 2021.7.0 | 2021.7) + version=2022.2.0 + ;; + 2021.6.0 | 2021.6) + version=2022.1.0 + ;; + 2021.5.0 | 2021.5) + version=2022.0.2 + # version=2022.0.1 + ;; + 2021.4 | 2021.3 | 2021.2) + version=$actual_version.0 + ;; + 2021.1) + version=2021.1.1 + ;; + *) + version=$actual_version + ;; + esac + else + case $actual_version in + 2022.0.0 | 2022.0) + version=2022.0.2 + ;; + 2023.1 | 2023.0 | 2022.2 | 2022.1 | 2021.4 | 2021.3 | 2021.2) + version=$actual_version.0 + ;; + 2021.1) + version=2021.1.1 + ;; + *) + version=$actual_version + ;; + esac + fi +} + +intel_version_map_m() +{ + local actual_version=$1 + case $actual_version in + 2021.9.0 | 2021.9) + version=2023.1.0 + ;; + 2021.8.0 | 2021.8) + version=2023.0.0 + ;; + 2021.7.1) + version=2022.3.1 + ;; + 2021.7.0 | 2021.7) + version=2022.3.0 + ;; + 2021.6.0 | 2021.6) + version=2022.2.0 + ;; + 2021.5.0 | 2021.5) + version=2022.1.0 + ;; + 2021.4 | 2021.3 | 2021.2 | 2021.1) + version=$actual_version.0 + ;; + *) + version=$actual_version + ;; + esac +} + +install_intel_apt() +{ + local version=$1 + local classic=$2 + intel_version_map_l $version $classic + + require_fetch + local _KEY="GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB" + $fetch https://apt.repos.intel.com/intel-gpg-keys/$_KEY > $_KEY + sudo apt-key add $_KEY + rm $_KEY + unset $_KEY + echo "deb https://apt.repos.intel.com/oneapi all main" \ + | sudo tee /etc/apt/sources.list.d/oneAPI.list + sudo apt-get update + + sudo apt-get install \ + intel-oneapi-compiler-{fortran,dpcpp-cpp-and-cpp-classic}-$version + + source /opt/intel/oneapi/setvars.sh + export_intel_vars + + if $classic; then + export FC="ifort" + export CC="icc" + export CXX="icpc" + else + export FC="ifx" + export CC="icx" + export CXX="icpx" + fi +} + +install_intel_dmg() +{ + local version=$1 + intel_version_map_m $version + + case $version in + 2021.1.0) + MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17426/m_BaseKit_p_2021.1.0.2427.dmg + MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17398/m_HPCKit_p_2021.1.0.2681.dmg + ;; + 2021.2.0) + MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17714/m_BaseKit_p_2021.2.0.2855.dmg + MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17643/m_HPCKit_p_2021.2.0.2903.dmg + ;; + 2021.3.0) + MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17969/m_BaseKit_p_2021.3.0.3043.dmg + MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/17890/m_HPCKit_p_2021.3.0.3226.dmg + ;; + 2021.4.0) + MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18256/m_BaseKit_p_2021.4.0.3384.dmg + MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18242/m_HPCKit_p_2021.4.0.3389.dmg + ;; + 2022.1.0) + MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18342/m_BaseKit_p_2022.1.0.92.dmg + MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18341/m_HPCKit_p_2022.1.0.86.dmg + ;; + 2022.2.0) + MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/18675/m_BaseKit_p_2022.2.0.226_offline.dmg + MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/18681/m_HPCKit_p_2022.2.0.158_offline.dmg + ;; + 2022.3.0) + MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18865/m_BaseKit_p_2022.3.0.8743.dmg + MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18866/m_HPCKit_p_2022.3.0.8685.dmg + ;; + 2022.3.1) + MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18971/m_BaseKit_p_2022.3.1.17244.dmg + MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/18977/m_HPCKit_p_2022.3.1.15344.dmg + ;; + 2023.0.0) + MACOS_BASEKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/19080/m_BaseKit_p_2023.0.0.25441.dmg + MACOS_HPCKIT_URL=https://registrationcenter-download.intel.com/akdlm/irc_nas/19086/m_HPCKit_p_2023.0.0.25440.dmg + ;; + 2023.1.0) + MACOS_BASEKIT_URL=https:/registrationcenter-download.intel.com/akdlm/IRC_NAS/2516a0a0-de4d-4f3d-9e83-545b32127dbb/m_BaseKit_p_2023.1.0.45568.dmg + MACOS_HPCKIT_URL=https:/registrationcenter-download.intel.com/akdlm/IRC_NAS/a99cb1c5-5af6-4824-9811-ae172d24e594/m_HPCKit_p_2023.1.0.44543.dmg + ;; + *) + exit 1 + ;; + esac + + require_fetch + $fetch $MACOS_HPCKIT_URL > m_HPCKit.dmg + hdiutil attach m_HPCKit.dmg + sudo /Volumes/"$(basename "$MACOS_HPCKIT_URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s \ + --action install \ + --eula=accept \ + --continue-with-optional-error=yes \ + --log-dir=. + hdiutil detach /Volumes/"$(basename "$MACOS_HPCKIT_URL" .dmg)" -quiet + rm m_HPCKit.dmg + + source /opt/intel/oneapi/setvars.sh + export_intel_vars + + export FC="ifort" + export CC="icc" + export CXX="icpc" +} + +install_intel() +{ + local platform=$1 + local classic=$2 + case $platform in + linux*) + install_intel_apt $version $classic + ;; + darwin*) + install_intel_dmg $version + ;; + *) + echo "Unsupported platform: $platform" + exit 1 + ;; + esac +}