diff --git a/.github/workflows/unix_linux.yml b/.github/workflows/unix_linux.yml new file mode 100644 index 000000000..020d3a739 --- /dev/null +++ b/.github/workflows/unix_linux.yml @@ -0,0 +1,163 @@ +name: Linux builds + +on: + # allows us to run workflows manually + workflow_dispatch: + pull_request: + branches: + - develop + - master + push: + branches: + - develop + - master + release: + types: # This configuration does not affect the page_build event above + - created +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + building-plugin: + runs-on: ubuntu-latest + strategy: + matrix: + cubit: [2021.4, 2021.5] + os: [ubuntu] + os_version: [20.04, 21.04] + include: + - os: ubuntu + os_version: 18.04 + cubit: 17.1.0 + + - os: debian + os_version: '10.10' # using a 'string' here as the 0 gets rounded away otherwise + cubit: 2021.5 + + + name: 'Cubit ${{ matrix.cubit }} Build for ${{ matrix.os }} ${{ matrix.os_version }} of Svalinn Plugin' + + container: + image: ${{ matrix.os }}:${{ matrix.os_version }} + + steps: + - name: install new git + shell: bash -l {0} + run: | + apt-get update + apt-get install -y software-properties-common curl + if [ "${{ matrix.os }}" == "ubuntu" ]; then + add-apt-repository ppa:git-core/ppa + apt-get update + fi + apt-get install -y git + - uses: actions/checkout@v2 + + - name: Environment Variables + shell: bash -l {0} + run: | + COREFORM_BASE_URL=https://f002.backblazeb2.com/file/cubit-downloads/Coreform-Cubit/Releases + + if [ "${{ matrix.cubit }}" == "17.1.0" ]; then + BASE=Trelis-17.1.0 + BASESDK=Trelis-SDK-17.1.0 + CUBIT_BASE_NAME=Trelis-17.1 + HDF5_PATH=/usr/lib/x86_64-linux-gnu/hdf5/serial + elif [ "${{ matrix.cubit }}" == "2021.4" ]; then + BASE=Coreform-Cubit-2021.4%2B15017_05893177 + CUBIT_BASE_NAME=Coreform-Cubit-2021.4 + HDF5_PATH=/usr/local/HDF_Group/HDF5/1.12.0 + elif [ "${{ matrix.cubit }}" == "2021.5" ]; then + BASE=Coreform-Cubit-2021.5%2B15962_5043ef39 + CUBIT_BASE_NAME=Coreform-Cubit-2021.5 + HDF5_PATH=/usr/local/HDF_Group/HDF5/1.12.0 + fi + + SUFFIX=Lin64 + EXT=deb + echo "SED=sed" >> $GITHUB_ENV + echo "BUILD_SHARED_LIBS=ON" >> $GITHUB_ENV + echo "BUILD_STATIC_LIBS=OFF" >> $GITHUB_ENV + echo "system=linux" >> $GITHUB_ENV + echo "CUBIT_PATH=/opt/${CUBIT_BASE_NAME}" >> $GITHUB_ENV + echo "COREFORM_BASE_URL=${COREFORM_BASE_URL}/Linux/" >> $GITHUB_ENV + echo "HDF5_PATH=${HDF5_PATH}" >> $GITHUB_ENV + + echo "OS=${{ matrix.os }}" >> $GITHUB_ENV + echo "OS_VERSION=${{ matrix.os_version }}" >> $GITHUB_ENV + echo "CMAKE_ADDITIONAL_FLAGS=-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0" >> $GITHUB_ENV + + echo "CUBIT_PKG=${BASE}-${SUFFIX}.${EXT}" >> $GITHUB_ENV + echo "CUBIT_SDK_PKG=${BASESDK}-${SUFFIX}.tar.gz" >> $GITHUB_ENV + echo "CUBIT_BASE_NAME=${CUBIT_BASE_NAME}" >> $GITHUB_ENV + + echo "CURRENT=$(pwd)" >> $GITHUB_ENV + echo "SCRIPTPATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV + echo "PLUGIN_ABS_PATH=$GITHUB_WORKSPACE/.." >> $GITHUB_ENV + echo "FOLDER_PKG=$GITHUB_WORKSPACE/pkg" >> $GITHUB_ENV + + echo "" >> ${HOME}/.bash_profile + echo "source $GITHUB_WORKSPACE/scripts/unix_share_build.sh" >> $HOME/.bash_profile + + - name: Initial setup + shell: bash -l {0} + run: | + ${system}_install_prerequisites + + - name: Downloading packages + shell: bash -l {0} + run: | + mkdir -p $FOLDER_PKG + cd ${FOLDER_PKG} + curl -L ${COREFORM_BASE_URL}${CUBIT_PKG} --output ${CUBIT_PKG} + if [ "${{ matrix.cubit }}" = "17.1.0" ]; then + curl -L ${COREFORM_BASE_URL}${CUBIT_SDK_PKG} --output ${CUBIT_SDK_PKG} + fi + mkdir ${SCRIPTPATH}/release + + - name: Cubit setup + shell: bash -l {0} + run: | + ${system}_setup_cubit ${{ matrix.cubit }} + + - name: Build HDF5 + shell: bash -l {0} + run: | + ${system}_build_hdf5 + + - name: Build MOAB + shell: bash -l {0} + run: | + build_moab + + - name: Build DAGMC + shell: bash -l {0} + run: | + build_dagmc + + - name: Build plugin + shell: bash -l {0} + run: | + build_plugin + + - name: Prepare package + shell: bash -l {0} + run: | + ${system}_build_plugin_pkg ${{ matrix.cubit }} + + - if: github.event_name != 'release' + name: Upload artifact for CI + uses: actions/upload-artifact@v2 + with: + name: svalinn-plugin_${{ matrix.os }}-${{ matrix.os_version }}_cubit_${{ matrix.cubit }}.tgz + path: ${{ github.workspace }}/release/svalinn-plugin_${{ matrix.os }}-${{ matrix.os_version }}_cubit_${{ matrix.cubit }}.tgz + if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` + + - if: github.event_name == 'release' + name: Upload binaries into the release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ github.workspace }}/release/svalinn-plugin_${{ matrix.os }}-${{ matrix.os_version }}_cubit_${{ matrix.cubit }}.tgz + asset_name: svalinn-plugin_${{ matrix.os }}-${{ matrix.os_version }}_cubit_${{ matrix.cubit }}.tgz + tag: ${{ github.ref }} diff --git a/.github/workflows/unix.yml b/.github/workflows/unix_mac.yml similarity index 69% rename from .github/workflows/unix.yml rename to .github/workflows/unix_mac.yml index 4bd938eea..409c02fcf 100644 --- a/.github/workflows/unix.yml +++ b/.github/workflows/unix_mac.yml @@ -1,4 +1,4 @@ -name: Unix +name: Mac builds on: # allows us to run workflows manually @@ -19,20 +19,14 @@ env: jobs: main: - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.os }}-${{ matrix.os_version }} strategy: matrix: cubit: [17.1.0, 2021.4, 2021.5] - os: [ubuntu-20.04, macos-10.15] - include: - - cubit: 17.1.0 - os: ubuntu-18.04 - exclude: - - cubit: 17.1.0 - os: ubuntu-20.04 - - name: 'Cubit Svalinn Plugin ${{ matrix.cubit }} Build for ${{ matrix.os }}' + os: [macos] + os_version: [10.15] + name: 'Cubit ${{ matrix.cubit }} Build for ${{ matrix.os }} ${{ matrix.os_version }} of Svalinn Plugin' steps: - uses: actions/checkout@v2 @@ -57,29 +51,17 @@ jobs: HDF5_PATH=/usr/local/HDF_Group/HDF5/1.12.0 fi - if [[ "${{ matrix.os }}" == "ubuntu"* ]]; then - SUFFIX=Lin64 - EXT=deb - echo "SED=sed" >> $GITHUB_ENV - echo "SUDO=sudo " >> $GITHUB_ENV - echo "BUILD_SHARED_LIBS=ON" >> $GITHUB_ENV - echo "BUILD_STATIC_LIBS=OFF" >> $GITHUB_ENV - echo "system=linux" >> $GITHUB_ENV - echo "CUBIT_PATH=/opt/${CUBIT_BASE_NAME}" >> $GITHUB_ENV - echo "COREFORM_BASE_URL=${COREFORM_BASE_URL}/Linux/" >> $GITHUB_ENV - echo "HDF5_PATH=${HDF5_PATH}" >> $GITHUB_ENV - elif [[ "${{ matrix.os }}" == "mac"* ]]; then - SUFFIX=Mac64 - EXT=dmg - echo "SED=gsed" >> $GITHUB_ENV - echo "BUILD_SHARED_LIBS=OFF" >> $GITHUB_ENV - echo "BUILD_STATIC_LIBS=ON" >> $GITHUB_ENV - echo "system=mac" >> $GITHUB_ENV - echo "CUBIT_PATH=/Applications/${CUBIT_BASE_NAME}.app/Contents" >> $GITHUB_ENV - echo "COREFORM_BASE_URL=${COREFORM_BASE_URL}/MacOS/" >> $GITHUB_ENV - fi + SUFFIX=Mac64 + EXT=dmg + echo "SED=gsed" >> $GITHUB_ENV + echo "BUILD_SHARED_LIBS=OFF" >> $GITHUB_ENV + echo "BUILD_STATIC_LIBS=ON" >> $GITHUB_ENV + echo "system=mac" >> $GITHUB_ENV + echo "CUBIT_PATH=/Applications/${CUBIT_BASE_NAME}.app/Contents" >> $GITHUB_ENV + echo "COREFORM_BASE_URL=${COREFORM_BASE_URL}/MacOS/" >> $GITHUB_ENV echo "OS=${{ matrix.os }}" >> $GITHUB_ENV + echo "OS_VERSION=${{ matrix.os_version }}" >> $GITHUB_ENV echo "CMAKE_ADDITIONAL_FLAGS=-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0" >> $GITHUB_ENV echo "CUBIT_PKG=${BASE}-${SUFFIX}.${EXT}" >> $GITHUB_ENV @@ -144,14 +126,15 @@ jobs: name: Upload artifact for CI uses: actions/upload-artifact@v2 with: - name: svalinn-plugin_${{ matrix.os }}_cubit_${{ matrix.cubit }}.tgz - path: ${{ github.workspace }}/release/svalinn-plugin_${{ matrix.os }}_cubit_${{ matrix.cubit }}.tgz + name: svalinn-plugin_${{ matrix.os }}-${{ matrix.os_version }}_cubit_${{ matrix.cubit }}.tgz + path: ${{ github.workspace }}/release/svalinn-plugin_${{ matrix.os }}-${{ matrix.os_version }}_cubit_${{ matrix.cubit }}.tgz + if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` - if: github.event_name == 'release' name: Upload binaries into the release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ${{ github.workspace }}/release/svalinn-plugin_${{ matrix.os }}_cubit_${{ matrix.cubit }}.tgz - asset_name: svalinn-plugin_${{ matrix.os }}_cubit_${{ matrix.cubit }}.tgz + file: ${{ github.workspace }}/release/svalinn-plugin_${{ matrix.os }}-${{ matrix.os_version }}_cubit_${{ matrix.cubit }}.tgz + asset_name: svalinn-plugin_${{ matrix.os }}-${{ matrix.os_version }}_cubit_${{ matrix.cubit }}.tgz tag: ${{ github.ref }} diff --git a/scripts/unix_share_build.sh b/scripts/unix_share_build.sh index 5a31bb888..c3fbe86c8 100644 --- a/scripts/unix_share_build.sh +++ b/scripts/unix_share_build.sh @@ -12,7 +12,7 @@ # - SUDO : specify the command prefix to run as root (if any) # - SED : command to run sed (usually sed for linux, gsed for mac) # - OS : reference to the Operating system, used to name the plugin tarball (and when using setup_var() function) - +# - OS_VERSION : reference to the Operating system version, used to name the plugin tarball (and when using setup_var() function) set -ex @@ -25,9 +25,9 @@ function mac_install_prerequisites() { brew install eigen gcc@6 gsed } -function ubuntu_version() { - export UBUNTU_VERSION=$(lsb_release -rs |cut -d"." -f1) - echo "Ubuntu Version: " $UBUNTU_VERSION +function unix_version() { + export LINUX_VERSION=$(lsb_release -rs |cut -d"." -f1) + echo "Linux Version: " $LINUX_VERSION } function linux_install_prerequisites() { @@ -35,9 +35,16 @@ function linux_install_prerequisites() { $SUDO ln -snf /usr/share/zoneinfo/$TZ /etc/localtime $SUDO sh -c 'echo $TZ > /etc/timezone' $SUDO apt-get update -y - $SUDO apt-get install -y g++ libeigen3-dev patchelf git cmake curl lsb-release python3 lsb-core + if [ "$OS" == "ubuntu" ]; then + $SUDO apt-get install -y g++ libeigen3-dev patchelf git cmake curl lsb-release python3 lsb-core + fi + if [ "$OS" == "debian" ]; then + $SUDO apt-get install -y g++ libeigen3-dev patchelf git cmake curl lsb-release python3 + fi $SUDO update-alternatives --install /usr/bin/python python /usr/bin/python3 10; \ + if [ $LINUX_VERSION -lt 21 ] && [ "$OS" == "ubuntu" ]; then $SUDO update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 10; \ + fi } function setup() { @@ -72,28 +79,31 @@ function setup_var() { return 1 fi - if [ "OS" == "MAC" ]; then + if [ "$OS" == "MAC" ]; then BUILD_SHARED_LIBS="OFF" BUILD_STATIC_LIBS="ON" - elif [ "OS" == "UBUNTU"]; then + elif [ "$OS" == "ubuntu"]; then + BUILD_SHARED_LIBS="ON" + BUILD_STATIC_LIBS="OFF" + elif [ "$OS" == "debian"]; then BUILD_SHARED_LIBS="ON" BUILD_STATIC_LIBS="OFF" else - echo "OS ENV variable needs to be defined to either UBUNTU or MAC" + echo "OS ENV variable needs to be defined to either UBUNTU, DEBIAN or MAC" return 1 fi } function linux_build_hdf5() { # if ubuntu 18.04 or lower rely on apt-get hdf5 - ubuntu_version - if [ $UBUNTU_VERSION -lt 20 ]; then + unix_version + if [ $LINUX_VERSION -lt 20 ] && [ "$OS" == "ubuntu" ]; then $SUDO apt-get install -y libhdf5-serial-dev else cd ${PLUGIN_ABS_PATH} mkdir -p hdf5/bld cd hdf5 - git clone https://github.com/HDFGroup/hdf5.git -b hdf5-1_12_0 --depth 1 + git clone https://github.com/HDFGroup/hdf5.git -b hdf5-1_12_0 --depth 1 --shallow-submodules cd bld cmake ../hdf5 -DBUILD_SHARED_LIBS:BOOL=ON make @@ -110,7 +120,7 @@ function build_moab() { cd ${PLUGIN_ABS_PATH} mkdir -pv moab/bld cd moab - git clone https://bitbucket.org/fathomteam/moab -b 5.3.0 --depth 1 + git clone https://bitbucket.org/fathomteam/moab -b 5.3.0 --depth 1 --shallow-submodules cd moab # patching MOAB CMakeLists.txt to use default find(HDF5) $SED -i "s/HDF5_MOAB/HDF5/" CMakeLists.txt @@ -134,7 +144,7 @@ function build_dagmc(){ cd ${PLUGIN_ABS_PATH} mkdir -pv DAGMC/bld cd DAGMC - git clone https://github.com/svalinn/DAGMC -b develop --depth 1 + git clone https://github.com/svalinn/DAGMC -b develop --depth 1 --shallow-submodules cd bld cmake ../DAGMC -DMOAB_DIR=${PLUGIN_ABS_PATH}/moab \ -DBUILD_UWUW=ON \ @@ -262,9 +272,10 @@ function linux_build_plugin_pkg(){ cd .. ln -sv svalinn/libsvalinn_plugin.so . cd ../.. - tar --sort=name -czvf svalinn-plugin_${OS}_cubit_$1.tgz bin - chmod 666 svalinn-plugin_${OS}_cubit_$1.tgz - cp svalinn-plugin_${OS}_cubit_$1.tgz $SCRIPTPATH/release/ + PLUGIN_FILENAME=svalinn-plugin_${OS}-${OS_VERSION}_cubit_$1.tgz + tar --sort=name -czvf ${PLUGIN_FILENAME} bin + chmod 666 ${PLUGIN_FILENAME} + cp ${PLUGIN_FILENAME} $SCRIPTPATH/release/ } function mac_build_plugin_pkg(){ @@ -287,12 +298,12 @@ function mac_build_plugin_pkg(){ install_name_tool -rpath ${CUBIT_PATH}/bin ${CUBIT_PATH}/MacOS libsvalinn_plugin.so fi - # Create the Svalinn plugin tarball cd .. ln -sv svalinn/libsvalinn_plugin.so . cd ../.. - tar -czvf svalinn-plugin_${OS}_cubit_${1}.tgz MacOS - chmod 666 svalinn-plugin_${OS}_cubit_$1.tgz - cp svalinn-plugin_${OS}_cubit_$1.tgz $SCRIPTPATH/release/ + PLUGIN_FILENAME=svalinn-plugin_${OS}-${OS_VERSION}_cubit_$1.tgz + tar -czvf ${PLUGIN_FILENAME} MacOS + chmod 666 ${PLUGIN_FILENAME} + cp ${PLUGIN_FILENAME} $SCRIPTPATH/release/ }