Commit 8faa4441 authored by Henderson, Shane's avatar Henderson, Shane
Browse files

Make some workflow changes for automation

parent db8a2072
Loading
Loading
Loading
Loading
+109 −21
Original line number Diff line number Diff line
workflow:
  rules:
    - if: $CI_MERGE_REQUEST_IID
    - if: $CI_COMMIT_TAG
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
      when: never
    - if: $CI_COMMIT_BRANCH

stages:
- test
  - build
  - deploy

#Primarily concerned with setting up micromamba for the appropriate platforms
#All the build requirements excepting some compiler magic is there
.bash_before: &bash_before
  - export MAMBA_ROOT_PREFIX="$CI_PROJECT_DIR/../tools/micromamba"
  - source ./ci/setup_mamba.sh
  - micromamba activate saline_build

.powershell_before: &powershell_before
  - $env:MAMBA_ROOT_PREFIX="$CI_PROJECT_DIR/../tools/micromamba"
  - . $CI_PROJECT_DIR/ci/setup_mamba.ps1
  - micromamba activate saline_build

build_macos:
  stage: build
  rules:
    - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
      when: manual
    - when: always
  allow_failure: true
  tags:
    - macOS
  before_script:
  - if [[ -f "/data/test_gcc/gcc-8.3.0/load_dev_env.sh" ]]; then BASE_DIR="/data/gitlab-runner"; . /data/test_gcc/gcc-8.3.0/load_dev_env.sh; ENV_BASE=/data/test_gcc/gcc-8.3.0; else BASE_DIR="/localhome/gitlab-runner"; . /projects/vera/gcc-8.3.0/load_dev_env.sh; ENV_BASE=/projects/vera/gcc-8.3.0; fi
  - which gcc
    - *bash_before
  script:
    - cmake -S $CI_PROJECT_DIR -B "$CI_PROJECT_DIR/build" -DCMAKE_BUILD_TYPE=RELEASE
      -Dsaline_ENABLE_Fortran=ON -DCMAKE_Fortran_FLAGS:STRING="-ffree-line-length-none"
      -Dsaline_ENABLE_Python=ON
    - cmake --build "$CI_PROJECT_DIR/build"
    - ctest --test-dir "$CI_PROJECT_DIR/build"
  artifacts:
    name: mac_wheel
    expire_in: 1 week
    paths:
      - build/src/python/dist/*.whl

.stage_artifacts: &stage_artifacts
build_windows:
  stage: build
  allow_failure: true
  rules:
    - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
      when: manual
    - when: always
  tags:
    - windows
  before_script:
    - *powershell_before
  script:
    - cmake
      -S $CI_PROJECT_DIR
      -B "$CI_PROJECT_DIR/build"
      -Dsaline_ENABLE_Fortran=OFF
      -Dsaline_ENABLE_Python=ON
      -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE
    - cmake --build $BLD_DIR --target ALL_BUILD --config RELEASE
    - ctest --build-config RELEASE --test-dir $BLD_DIR
  artifacts:
    name: windows_wheel
    expire_in: 1 week
    paths:
      - build/
      - TriBITS/
      - googletest/
      - testframework/
    expire_in: 1 day
      - build/$CI_COMMIT_SHORT_SHA/src/python/dist/*.whl

linux_gcc83_testing:
  stage: test
build_linux:
  stage: build
  rules:
    - when: always
  tags:
    - linux
    - gcc
    - mamba
  before_script:
    - *bash_before
  script:
    - cmake -S $CI_PROJECT_DIR -B "$CI_PROJECT_DIR/build" -DCMAKE_BUILD_TYPE=RELEASE
      -Dsaline_ENABLE_Fortran=ON -DCMAKE_Fortran_FLAGS:STRING="-ffree-line-length-none"
      -Dsaline_ENABLE_Python=ON
    - cmake --build "$CI_PROJECT_DIR/build"
    - ctest --test-dir "$CI_PROJECT_DIR/build"
  artifacts:
    name: linux_wheel
    expire_in: 1 week
    paths:
      - build/src/python/dist/*.whl

deploy_staging:
  stage: deploy
  tags:
    - linux
    - gcc
    - mamba
  rules:
    - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
      when: never
    - when: manual
  needs:
    - build_linux
    - build_macos
    - build_windows
  before_script:
    - *bash_before
  script:
    - SRC_DIR=`pwd`
    - BLD_DIR="/tmp/$CI_PIPELINE_ID/$BLD_NAME"
    - mkdir -p $BLD_DIR
    - cd $BLD_DIR
    - rm -rf *
    - echo $PATH
    - which gcc
    - echo "$PATH"
    - $SRC_DIR/ci/linux_gcc83_test.sh $SRC_DIR
      #This is probably not the most ergonomic way...
    - NIX_WHL_FILE=`find $CI_PROJECT_DIR/build -name '*linux*'`
    - WIN_WHL_FILE=`find $CI_PROJECT_DIR/build -name '*win*'`
    - MAC_WHL_FILE=`find $CI_PROJECT_DIR/build -name '*mac*'`
    - TWINE_USERNAME=${CODE_DEPLOY} TWINE_PASSWORD=${CODE_DEPLOY_TOKEN} python -m twine upload --repository-url https://code.ornl.gov/api/v4/projects/NEAMS%2Fsaline/packages/pypi $NIX_WHL_FILE
    - TWINE_USERNAME=${CODE_DEPLOY} TWINE_PASSWORD=${CODE_DEPLOY_TOKEN} python -m twine upload --repository-url https://code.ornl.gov/api/v4/projects/NEAMS%2Fsaline/packages/pypi $WIN_WHL_FILE
    - TWINE_USERNAME=${CODE_DEPLOY} TWINE_PASSWORD=${CODE_DEPLOY_TOKEN} python -m twine upload --repository-url https://code.ornl.gov/api/v4/projects/NEAMS%2Fsaline/packages/pypi $MAC_WHL_FILE
+8 −5
Original line number Diff line number Diff line
@@ -4,8 +4,11 @@
#             Molten Salt Thermophysical Properties Interpolation              #
################################################################################
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)

#First pass automated version increment
string(TIMESTAMP t %Y.%m.%d UTC)
project(saline
  VERSION 0.0.1
  VERSION ${t}
  DESCRIPTION "MSTDB-TP API"
  LANGUAGES CXX
)
@@ -18,10 +21,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_subdirectory(src)

# Testing is enabled unless explicitly turned off
if (NOT DEFINED saline_ENABLE_tests )
  set(saline_ENABLE_tests ON)
if (NOT DEFINED ${PROJECT_NAME}_ENABLE_tests )
  set(${PROJECT_NAME}_ENABLE_tests ON)
endif()
if (saline_ENABLE_tests )
if (${PROJECT_NAME}_ENABLE_tests )
  include(CTest)
  add_subdirectory(tests)
endif()

ci/build_env.yml

0 → 100644
+12 −0
Original line number Diff line number Diff line
name: saline_build
channels:
  - conda-forge
dependencies:
  - cmake
  - cxx-compiler
  - fortran-compiler
  - python=3.8
  - build
  - swig
  - setuptools
  - twine

ci/setup_mamba.ps1

0 → 100755
+25 −0
Original line number Diff line number Diff line
if ( !(Test-Path $CI_PROJECT_DIR/../tools/micromamba.exe -PathType Leaf) )
{
    # Didn't find it so install micromamba
    mkdir -p $CI_PROJECT_DIR/../tools
    cd $CI_PROJECT_DIR/../tools

    Invoke-Webrequest -URI https://micro.mamba.pm/api/micromamba/win-64/latest -OutFile micromamba.tar.bz2
    $7z = "& '$env:PROGRAMFILES\7-zip\7z.exe'"
    $params = "-y x micromamba.tar.bz2"
    Invoke-Expression "$7z $params"
    $params = "-y x micromamba.tar"
    Invoke-Expression "$7z $params"
    MOVE -Force Library\bin\micromamba.exe micromamba.exe
    cd $CI_PROJECT_DIR
}

Invoke-Expression "$CI_PROJECT_DIR\..\tools\micromamba.exe shell hook -s powershell" | Out-String | Invoke-Expression
if (micromamba info --envs | Select-String "saline_build" )
{
    echo "env already exists"
}
else
{
    micromamba create -f $CI_PROJECT_DIR/ci/build_env.yml -y
}

ci/setup_mamba.sh

0 → 100755
+28 −0
Original line number Diff line number Diff line
#!/bin/bash

# Look for micromamba install
if ! [ -f "$CI_PROJECT_DIR/../tools/bin/micromamba" ]; then
    # Didn't find it so install micromamba
    mkdir -p "$CI_PROJECT_DIR/../tools/"
    cd "$CI_PROJECT_DIR/../tools/"

    # TO be clear this is hardly adequate in general and only meets what I know
    # is going to happen
    if [ "$(uname)" == "Darwin" ]; then
        curl -Lks https://micro.mamba.pm/api/micromamba/osx-64/latest | tar -xvj bin/micromamba
    elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
        curl -Lks https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
    fi
    cd $CI_PROJECT_DIR
fi

# Get things set up to run mamba
eval "$($CI_PROJECT_DIR/../tools/bin/micromamba shell hook --shell bash --root-prefix $MAMBA_ROOT_PREFIX)"

# Ensure we have the environment built| grep -q base; then echo "base already exists"; fi
if micromamba info --envs | grep -q saline_build; then
    echo "env already exists"
else
    # Since it wasn't installed create the environment while we are here
    micromamba create -f $CI_PROJECT_DIR/ci/build_env.yml -y
fi
Loading