Skip to content

Commit

Permalink
Merge pull request #16 from odav/main
Browse files Browse the repository at this point in the history
Aggregated Fixes and Updates SOC and build mgmt
  • Loading branch information
odav authored Nov 6, 2024
2 parents d4c0d08 + 117351c commit 7a222b8
Show file tree
Hide file tree
Showing 183 changed files with 2,859 additions and 2,874 deletions.
207 changes: 180 additions & 27 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,139 @@ on:
- '*.*.*'

workflow_dispatch:
inputs:
rev:
description: 'tag, branch, or SHA to check out'
required: true
default: 'develop'

permissions:
contents: write
packages: write
pull-requests: write



jobs:
build:

# Get the version from tag
version:
name: Version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: '${{ github.event.inputs.rev }}'
fetch-tags: true
fetch-depth: 0
- name: Get SWAT+ version
id: get_version
run: |
V=`git describe --tags`
echo $V
echo $V >v.txt
cat v.txt
echo ${{ github.event.release.tag_name }}
echo ${GITHUB_REF#refs/*/}
- name: upload
uses: actions/upload-artifact@v4
with:
name: release_tag
path: v.txt

##### Build swat with GNU
build-gnu:
runs-on: ${{ matrix.os }}
if: endsWith(github.event.base_ref, 'main') == true
needs:
- version
#if: endsWith(github.event.base_ref, 'main') == true

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
toolchain:
- {compiler: gcc, version: 13}

steps:
- name: Install Compiler
uses: fortran-lang/setup-fortran@v1
id: setup-fortran
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}

- name: Checkout
uses: actions/checkout@v4

- name: Build SWAT+
id: build_exe
run: |
echo ${{ env.FC }}
cmake --version
RELEASE_VERSION=${GITHUB_REF#refs/*/}
os="$RUNNER_OS"
e="build/swatplus-*"
gen="Unix"
if [ "$RUNNER_OS" == "Windows" ]; then
e="build/swatplus-*.exe"
gen="MinGW"
fi
# generate
cmake -B build -G "${gen} Makefiles" \
-D CMAKE_Fortran_COMPILER=${{ env.FC }} \
-D TAG=$RELEASE_VERSION \
-D CMAKE_BUILD_TYPE=Release
# build
cmake --build build --parallel 4
exebase=`basename -s .exe build/swatplus-*`
exez="${exebase}.zip"
exe=`ls $e`
echo $exe
echo $exez
echo $os
echo "exe=$exe" >> $GITHUB_OUTPUT
echo "exez=$exez" >> $GITHUB_OUTPUT
echo "os=$os" >> $GITHUB_OUTPUT
ls -hl build/swatplus-*
file build/swatplus-*
if [ "$RUNNER_OS" != "Windows" ]; then
(cd build && zip ../$exez swatplus-*)
fi
shell: bash

- name: zip
if: matrix.os == 'windows-latest'
uses: vimtor/[email protected]
with:
files: ${{ steps.build_exe.outputs.exe }}
dest: ${{ steps.build_exe.outputs.exez }}

- name: upload
uses: actions/upload-artifact@v4
with:
name: gnu-${{ steps.build_exe.outputs.os }}
path: ${{ steps.build_exe.outputs.exez }}


##### Build with Intel (ifx. ifort)

build-intel:
runs-on: ${{ matrix.os }}
needs:
- version
# if: endsWith(github.event.base_ref, 'main') == true

strategy:
fail-fast: false
Expand All @@ -38,7 +161,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
# with:
with:
ref: '${{ github.event.inputs.rev }}'
# fetch-tags: true
# fetch-depth: 0

Expand All @@ -49,13 +173,19 @@ jobs:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}

- name: Download version
uses: actions/download-artifact@v4
with:
name: release_tag

- name: Build SWAT+
id: build_exe
run: |
echo ${{ env.FC }}
cmake --version
RELEASE_VERSION=${GITHUB_REF#refs/*/}
# RELEASE_VERSION=${GITHUB_REF#refs/*/}
RELEASE_VERSION=`cat v.txt`
os="$RUNNER_OS"
if [ "$RUNNER_OS" == "Linux" ]; then
Expand Down Expand Up @@ -83,7 +213,7 @@ jobs:
fi
# compile
cmake --build build
cmake --build build --parallel 4
exebase=`basename -s .exe build/swatplus-*`
exez="${exebase}.zip"
Expand Down Expand Up @@ -114,48 +244,71 @@ jobs:
dest: ${{ steps.build_exe.outputs.exez }}

- name: upload
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: sp-${{ steps.build_exe.outputs.os }}
name: intel-${{ steps.build_exe.outputs.os }}
path: ${{ steps.build_exe.outputs.exez }}


##### Create a new release with all zip files
release:
name: Release
runs-on: ubuntu-latest
needs:
- build
needs: [ build-gnu, build-intel ]

steps:
- name: Download Linux
uses: actions/download-artifact@v2
- name: Download GNU Linux
uses: actions/download-artifact@v4
with:
name: gnu-Linux

- name: Download GNU Windows
uses: actions/download-artifact@v4
with:
name: sp-Linux
name: gnu-Windows

- name: Download Windows
uses: actions/download-artifact@v2
- name: Download GNU macOS
uses: actions/download-artifact@v4
with:
name: sp-Windows
name: gnu-macOS

- name: Download macOS
uses: actions/download-artifact@v2
- name: Download Intel Linux
uses: actions/download-artifact@v4
with:
name: sp-macOS
name: intel-Linux

- name: Download Intel Windows
uses: actions/download-artifact@v4
with:
name: intel-Windows

- name: Download Intel macOS
uses: actions/download-artifact@v4
with:
name: intel-macOS

- name: Download version
uses: actions/download-artifact@v4
with:
name: release_tag

- name: Read version
id: read_ver
run: |
RELEASE_VERSION=`cat v.txt`
echo "rv=$RELEASE_VERSION" >> $GITHUB_OUTPUT
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
token: ${{ github.token }}
tag_name: ${{ github.event.release.tag_name }}
prerelease: false
# tag_name: ${{ github.event.release.tag_name }}
prerelease: true
draft: false
name: ${{ github.event.release.tag_name }}
# name: ${{ github.event.release.tag_name }}
name: ${{ steps.read_ver.outputs.rv }}
files: swatplus-*
generate_release_notes: true
body: |
<details>
<summary>Autogenerated Changelog</summary>
... changelog ...
</details>



3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ CMakeCache.txt
Resources/R*
src/main.f90
ford.md
/.vs/SWAT_PLUS_DEV
/.vs/SWAT_PLUS_DEV
/.vscode
25 changes: 12 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ if (UNIX)
set(fdialect "-free -fpe0 -traceback -diag-disable=10448")
set(fdebug "-warn all")
set(frelease "-O")
set(FFC "ifo")
set(FFC "ifo")
link_libraries("-static")
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL IntelLLVM)
set(fdialect "-free -fpe0 -traceback")
set(fdebug "-warn all -O0")
set(frelease "-O")
set(FFC "ifx")
set(FFC "ifx")
link_libraries("-static")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
set(fdialect "-fcheck=all -ffpe-trap=invalid,zero,overflow,underflow -fimplicit-none -ffree-line-length-none -fbacktrace -finit-local-zero -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans")
set(fdebug "-Wall")
set(frelease "-O")
set(FFC "gcc")
set(fdialect "-fcheck=all -ffpe-trap=invalid,zero,overflow,underflow -fimplicit-none -ffree-line-length-none -fbacktrace -finit-local-zero -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans")
set(fdebug "-Wall")
set(frelease "-O")
set(FFC "gnu")
if(NOT APPLE)
link_libraries("-static")
endif()
Expand All @@ -66,18 +66,18 @@ elseif(WIN32)
elseif(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
set(fdialect "-fcheck=all -ffpe-trap=invalid,zero,overflow,underflow -fimplicit-none -ffree-line-length-none -fbacktrace -finit-local-zero -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans")
set(fdebug "-Wall ")
set(FFC "gcc")
set(FFC "gnu")
set(frelease "-O")
endif()
endif()

string(TOLOWER ${CMAKE_HOST_SYSTEM_PROCESSOR} ARCH)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(AR "${FFC}-lin_${ARCH}")
set(AR "lin_${ARCH}")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(AR "${FFC}-win_${ARCH}")
set(AR "win_${ARCH}")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(AR "${FFC}-mac_${ARCH}")
set(AR "mac_${ARCH}")
else()
set(AR "unknown")
endif()
Expand All @@ -92,9 +92,9 @@ endif()

# SWAT Version number
set(SWAT_VERSION ${TAG})
set(SWATPLUS_EXE "swatplus-${SWAT_VERSION}-${AR}${TY}")
set(SWATPLUS_EXE "swatplus-${SWAT_VERSION}-${FFC}-${AR}${TY}")

# Enable this to 'TRUE' to see the fortran command on compile
# Set this to 'TRUE' to see the fortran command on compile
set(CMAKE_VERBOSE_MAKEFILE FALSE)

set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${fdialect}")
Expand All @@ -111,7 +111,6 @@ set(CMAKE_Fortran_FLAGS_RELEASE "${frelease}")

if(EXISTS "${PROJECT_SOURCE_DIR}/src/main.f90.in")
string(TIMESTAMP ISO "%Y-%m-%d %H:%M:%S")
# string(TIMESTAMP TODAY "%b %d %Y") # e.g. produces Dec 7 2023
string(TIMESTAMP TODAY "%Y-%m-%d") # e.g. produces 2023-12-07
string(TIMESTAMP YEAR "%Y")

Expand Down
Loading

0 comments on commit 7a222b8

Please sign in to comment.