Skip to content

Test

Test #392

Workflow file for this run

name: Test
on:
push:
branches:
- main
- develop*
pull_request:
branches:
- main
- develop*
schedule:
- cron: '0 6 * * *'
jobs:
test:
name: Test compiler
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- ubuntu-20.04
- macos-13
- macos-12
- macos-11
- windows-2022
- windows-2019
toolchain:
- {compiler: gcc, version: 13}
- {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.2'}}
# {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.10'}}
# {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.10'}}
# {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'}}
- {os: windows-2022, toolchain: {compiler: intel, version: '2023.2.0'}}
- {os: windows-2022, toolchain: {compiler: intel, version: '2023.1.0'}}
- {os: windows-2022, toolchain: {compiler: intel, version: '2023.0.0'}}
- {os: windows-2022, toolchain: {compiler: intel, version: '2022.2.0'}}
- {os: windows-2022, toolchain: {compiler: intel, version: '2022.1.0'}}
- {os: windows-2022, toolchain: {compiler: intel-classic, version: '2021.10.0'}}
- {os: windows-2022, toolchain: {compiler: intel-classic, version: '2021.9.0'}}
- {os: windows-2022, toolchain: {compiler: intel-classic, version: '2021.8.0'}}
- {os: windows-2022, toolchain: {compiler: intel-classic, version: '2021.7.0'}}
- {os: windows-2022, toolchain: {compiler: intel-classic, version: '2021.6.0'}}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Fortran
continue-on-error: ${{ matrix.toolchain.compiler == 'gcc' }}
id: setup-fortran
uses: ./
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}
- name: Check compiler version
if: steps.setup-fortran.outcome == 'success'
shell: bash
env:
FC: ${{ steps.setup-fortran.outputs.fc }}
CC: ${{ steps.setup-fortran.outputs.cc }}
run: |
if ([ "$RUNNER_OS" == "Windows" ] && [[ "${{ matrix.toolchain.compiler }}" =~ "intel" ]]); then
# only last line of output captured by command substitution, write to temp file instead
${{ env.FC }} //QV > "$RUNNER_TEMP/${{ env.FC }}.ver" 2>&1
${{ env.CC }} //QV > "$RUNNER_TEMP/${{ env.CC }}.ver" 2>&1
fcv=$(cat "$RUNNER_TEMP/${{ env.FC }}.ver" | head -n 1)
ccv=$(cat "$RUNNER_TEMP/${{ env.CC }}.ver" | head -n 1)
fcv=${fcv#*Version }
fcv=${fcv%% Build*}
ccv=${ccv#*Version }
ccv=${ccv%% Build*}
else
fcv=$(${{ env.FC }} --version | head -n 1)
ccv=$(${{ env.CC }} --version | head -n 1)
fcv=$(echo "$fcv" | grep -woE '[0123456789.]+' | head -n 1)
ccv=$(echo "$ccv" | grep -woE '[0123456789.]+' | head -n 1)
fi
[[ "$fcv" == ${{ matrix.toolchain.version }}* ]] && (echo "found ${{ env.FC }} version: $fcv") || (echo "unexpected ${{ env.FC }} version: $fcv"; exit 1)
[[ "$ccv" == ${{ matrix.toolchain.version }}* ]] && (echo "found ${{ env.CC }} version: $ccv") || (echo "unexpected ${{ env.CC }} version: $ccv"; exit 1)
- name: Test compile program (bash)
if: steps.setup-fortran.outcome == 'success'
shell: bash
env:
FC: ${{ steps.setup-fortran.outputs.fc }}
CC: ${{ steps.setup-fortran.outputs.cc }}
run: |
${{ env.FC }} -o hw hw.f90
output=$(./hw '2>&1')
[[ "$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' }}
shell: pwsh
env:
FC: ${{ steps.setup-fortran.outputs.fc }}
CC: ${{ steps.setup-fortran.outputs.cc }}
run: |
rm hw.exe
${{ env.FC }} -o hw.exe hw.f90
$output=$(& ".\hw.exe")
if ($output -match "hello world") {
write-output $output
} else {
write-output "unexpected output: $output"
exit 1
}
- name: Test compile program (Powershell Desktop)
if: ${{ steps.setup-fortran.outcome == 'success' && runner.os == 'Windows' }}
shell: powershell
env:
FC: ${{ steps.setup-fortran.outputs.fc }}
CC: ${{ steps.setup-fortran.outputs.cc }}
run: |
rm hw.exe
${{ env.FC }} -o hw.exe hw.f90
$output=$(& ".\hw.exe")
if ($output -match "hello world") {
write-output $output
} else {
write-output "unexpected output: $output"
exit 1
}
- name: Test compile program (cmd)
if: ${{ steps.setup-fortran.outcome == 'success' && runner.os == 'Windows' }}
shell: cmd
env:
FC: ${{ steps.setup-fortran.outputs.fc }}
CC: ${{ steps.setup-fortran.outputs.cc }}
run: |
del hw.exe
${{ env.FC }} -o hw.exe hw.f90
for /f "tokens=* usebackq" %%f in (`.\hw.exe`) do @set "OUTPUT=%%f"
if "%OUTPUT%"=="hello world" (
echo %OUTPUT%
) else (
echo unexpected output: %OUTPUT%
exit 1
)
- name: Create compatibility report
shell: bash
run: |
if [[ "${{ steps.setup-fortran.outcome }}" == "success" ]]; then
support="✓"
else
support=""
fi
mkdir compat
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
path: compat/*.csv
compat:
name: Report compatibility
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install packages
run: |
pip install tabulate pandas
- name: Download reports
uses: actions/download-artifact@v3
with:
name: compat
path: compat
- name: Concatenate reports
run: |
echo "runner,compiler,version,support" > compat_long.csv
cat compat/*.csv >> compat_long.csv
- name: Make wide CSV and MD table
id: merge-reports
shell: python
run: |
import pandas as pd
df = pd.read_csv("compat_long.csv")
df = pd.pivot(df, index="runner", columns="version", values="support")
df = df.sort_values(by=["runner"])
df.to_csv("compat.csv")
with open("compat.md", "w") as file:
file.write(df.to_markdown().replace("nan", ""))
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: compat
path: |
compat.csv
compat.md
- name: Check for changes
id: diff
run: |
if ! [ -f compat.csv ]; then
echo "diff=false" >> $GITHUB_OUTPUT
exit 0
fi
diff=$(git diff compat.csv)
if [[ $diff == "" ]]; then
echo "No changes found"
echo "diff=false" >> $GITHUB_OUTPUT
else
echo "Changes found:"
echo "$diff"
echo "diff=true" >> $GITHUB_OUTPUT
fi
- name: Update README
if: ${{ steps.diff.outputs.diff == 'true' && github.event_name == 'push' }}
shell: python
run: |
import re
from pathlib import Path
readme_path = Path("README.md")
readme = readme_path.open().read()
with open("compat.md", "r") as compat:
table = ''.join(compat.readlines())
r = re.compile(r'<!\-\- compat starts \-\->.*<!\-\- compat ends \-\->', re.DOTALL)
chunk = '<!-- compat starts -->{}<!-- compat ends -->'.format('\n{}\n'.format(table))
readme_path.open('w').write(r.sub(chunk, readme))
- name: Print README diff
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' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
now=$(date +'%Y-%m-%dT%H-%M-%S')
updated_branch="compat_$now"
default_branch="${{ github.event.repository.default_branch }}"
git switch -c "$updated_branch"
git add compat.csv README.md
git commit -m "Update compatibility matrix"
git push -u origin "$updated_branch"
gh pr create -B "$default_branch" -H "$updated_branch" --title "Update compatibility matrix" --body-file compat.md