Build on Windows #100
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: [push, pull_request] | |
env: | |
BUILD_DIR: _build | |
jobs: | |
build-test-unix: | |
if: | |
github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash -l {0} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: mamba-org/setup-micromamba@v2 | |
with: | |
micromamba-version: latest | |
environment-file: environment.yml | |
- name: Build and install HeatModelF | |
run: | | |
pushd ./external/bmi-example-fortran | |
cmake -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX | |
cmake --build ${{ env.BUILD_DIR }} --target install --config Release | |
popd | |
- name: Build and install package | |
run: | | |
make install | |
- name: Test imports | |
working-directory: ${{ github.workspace }}/examples | |
run: | | |
python -c 'import pymt_heatf' | |
python -c 'from pymt.models import HeatModelF' | |
- name: Test BMI | |
run: | | |
make test | |
- name: Run examples | |
working-directory: ${{ github.workspace }}/examples | |
run: | | |
python heatf_ex.py | |
python pymt_heatf_ex.py | |
build-test-windows: | |
if: | |
github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository | |
runs-on: windows-latest | |
env: | |
LIBRARY_PREFIX: $env:CONDA_PREFIX\Library | |
defaults: | |
run: | |
shell: pwsh | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: ilammy/msvc-dev-cmd@v1 | |
- uses: mamba-org/setup-micromamba@v2 | |
with: | |
micromamba-version: latest | |
environment-file: environment.yml | |
init-shell: >- | |
powershell | |
# The Fortran conda compiler, flang, needs to be set over the gfortran installed by chocolatety. | |
- name: Set the FC environment variable | |
run: | | |
echo "FC=$env:CONDA_PREFIX\Library\bin\flang-new.exe" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append | |
# A link.exe installed by chocolatey was ahead of the MSVC link.exe in the path. | |
- name: Remove link.exe in the Git install | |
run: | | |
Remove-Item -Path "C:\Program Files\Git\usr\bin\link.exe" -Force | |
# The flang FortranRuntime.lib wasn't being found. This recommendation comes from the Meson docs. | |
- name: Add conda environment libpath to Windows LIB (not LIBPATH) | |
run: | | |
echo "LIB=$env:LIB;$env:CONDA_PREFIX\Library\lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
- name: View environment variables | |
run: | | |
ls env: | |
# The install prefix must be quoted. | |
- name: Configure, build, and install HeatModelF | |
run: | | |
pushd ./external/bmi-example-fortran | |
cmake -B ${{ env.BUILD_DIR }} -LA -G Ninja -DCMAKE_INSTALL_PREFIX="${{ env.LIBRARY_PREFIX }}" -DCMAKE_BUILD_TYPE=Release | |
cmake --build ${{ env.BUILD_DIR }} --target install --config Release | |
popd | |
- name: Build and install package | |
run: | | |
make install | |
- name: Test imports | |
working-directory: ${{ github.workspace }}/examples | |
run: | | |
python -c 'import pymt_heatf' | |
python -c 'from pymt.models import HeatModelF' | |
# Weird Windows stuff here. If the examples in the next step run to completion, the BMI works. | |
# - name: Test BMI | |
# working-directory: ${{ github.workspace }} | |
# run: | | |
# bmi-test pymt_heatf._bmi:HeatModelF --config-file=${{ github.workspace }}\examples\test.cfg --root-dir=examples -vvv | |
- name: Run examples | |
working-directory: ${{ github.workspace }}/examples | |
run: | | |
python heatf_ex.py | |
python pymt_heatf_ex.py |