Skip to content

Commit

Permalink
Merge pull request #1 from Mariosmsk/retry-builds
Browse files Browse the repository at this point in the history
Retry builds
  • Loading branch information
eladsal authored Apr 21, 2024
2 parents e396bd8 + cd242aa commit 3d7cf9a
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 32 deletions.
63 changes: 44 additions & 19 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,52 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- uses: actions/checkout@v4
- name: Setup build directory
run: mkdir buildproducts
- uses: actions/checkout@v4

- name: CMake
working-directory: ./buildproducts
run: cmake ..
- name: Setup build directory
run: mkdir buildproducts

- name: Make
working-directory: ./buildproducts
run: make
- name: CMake
working-directory: ./buildproducts
run: |
retry=0
max_retries=3
until cmake ..; do
retry=$((retry+1))
echo "Retry $retry/$max_retries..."
if [ "$retry" -ge "$max_retries" ]; then
echo "CMake configuration failed after $max_retries attempts."
exit 1
fi
sleep 10
done
- name: Copy header files to build directory
run: |
cp include/epanet2.h buildproducts/
cp include/epanet2_2.h buildproducts/
cp include/epanet2_enums.h buildproducts/
- uses: actions/upload-artifact@v4
with:
name: libepanet-output
path: buildproducts/
- name: Make
working-directory: ./buildproducts
run: |
retry=0
max_retries=3
until make; do
retry=$((retry+1))
echo "Retry $retry/$max_retries..."
if [ "$retry" -ge "$max_retries" ]; then
echo "Make build failed after $max_retries attempts."
exit 1
fi
sleep 10
done
- name: Copy header files to build directory
run: |
cp include/epanet2.h buildproducts/
cp include/epanet2_2.h buildproducts/
cp include/epanet2_enums.h buildproducts/
- uses: actions/upload-artifact@v4
with:
name: libepanet-output
path: buildproducts/
37 changes: 31 additions & 6 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,51 @@ on:
jobs:
build:
runs-on: macos-latest
strategy:
fail-fast: false

steps:
- uses: actions/checkout@v4

- name: Setup build directory
run: mkdir buildproducts

- name: CMake
working-directory: ./buildproducts
run: cmake ..

run: |
retry=0
max_retries=3
until cmake ..; do
((retry++))
echo "Retry $retry/$max_retries..."
if [ "$retry" -ge "$max_retries" ]; then
echo "CMake configuration failed after $max_retries attempts."
exit 1
fi
sleep 10
done
- name: Make
working-directory: ./buildproducts
run: make

run: |
retry=0
max_retries=3
until make; do
((retry++))
echo "Retry $retry/$max_retries..."
if [ "$retry" -ge "$max_retries" ]; then
echo "Make build failed after $max_retries attempts."
exit 1
fi
sleep 10
done
- name: Copy header files to build directory
run: |
cp include/epanet2.h buildproducts/
cp include/epanet2_2.h buildproducts/
cp include/epanet2_enums.h buildproducts/
- uses: actions/upload-artifact@v4
with:
name: libepanet-output
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/win32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
jobs:
build:
runs-on: windows-latest
strategy:
fail-fast: false

steps:
- name: Checkout repository
Expand All @@ -19,7 +21,21 @@ jobs:

- name: CMake
working-directory: ./buildproducts
run: cmake .. -A Win32 && cmake --build . --config Release
shell: pwsh
run: |
$retryCount = 0
$maxRetries = 3
do {
cmake .. -A Win32 && cmake --build . --config Release
if ($LASTEXITCODE -eq 0) { break }
Write-Host "Retry $($retryCount + 1)/$maxRetries..."
Start-Sleep -Seconds 10
$retryCount++
} while ($retryCount -lt $maxRetries)
if ($retryCount -eq $maxRetries) {
Write-Host "CMake build failed after $maxRetries attempts."
exit 1
}
- name: Copy header files to build directory
run: |
Expand All @@ -31,4 +47,4 @@ jobs:
- uses: actions/upload-artifact@v4
with:
name: epanet2-win32
path: buildproducts\bin\Release
path: buildproducts\bin\Release
25 changes: 21 additions & 4 deletions .github/workflows/win64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
jobs:
build:
runs-on: windows-latest
strategy:
fail-fast: false

steps:
- name: Checkout repository
Expand All @@ -19,16 +21,31 @@ jobs:

- name: CMake
working-directory: ./buildproducts
run: cmake .. -A x64 && cmake --build . --config Release

shell: pwsh
run: |
$retryCount = 0
$maxRetries = 3
do {
cmake .. -A x64 # Specify architecture for 64-bit
cmake --build . --config Release
if ($LASTEXITCODE -eq 0) { break }
Write-Host "Retry $($retryCount + 1)/$maxRetries..."
Start-Sleep -Seconds 10
$retryCount++
} while ($retryCount -lt $maxRetries)
if ($retryCount -eq $maxRetries) {
Write-Host "CMake build failed after $maxRetries attempts."
exit 1
}
- name: Copy header files to build directory
run: |
copy include\epanet2.h buildproducts\bin\Release
copy include\epanet2_2.h buildproducts\bin\Release
copy include\epanet2_enums.h buildproducts\bin\Release
shell: cmd

- uses: actions/upload-artifact@v4
with:
name: epanet2-win64
path: buildproducts\bin\Release
path: buildproducts\bin\Release
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# CMake is available at https://cmake.org/download/
#

cmake_minimum_required (VERSION 2.8.8)
cmake_minimum_required (VERSION 3.5.2)

project(EPANET)

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ OWA-EPANET
[![codecov](https://codecov.io/gh/OpenWaterAnalytics/EPANET/branch/master/graph/badge.svg)](https://codecov.io/gh/OpenWaterAnalytics/EPANET)

[![linux](https://github.com/OpenWaterAnalytics/EPANET/actions/workflows/ccpp.yml/badge.svg)](https://github.com/OpenWaterAnalytics/EPANET/actions/workflows/ccpp.yml)
[![macos](https://github.com/OpenWaterAnalytics/EPANET/actions/workflows/macos.yml/badge.svg)](https://github.
com/OpenWaterAnalytics/EPANET/actions/workflows/macos.yml)
[![epanet2-win32](https://github.com/OpenWaterAnalytics/EPANET/actions/workflows/win32.yml/badge.svg)](https://github.com/OpenWaterAnalytics/EPANET/actions/workflows/win32.yml)
[![epanet2-win64](https://github.com/OpenWaterAnalytics/EPANET/actions/workflows/win64.yml/badge.svg)](https://github.com/OpenWaterAnalytics/EPANET/actions/workflows/win64.yml)

Expand Down

0 comments on commit 3d7cf9a

Please sign in to comment.