Commit 4304cdc6 authored by Henderson, Shane's avatar Henderson, Shane
Browse files

Changes configuration to allow package relocation

parent 691e39cc
Loading
Loading
Loading
Loading
+126 −22
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:
    - pip install delocate
    - 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"
    - cmake --install build --prefix install
    - delocate-wheel -w ${CI_PROJECT_DIR}/install/wheelhouse ${CI_PROJECT_DIR}/build/src/python/dist/SalinePy*.whl
  artifacts:
    name: darwin_x86
    expire_in: 1 week
    paths:
      - install

.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:
    - pip install delvewheel
    - cmake
      -S $CI_PROJECT_DIR
      -B build
      -Dsaline_ENABLE_Fortran=OFF
      -Dsaline_ENABLE_Python=ON
      -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE
    - cmake --build build --target ALL_BUILD --config RELEASE
    - ctest --build-config RELEASE --test-dir build
    - cmake --install build --prefix install
    - $WHL_FILE = (Get-Item ${CI_PROJECT_DIR}\build\src\python\dist\*.whl).FullName
    - delvewheel repair -w ${CI_PROJECT_DIR}/install/wheelhouse ${WHL_FILE}
  artifacts:
    name: windows_x86
    expire_in: 1 week
    paths:
      - build/
      - TriBITS/
      - googletest/
      - testframework/
    expire_in: 1 day
      - install

linux_gcc83_testing:
  stage: test
build_linux:
  stage: build
  rules:
    - when: always
  tags:
    - linux
    - gcc
    - warroom10
  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
    - pip install auditwheel
    - pip install patchelf
    - cmake -S $CI_PROJECT_DIR -B build -DCMAKE_BUILD_TYPE=RELEASE
      -Dsaline_ENABLE_Fortran=ON -DCMAKE_Fortran_FLAGS:STRING="-ffree-line-length-none"
      -Dsaline_ENABLE_Python=ON
    - cmake --build build
    - ctest --test-dir build
    - cmake --install build --prefix install
    - auditwheel repair -w ${CI_PROJECT_DIR}/install/wheelhouse --plat manylinux_2_34_x86_64 ${CI_PROJECT_DIR}/build/src/python/dist/SalinePy*.whl
  artifacts:
    name: linux_x86
    expire_in: 1 week
    paths:
      - install

        #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:
      #- tar -czvf linux_x86.tar.gz ./install
      #- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file darwin_x86.tar.gz  "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/my_package/0.0.1/darwin_x86.tar.gz"'
      #- WHL_FILE=${CI_PROJECT_DIR}/build/src/python/dist/SalinePy*.whl
      #- TWINE_USERNAME=gitlab-ci-token TWINE_PASSWORD=${CI_JOB_TOKEN} python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi ${WHL_FILE}
        #
      #- tar -czvf windows_x86.tar.gz ./install
      #- Invoke-RestMethod -Headers @{ "JOB-TOKEN"="$CI_JOB_TOKEN" } -InFile windows_x86.tar.gz -uri "${CI_API_V4_URL}/projects/5955/packages/generic/my_package/0.0.1/windows_x86.tar.gz" -Method put
      #- twine upload -u gitlab-ci-token -p ${CI_JOB_TOKEN} --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi ${CI_PROJECT_DIR}\build\src\python\dist\${WHL_FILE}
        #
      #- tar -czvf linux_x86.tar.gz ./install
      #- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file linux_x86.tar.gz "${CI_API_V4_URL}/projects/5955/packages/generic/my_package/0.0.1/linux_x86.tar.gz"'
      #- WHL_FILE=${CI_PROJECT_DIR}/build/src/python/dist/SalinePy*.whl
      #- TWINE_USERNAME=gitlab-ci-token TWINE_PASSWORD=${CI_JOB_TOKEN} python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi ${WHL_FILE}
+7 −5
Original line number Diff line number Diff line
@@ -4,8 +4,10 @@
#             Molten Salt Thermophysical Properties Interpolation              #
################################################################################
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)

#First pass automated version increment
project(saline
  VERSION 0.0.1
  VERSION 0.1.0
  DESCRIPTION "MSTDB-TP API"
  LANGUAGES CXX
)
@@ -18,10 +20,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 | 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