44 push :
55 branches :
66 - main
7- - develop
7+ - develop*
88 pull_request :
99 branches :
1010 - main
11- - develop
11+ - develop*
1212 schedule :
13- - cron : ' 0 6 * * *' # run at 6 AM UTC every day
13+ - cron : ' 0 6 * * *'
1414
1515jobs :
1616 test :
17+ name : Test compiler
1718 runs-on : ${{ matrix.os }}
18- continue-on-error : true
1919 strategy :
2020 fail-fast : false
2121 matrix :
@@ -28,13 +28,15 @@ jobs:
2828 uses : actions/checkout@v3
2929
3030 - name : Setup Fortran
31+ continue-on-error : true
3132 id : setup-fortran
3233 uses : ./
3334 with :
3435 compiler : ${{ matrix.compiler }}
3536 version : ${{ matrix.version }}
3637
3738 - name : Check compiler version
39+ if : steps.setup-fortran.outcome == 'success'
3840 shell : bash
3941 env :
4042 FC : ${{ steps.setup-fortran.outputs.fc }}
@@ -46,26 +48,49 @@ jobs:
4648 echo $fcv
4749 echo $ccv
4850
49- fcv=${fcv##* }
50- ccv=${ccv##* }
51+ fcv=$(echo "$ {fcv##*)}" | xargs)
52+ ccv=$(echo "$ {ccv##*)}" | xargs)
5153
5254 [[ $fcv == ${{ matrix.version }}* ]] || (echo "unexpected Fortran compiler version: $fcv"; exit 1)
5355 [[ $ccv == ${{ matrix.version }}* ]] || (echo "unexpected C compiler version: $ccv"; exit 1)
5456
5557 - name : Test compile program (bash)
56- continue-on-error : true
58+ if : steps.setup-fortran.outcome == 'success'
5759 shell : bash
60+ env :
61+ FC : ${{ steps.setup-fortran.outputs.fc }}
62+ CC : ${{ steps.setup-fortran.outputs.cc }}
5863 run : |
59- gfortran -o hw test/ hw.f90
64+ ${{ env.FC }} -o hw hw.f90
6065 output=$(./hw '2>&1')
6166 [[ "$output" == *"hello world"* ]] && echo "$output" || (echo "Unexpected output: $output"; exit 1)
6267
63- - name : Test compile program (pwsh )
64- if : runner.os == 'Windows'
68+ - name : Test compile program (Powershell Core )
69+ if : steps.setup-fortran.outcome == 'success' && runner.os == 'Windows'
6570 shell : pwsh
71+ env :
72+ FC : ${{ steps.setup-fortran.outputs.fc }}
73+ CC : ${{ steps.setup-fortran.outputs.cc }}
74+ run : |
75+ rm hw.exe
76+ ${{ env.FC }} -o hw.exe hw.f90
77+ $output=$(& ".\hw.exe")
78+ if ($output -match "hello world") {
79+ write-output $output
80+ } else {
81+ write-output "unexpected output: $output"
82+ exit 1
83+ }
84+
85+ - name : Test compile program (Powershell Desktop)
86+ if : steps.setup-fortran.outcome == 'success' && runner.os == 'Windows'
87+ shell : powershell
88+ env :
89+ FC : ${{ steps.setup-fortran.outputs.fc }}
90+ CC : ${{ steps.setup-fortran.outputs.cc }}
6691 run : |
6792 rm hw.exe
68- gfortran -o hw.exe test\ hw.f90
93+ ${{ env.FC }} -o hw.exe hw.f90
6994 $output=$(& ".\hw.exe")
7095 if ($output -match "hello world") {
7196 write-output $output
@@ -75,15 +100,141 @@ jobs:
75100 }
76101
77102 - name : Test compile program (cmd)
78- if : runner.os == 'Windows'
103+ if : steps.setup-fortran.outcome == 'success' && runner.os == 'Windows'
79104 shell : cmd
105+ env :
106+ FC : ${{ steps.setup-fortran.outputs.fc }}
107+ CC : ${{ steps.setup-fortran.outputs.cc }}
80108 run : |
81109 del hw.exe
82- gfortran -o hw.exe test\ hw.f90
110+ ${{ env.FC }} -o hw.exe hw.f90
83111 for /f "tokens=* usebackq" %%f in (`.\hw.exe`) do @set "OUTPUT=%%f"
84112 if "%OUTPUT%"=="hello world" (
85- exit 0
113+ echo %OUTPUT%
86114 ) else (
87- echo " unexpected output: %OUTPUT%"
115+ echo unexpected output: %OUTPUT%
88116 exit 1
89117 )
118+
119+ - name : Create compatibility report
120+ shell : bash
121+ run : |
122+ if [[ "${{ steps.setup-fortran.outcome }}" == "success" ]]; then
123+ support="✓"
124+ else
125+ support=""
126+ fi
127+
128+ mkdir compat
129+ prefix="${{ matrix.os }},${{ matrix.compiler }},${{ matrix.version }}"
130+ echo "$prefix,$support" >> "compat/${prefix//,/_}.csv"
131+
132+ - name : Upload compatibility report
133+ uses : actions/upload-artifact@v3
134+ with :
135+ name : compat
136+ path : compat/*.csv
137+
138+ compat :
139+ name : Report compatibility
140+ needs : test
141+ runs-on : ubuntu-latest
142+ steps :
143+
144+ - name : Checkout repository
145+ uses : actions/checkout@v3
146+
147+ - name : Setup Python
148+ uses : actions/setup-python@v4
149+ with :
150+ python-version : 3.9
151+
152+ - name : Install packages
153+ run : |
154+ pip install tabulate pandas
155+
156+ - name : Download reports
157+ uses : actions/download-artifact@v3
158+ with :
159+ name : compat
160+ path : compat
161+
162+ - name : Concatenate reports
163+ run : |
164+ echo "runner,compiler,version,support" > compat_long.csv
165+ cat compat/*.csv >> compat_long.csv
166+
167+ - name : Make wide CSV and MD table
168+ id : merge-reports
169+ shell : python
170+ run : |
171+ import pandas as pd
172+ df = pd.read_csv("compat_long.csv")
173+ df = pd.pivot(df, index="runner", columns="version", values="support")
174+ df = df.sort_values(by=["runner"])
175+ df.to_csv("compat.csv")
176+ with open("compat.md", "w") as file:
177+ file.write(df.to_markdown().replace("nan", ""))
178+
179+ - name : Upload artifacts
180+ uses : actions/upload-artifact@v3
181+ with :
182+ name : compat
183+ path : |
184+ compat.csv
185+ compat.md
186+
187+ - name : Check for changes
188+ id : diff
189+ run : |
190+ if ! [ -f compat.csv ]; then
191+ echo "diff=false" >> $GITHUB_OUTPUT
192+ exit 0
193+ fi
194+
195+ diff=$(git diff compat.csv)
196+ if [[ $diff == "" ]]; then
197+ echo "No changes found"
198+ echo "diff=false" >> $GITHUB_OUTPUT
199+ else
200+ echo "Changes found:"
201+ echo "$diff"
202+ echo "diff=true" >> $GITHUB_OUTPUT
203+ fi
204+
205+ - name : Update README
206+ if : steps.diff.outputs.diff == 'true'
207+ shell : python
208+ run : |
209+ import re
210+ from pathlib import Path
211+ readme_path = Path("README.md")
212+ readme = readme_path.open().read()
213+ with open("compat.md", "r") as compat:
214+ table = ''.join(compat.readlines())
215+ r = re.compile(r'<!\-\- compat starts \-\->.*<!\-\- compat ends \-\->', re.DOTALL)
216+ chunk = '<!-- compat starts -->{}<!-- compat ends -->'.format('\n{}\n'.format(table))
217+ readme_path.open('w').write(r.sub(chunk, readme))
218+
219+ - name : Print README diff
220+ if : steps.diff.outputs.diff == 'true'
221+ run : |
222+ git diff README.md
223+
224+ - name : Create pull request
225+ if : steps.diff.outputs.diff == 'true'
226+ env :
227+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
228+ run : |
229+ git config user.name "github-actions[bot]"
230+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
231+
232+ now=$(date +'%Y-%m-%dT%H-%M-%S')
233+ updated_branch="compat_$now"
234+ default_branch="${{ github.event.repository.default_branch }}"
235+
236+ git switch -c "$updated_branch"
237+ git add compat.csv README.md
238+ git commit -m "Update compatibility matrix"
239+ git push -u origin "$updated_branch"
240+ gh pr create -B "$default_branch" -H "$updated_branch" --title "Update compatibility matrix" --body-file compat.md
0 commit comments