Skip to content

Commit

Permalink
Merge pull request #1 from vegardjervell/ci_actions
Browse files Browse the repository at this point in the history
Ci actions
  • Loading branch information
vegardjervell authored Oct 11, 2024
2 parents a735947 + 26fa700 commit 97a92f7
Show file tree
Hide file tree
Showing 31 changed files with 884 additions and 493 deletions.
7 changes: 7 additions & 0 deletions .github/prerelease_bodyFile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This release is automatically updated whenever a pull request is merged to `main`.

For stable releases of `ThermoPack`, see releases named `vX.Y.Z`.

To install this release, download and unzip the appropriate zip file, then install with `pip install thermopack -f wheel-<version>-<system>/`, where `wheel-<version>-<system>` is the directory created by unzipping the file.

Documentation and user guides for the latest version are found at [thermotools.github.io/thermopack](thermotools.github.io/thermopack), but are likely not as well maintained as the documentation and guides for stable releases.
17 changes: 17 additions & 0 deletions .github/scripts/before_windows_build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#Set-PSDebug -Trace 1
echo "Running before_build on windows ..."
mkdir build
echo "Created build dir ..."
cd build
echo "Moved into build dir ..."
cmake .. -G Ninja -DCMAKE_Fortran_COMPILER=ifort -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release
echo "cmake finished ..."
cmake --build . --config=Release --target install
echo "build finished ..."
# python -c "import sys; sys.path.insert(0, '../addon/pycThermopack'); import makescript; makescript.windows_make('v3')"
python ../addon/pycThermopack/map_platform_specifics.py --diffs=v3 --ifort=True
echo "--- pycThermopack contents ---"
dir ../addon/pycThermopack
echo "--- pycThermopack/thermopack contents ---"
dir ../addon/pycThermopack/thermopack
#Set-PSDebug -Off
131 changes: 131 additions & 0 deletions .github/workflows/cibuildwheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: cibuildwheel

on: []

jobs:
build_wheels:
name: Build ${{ matrix.tp_version }} wheels on ${{ matrix.os }}-${{ matrix.version }}
runs-on: ${{ matrix.os }}-${{ matrix.version }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [macOS, ubuntu, windows]
version: [latest]
tp_version: [v2, v3]
include:
- version: 12
os: macOS
tp_version: v2
- version: 12
os: macOS
tp_version: v3

steps:
- uses: actions/checkout@v4
- name: checkout submodules
run: git submodule update --init --recursive

- name: Setup Linux env
if: matrix.os == 'ubuntu'
run: |
echo "gfortran=gfortran" >> $GITHUB_ENV
echo "libinspector=ls ../addon/pycThermopack/thermopack/libthermopack* | xargs ldd" >> $GITHUB_ENV
- name: Setup macOS env
if: matrix.os == 'macOS'
run: |
echo "gfortran=$(which gfortran-13)" >> $GITHUB_ENV
echo "libinspector=otool -L ../addon/pycThermopack/thermopack/libthermopack*" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | cut -d '.' -f 1)" >> $GITHUB_ENV
- name: Setup Windows env
if: matrix.os == 'windows'
uses: fortran-lang/setup-fortran@v1
with:
compiler: intel-classic
version: '2021.12'

- name: Check macOS deployment target
if: matrix.os == 'macOS'
run: echo "Deployment target version is ${{ env.MACOSX_DEPLOYMENT_TARGET }} / ${MACOSX_DEPLOYMENT_TARGET}"

- name: Build wheel
uses: pypa/[email protected] # run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ARCHS: auto64
CIBW_BEFORE_ALL_LINUX: |
yum install -y blas blas-devel
yum install -y lapack lapack-devel
CIBW_BEFORE_BUILD_WINDOWS: powershell -ExecutionPolicy Bypass -File .github/scripts/before_windows_build.ps1

CIBW_BEFORE_BUILD: |
${{ env.gfortran }} --version
export FC=${{ env.gfortran }}
mkdir build
cd build
cmake ..
make -j4 install
python ../addon/pycThermopack/map_platform_specifics.py --diffs=${{ matrix.tp_version }}
echo "--- pycThermopack contents ---"
ls ../addon/pycThermopack
echo "--- pycThermopack/thermopack contents ---"
ls ../addon/pycThermopack/thermopack
echo "--- Inspecting libthermopack ---"
${{ env.libinspector }}
CIBW_BUILD: "*cp311*"
CIBW_SKIP: "*musllinux*"
CIBW_TEST_SKIP: "*x86_64* thermopack-2*"
CIBW_BUILD_VERBOSITY: 1
with:
package-dir: "./addon/pycThermopack"
output-dir: "./wheelhouse"
config-file: "{package}/pyproject.toml"

- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.tp_version }}-${{ matrix.os }}-${{ matrix.version }}
path: ./wheelhouse/*.whl

release_wheels: # Create or update the release tagged Latest-beta, and upload wheels to that release.
name: Update prerelease
if: github.ref == 'refs/heads/main'
needs: build_wheels
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v3

- name: Download created wheels
uses: actions/download-artifact@v4
with:
pattern: wheel-*

- name: Display full directory status
run: ls -R .

- name: zip wheels
run: |
for dir in wheel-*; do
zip -r "${dir}.zip" ${dir}
done
- name: Display current directory status
run: ls

- uses: ncipollo/release-action@v1
with:
allowUpdates: true
prerelease: true
updateOnlyUnreleased: true
removeArtifacts: true
name: "Latest (beta)"
tag: Latest-beta
commit: main
makeLatest: true
bodyFile: ".github/prerelease_bodyFile.md"
artifacts: "wheel-*.zip"
25 changes: 25 additions & 0 deletions .github/workflows/dummy_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Dummy Build

on:
push:
branches:
- main
pull_request:

jobs:
build_wheels:
if: github.ref == 'refs/heads/main' || github.event_name != 'push'
name: Dummy build
runs-on: ubuntu-latest
steps:
- name: Build
run: echo "Building ... but not a PR"

release_wheels:
name: Dummy release
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Release
run: echo "Releasing ..."

15 changes: 15 additions & 0 deletions .github/workflows/dummy_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Dummy Test

on:
push:
branches:
- main
pull_request:

jobs:
run_tests:
name: Dummy test
runs-on: ubuntu-latest
steps:
- name: Test
run: echo "Testing ..."
187 changes: 187 additions & 0 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
name: unittests

on: []

jobs:
run-tests:
name: Test on ${{ matrix.os }} with ${{ matrix.toolchain.compiler }} ${{ matrix.toolchain.version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-12]
toolchain:
- {compiler: gcc, version: 13}
include:
# - os: ubuntu-latest
# toolchain: {nvidia-hpc, version: '23.11'}
# - os: windows-2022
# toolchain: {compiler: intel, version: '2024.1'}
- os: windows-2022
toolchain: {compiler: intel-classic, version: '2021.12'}
# exclude:
# - os: windows-latest
# toolchain: {compiler: gcc, version: 13}

steps:
- uses: actions/checkout@v4
- name: checkout submodules
run: git submodule update --init --recursive

# - name: Setup Visual Studio 2022
# if: matrix.os == 'windows-2022'
# uses: microsoft/[email protected]

- name: Install ninja-build tool
if: matrix.os == 'windows-2022'
uses: seanmiddleditch/gha-setup-ninja@16b940825621068d98711680b6c3ff92201f8fc0

- uses: fortran-lang/setup-fortran@v1
id: setup-fortran
if: matrix.os != 'macos-12'
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}

- name: Setup gfortran macos-12
if: matrix.os == 'macos-12'
run: |
export FC=$(which gfortran-13)
echo FC=$FC >> $GITHUB_ENV
- name: Build ThermoPack
if: matrix.os != 'windows-2022'
run: |
mkdir build
cd build
cmake -Dtest=ON -DCMAKE_BUILD_TYPE=Debug ..
make -j4 install
# - name: Build LAPACK Windows
# if: matrix.os == 'windows-2022'
# run: |
# cd external
# cd lapack
# cmake -B build -G Ninja -DCMAKE_Fortran_COMPILER=${{ env.FC }} -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icx
# cmake --build build --target install

- name: Build ThermoPack Windows
if: ${{ runner.os == 'Windows' }}
run: |
echo "Building on ${{ matrix.os }}"
$FC = ${{ env.FC }}
$FC_PATH = $((Get-Command ${{ env.FC }} | Select-Object -ExpandProperty Path) -replace '\\', '/')
echo "Using compiler $env:FC / ${{ env.FC }}"
echo "Fortran compiler at: $(Get-Command ${{ env.FC }} | Select-Object -ExpandProperty Path) / $FC_PATH"
cmake -B build -G Ninja -DCMAKE_Fortran_COMPILER=${{ env.FC }} -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --target install --verbose
# cmake -B build -G "Visual Studio 17 2022" -DCMAKE_Fortran_COMPILER=${{ env.FC }}

- name: Inspect thermopack Linux
if: ${{ runner.os == 'Linux' }}
run: |
echo "--- Inspecting libthermopack ---"
ldd installed/libthermopack.so
nm installed/libthermopack.so | grep " T "
echo "--- Inspecting run_unittests ---"
ldd installed/unittests
- name: Inspect thermopack MacOS
if: ${{ runner.os == 'macOS' }}
run: |
echo "--- Inspecting libthermopack ---"
otool -L installed/libthermopack.dylib
nm installed/libthermopack.dylib | grep " T "
echo "--- Inspecting run_unittests ---"
otool -L installed/unittests
- name: Inspect thermopack Windows
if: ${{ runner.os == 'Windows' }}
run: |
echo "--- Inspecting libthermopack.dll ---"
dumpbin /DEPENDENTS installed/libthermopack.dll
dumpbin /EXPORTS installed/libthermopack.dll
- name: Upload
uses: actions/upload-artifact@v4
with:
name: binary-${{ matrix.os }}-${{ matrix.toolchain.compiler }}
path: ./installed/*

- id: fortran_test
name: Run unittests
if: matrix.os != 'windows-2022'
continue-on-error: true
run: |
result=$(./installed/unittests)
if echo "$result" | grep -q "OK"; then
statuscode=0
else
statuscode=1
fi
echo "$result"
echo "statuscode=$statuscode" >> $GITHUB_OUTPUT
exit $statuscode
- uses: actions/setup-python@v5
- id: python_test
name: Run python tests for Linux/MacOS
if: matrix.os != 'windows-2022'
continue-on-error: true
run: |
python addon/pycThermopack/map_platform_specifics.py
pip install addon/pycThermopack/[test]
pytest addon/pyTests
result=$(pytest addon/pyTests)
if echo "$result" | grep -q "FAILED"; then
statuscode=1
else
statuscode=0
fi
echo "$result"
echo "statuscode=$statuscode" >> $GITHUB_OUTPUT
exit $statuscode
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- id: python_test_windows
name: Run python tests for Windows
if: matrix.os == 'windows-2022'
continue-on-error: true
run: |
python -m pip install --upgrade pip
pip install pytest numpy
python -c "import sys; sys.path.insert(0, './addon/pycThermopack'); import makescript; makescript.windows_make('v3')"
pip install ./addon/pycThermopack/[test]
$result = python -m pytest ./addon/pyTests
if ($result -match "FAILED") {
$statuscode = 1
} else {
$statuscode = 0
}
Write-Output $result
Add-Content -Path $env:GITHUB_OUTPUT -Value "statuscode=$statuscode"
exit $statuscode
- name: Check success
if: matrix.os != 'windows-2022'
run: |
echo "Fortran test result : ${{ steps.fortran_test.outputs.statuscode }}"
echo "Python test result : ${{ steps.python_test.outputs.statuscode }}"
if [[ ${{ steps.fortran_test.outputs.statuscode }} -eq 0 ]] && [[ ${{ steps.python_test.outputs.statuscode }} -eq 0 ]]; then
exit 0
else
exit 1
fi
- name: Check success Windows
if: matrix.os == 'windows-2022'
run: |
$statusCode = ${{ steps.python_test_windows.outputs.statuscode }}
Write-Host "Python test result: $statusCode"
if ($statusCode -eq 0) {
exit 0
} else {
exit 1
}
Loading

0 comments on commit 97a92f7

Please sign in to comment.