forked from fortran-lang/setup-fortran
-
Notifications
You must be signed in to change notification settings - Fork 0
227 lines (200 loc) · 6.98 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
name: Test
# Workflow has two modes: assert and report
# Push and pull request run in assert mode.
# Schedule and dispatch run in report mode.
on:
push:
paths-ignore:
- '**.md'
tags-ignore:
- v**
pull_request:
branches:
- main
- develop*
- math
paths-ignore:
- '**.md'
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:
jobs:
options:
name: Set options
runs-on: ubuntu-latest
outputs:
mode: ${{ steps.mode.outputs.mode }}
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set mode
id: mode
run: |
trigger=${{ github.event_name }}
if [[ "$trigger" == "schedule" ]] || [[ "$trigger" == "workflow_dispatch" ]]; then
echo "mode=report" >> "$GITHUB_OUTPUT"
else
echo "mode=assert" >> "$GITHUB_OUTPUT"
fi
- name: Set matrix
working-directory: .github/compat
id: matrix
run: |
mode=${{ steps.mode.outputs.mode }}
if [[ "$mode" == "report" ]]; then
yq -o json matrix.yml > matrix.json
else
python matrix_json_from_csv.py "long_compat.csv" "matrix.json"
fi
matrix=$(cat matrix.json | jq -r tostring)
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
# debugging
- name: Show matrix
run: echo "${{ toJSON(fromJSON(steps.matrix.outputs.matrix)) }}"
test:
name: Test
needs: options
runs-on: ${{ matrix.os }}
continue-on-error: ${{ needs.options.outputs.mode == 'report' }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.options.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Fortran
id: setup-fortran
continue-on-error: ${{ needs.options.outputs.mode == 'report' }}
uses: ./
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}
install_mkl: true
# - name: Debug with tmate
# uses: mxschmitt/action-tmate@v3
- name: Test Fortran compiler
if: steps.setup-fortran.outcome == 'success'
uses: ./.github/actions/test-fc
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}
- name: Test MKL libraries
# we could also exclude 2021.5 for all macos versions here
# this needs refactoring at some point - should the install
# fail if no mkl version exists?
if: steps.setup-fortran.outcome == 'success' && runner.os != 'windows'
uses: ./.github/actions/test-mkl
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}
install_mkl: true
- name: Test C compiler
continue-on-error: true
if: needs.options.outputs.mode == 'report' && steps.setup-fortran.outcome == 'success'
uses: ./.github/actions/test-cc
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}
- name: Test C++ compiler
continue-on-error: true
if: needs.options.outputs.mode == 'report' && steps.setup-fortran.outcome == 'success'
uses: ./.github/actions/test-cxx
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}
- name: Create compatibility report
if: needs.options.outputs.mode == 'report'
shell: bash
run: |
mkdir -p compat
support=$([ "${{ steps.setup-fortran.outcome }}" == "success" ] && echo "✓" || echo "")
prefix="${{ matrix.os }},${{ matrix.toolchain.compiler }},${{ matrix.toolchain.version }}"
report="compat/${prefix//,/_}.csv"
echo "$prefix,$support" >> "$report"
cat "$report"
- name: Upload compatibility report
if: needs.options.outputs.mode == 'report'
uses: actions/upload-artifact@v3
with:
name: compat
path: compat/*.csv
compat:
name: Report compatibility
needs:
- options
- test
if: needs.options.outputs.mode == 'report'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install packages
run: pip install -r requirements.txt
- name: Download reports
uses: actions/download-artifact@v3
with:
name: compat
path: compat
- name: Concatenate reports
run: |
echo "runner,compiler,version,support" > .github/compat/long_compat.csv
cat compat/*.csv >> .github/compat/long_compat.csv
- name: Make wide reports
working-directory: .github/compat
run: |
python wide_compat_reports.py "long_compat.csv" "compat.csv"
cat compat.md
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: compat
path: |
.github/compat/long_compat.csv
.github/compat/compat.csv
.github/compat/compat.md
- name: Check for changes
working-directory: .github/compat
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' }}
run: python .github/compat/update_compat_table.py ".github/compat/compat.md" "README.md"
- name: Print README diff
if: ${{ steps.diff.outputs.diff == 'true' }}
run: git diff README.md
- name: Create pull request
if: ${{ steps.diff.outputs.diff == 'true' }}
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 .github/compat/*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 .github/compat/compat.md