Skip to content

Commit 356c542

Browse files
committed
[workflows] Update GitHub workflows
Use the Ubuntu 22.04 runner and the release_16x and release_17x branches of classic-flang-llvm-project to build and test Classic Flang. We use the pre-built classic-flang-llvm-project for building, so we do not actually need to install a specific version of GCC. Also simplify the logic for finding and downloading a suitable prebuilt compiler.
1 parent 660b3a0 commit 356c542

File tree

3 files changed

+65
-45
lines changed

3 files changed

+65
-45
lines changed

.github/workflows/build_flang.yml

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,24 @@ on:
1414

1515
jobs:
1616
build_flang:
17-
runs-on: ubuntu-20.04
17+
runs-on: ubuntu-22.04
1818
env:
1919
install_prefix: /usr/local
2020
strategy:
2121
matrix:
2222
target: [X86]
23-
cc: [clang, gcc]
24-
version: [10, 11]
25-
llvm_branch: [release_15x]
23+
cc: [clang]
24+
version: [14, 15]
25+
llvm_branch: [release_16x, release_17x]
26+
include:
27+
- target: X86
28+
cc: gcc
29+
version: 12
30+
llvm_branch: release_16x
31+
- target: X86
32+
cc: gcc
33+
version: 12
34+
llvm_branch: release_17x
2635

2736
steps:
2837
# Checks-out your repository under $GITHUB_WORKSPACE, so the job can access it
@@ -45,21 +54,27 @@ jobs:
4554
- name: Download artifacts
4655
run: |
4756
cd ../..
48-
curl -sL https://api.github.com/repos/flang-compiler/classic-flang-llvm-project/actions/workflows/pre-compile_llvm.yml/runs --output runs_llvm.json
49-
wget --output-document artifacts_llvm `jq -r '.workflow_runs[0].artifacts_url?' runs_llvm.json`
50-
51-
i="0"
52-
# Keep checking older builds to find the right branch and correct number of artifacts
53-
while { [ `jq -r '.total_count?' artifacts_llvm` != "5" ] || \
54-
[ `jq -r --argjson i "$i" '.workflow_runs[$i].head_branch?' runs_llvm.json` != ${{ matrix.llvm_branch }} ]; } && \
55-
[ $i -lt 10 ];
56-
do
57-
echo "No artifacts or wrong branch in build $i, counting from latest"
58-
i=$[$i+1]
59-
wget --output-document artifacts_llvm `jq -r --argjson i "$i" '.workflow_runs[$i].artifacts_url?' runs_llvm.json`
57+
# Search backwards in the workflow history for the specified branch
58+
# for the first successful run that produced the desired artifact.
59+
build_name="llvm_build_${{ matrix.target }}_${{ matrix.cc }}_${{ matrix.version }}_${{ matrix.llvm_branch }}"
60+
curl -sL https://api.github.com/repos/flang-compiler/classic-flang-llvm-project/actions/workflows/pre-compile_llvm.yml/runs -o llvm_runs.json
61+
urls=(`jq -r --arg b ${{ matrix.llvm_branch }} '.workflow_runs[] | select(.head_branch == $b) | select (.conclusion == "success") | .artifacts_url?' llvm_runs.json`)
62+
for artifacts_url in "${urls[@]}"; do
63+
curl -sL "$artifacts_url" -o llvm_artifacts.json
64+
archive_url=`jq -r --arg b $build_name '.artifacts[] | select(.name == $b) | .archive_download_url' llvm_artifacts.json`
65+
if [ -z "$archive_url" ]; then
66+
echo "$artifacts_url did not contain a $build_name archive; too old?"
67+
continue
68+
fi
69+
echo "Downloading $archive_url."
70+
if curl -sL -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" $archive_url -o llvm_build.zip; then
71+
break
72+
fi
6073
done
61-
url=`jq -r '.artifacts[] | select(.name == "llvm_build_${{ matrix.target }}_${{ matrix.cc }}_${{ matrix.version }}_${{ matrix.llvm_branch }}") | .archive_download_url' artifacts_llvm`
62-
wget --output-document llvm_build.zip --header="Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" $url
74+
if [ ! -f llvm_build.zip ]; then
75+
echo "Could not download the correct prebuilt compiler; aborting."
76+
exit 1
77+
fi
6378
6479
- name: Install llvm
6580
run: |
@@ -70,10 +85,6 @@ jobs:
7085
cd classic-flang-llvm-project/build
7186
sudo make install/fast
7287
73-
# gcc11 and g++11 are needed to install llvm
74-
- if: matrix.cc == 'gcc' && matrix.version == '11'
75-
run: sudo apt install gcc-11 g++-11
76-
7788
- name: Build and install flang & libpgmath
7889
run: |
7990
${{ env.install_prefix }}/bin/clang --version
@@ -89,13 +100,13 @@ jobs:
89100
make check-flang-long
90101
91102
# Archive documentation just once, for the fastest job.
92-
- if: matrix.cc == 'clang' && matrix.version == '11'
103+
- if: matrix.cc == 'clang' && matrix.version == '15'
93104
run: |
94105
cd build/flang/docs/web
95106
cp -r html/ ../../.. # copy to a place where Upload can find it.
96107
97108
# Upload docs just once, for the fastest job.
98-
- if: matrix.cc == 'clang' && matrix.version == '11'
109+
- if: matrix.cc == 'clang' && matrix.version == '15'
99110
uses: actions/upload-artifact@v2
100111
with:
101112
name: html_docs_flang

.github/workflows/build_flang_arm64.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
strategy:
2727
matrix:
2828
target: [AArch64]
29-
llvm_branch: [release_15x]
29+
llvm_branch: [release_16x, release_17x]
3030

3131
steps:
3232
- name: Check tools

.github/workflows/build_flang_windows.yml

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
os:
2121
- windows-latest
2222
# - self-hosted
23-
llvm_branch: [release_15x]
23+
llvm_branch: [release_16x, release_17x]
2424
include:
2525
- os: windows-latest
2626
arch: amd64
@@ -70,27 +70,36 @@ jobs:
7070
- name: Download artifact
7171
run: |
7272
cd ../..
73-
Invoke-WebRequest -Uri https://api.github.com/repos/flang-compiler/classic-flang-llvm-project/actions/workflows/pre-compile_llvm.yml/runs -OutFile runs_llvm.json
74-
Invoke-WebRequest "$(jq -r '.workflow_runs[0].artifacts_url?' runs_llvm.json)" -OutFile artifacts_llvm
75-
76-
$i=0
77-
# Keep checking older builds to find the right branch and correct number of artifacts
78-
while ( ( "$(jq -r '.total_count?' artifacts_llvm)" -ne "5" ) -or `
79-
( "$(jq -r --argjson i $i ".workflow_runs[$i].head_branch" runs_llvm.json)" -ne "${{ matrix.llvm_branch }}") -and `
80-
($i -lt 10)
81-
)
82-
{
83-
write-output "No artifacts or wrong branch in build $i, counting from latest"
84-
$i += 1
85-
Invoke-WebRequest -Uri "$(jq -r --argjson i $i ".workflow_runs[$i].artifacts_url" runs_llvm.json)" -OutFile artifacts_llvm
73+
# Search backwards in the workflow history for the specified branch
74+
# for the first successful run that produced the desired artifact.
75+
$build_name="llvm_build_win_${{ matrix.arch }}_clangcl_${{ matrix.llvm_branch }}"
76+
Invoke-WebRequest -Uri https://api.github.com/repos/flang-compiler/classic-flang-llvm-project/actions/workflows/pre-compile_llvm.yml/runs -OutFile llvm_runs.json
77+
$urls = @($(jq -r --arg b ${{ matrix.llvm_branch }} '.workflow_runs[] | select(.head_branch == $b) | select (.conclusion == ""success"") | .artifacts_url?' llvm_runs.json))
78+
Invoke-WebRequest "$(jq -r '.workflow_runs[0].artifacts_url?' llvm_runs.json)" -OutFile llvm_artifacts.json
79+
for ($i = 0; $i -lt $urls.Count; $i++) {
80+
$artifacts_url = $urls[$i]
81+
Invoke-WebRequest -Uri "$artifacts_url" -o llvm_artifacts.json
82+
$archive_url = "$(jq -r --arg b $build_name '.artifacts[] | select(.name == $b) | .archive_download_url' llvm_artifacts.json)"
83+
if (! $archive_url) {
84+
Write-Output "$artifacts_url did not contain a $build_name archive; too old?"
85+
continue
86+
}
87+
Write-Output "Downloading $archive_url."
88+
$artifact_path = "$pwd\${build_name}.zip"
89+
try {
90+
$response = Invoke-WebRequest -Method Get -Uri $archive_url -OutFile $artifact_path -Headers @{ "Authorization" = "Bearer ${{ secrets.GITHUB_TOKEN }}" }
91+
if ($response.StatusCode -lt 300) {
92+
break
93+
}
94+
} catch {}
95+
}
96+
if (!(Test-Path "$artifact_path")) {
97+
Write-Output "Could not download the correct prebuilt compiler; aborting."
98+
exit 1
8699
}
87-
$url="$(jq -r '.artifacts[] | select(.name==\"llvm_build_win_${{ matrix.arch }}_clangcl_${{ matrix.llvm_branch }}\") | .archive_download_url' artifacts_llvm)"
88-
write-output "$($url)"
89-
$artifactPath = "$pwd\llvm_build_win_${{ matrix.arch }}_clangcl_${{ matrix.llvm_branch }}.zip"
90-
Invoke-RestMethod -Method Get -Uri $url -OutFile $artifactPath -Headers @{ "Authorization" = "Bearer ${{ secrets.GITHUB_TOKEN }}" }
91-
Expand-Archive -Force -Path llvm_build_win_${{ matrix.arch }}_clangcl_${{ matrix.llvm_branch }}.zip -DestinationPath .
100+
Expand-Archive -Force -Path "${build_name}.zip" -DestinationPath .
92101
& 7z x "$pwd\llvm_build.7z" -o"$pwd\classic-flang-llvm-project\" -y
93-
write-output "$(Get-ChildItem)"
102+
Write-Output "$(Get-ChildItem)"
94103
95104
- name: Build and install flang & libpgmath
96105
run: |

0 commit comments

Comments
 (0)