Skip to content

Commit

Permalink
Merge pull request #170 from NCAR/github_actions
Browse files Browse the repository at this point in the history
Added Github Actions workflow for CI tests
  • Loading branch information
erogluorhan committed May 11, 2022
2 parents b196383 + 0043f75 commit 8a96101
Show file tree
Hide file tree
Showing 10 changed files with 16,549 additions and 71 deletions.
6 changes: 6 additions & 0 deletions .build/Site.local.template
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
${CAIROLIB}
${CAIROLIBUSER}

#undef CCompiler
#undef FCompiler
#undef CxxCompiler
#undef CppCommand
#undef LdCommand

#define CCompiler "${CC}"
#define FCompiler "${FC}"
#define CxxCompiler "${CXX}"
Expand Down
8 changes: 7 additions & 1 deletion .build/conda_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ export RECIPE_DIR="${SRC_DIR}/$(basename "${RECIPE_DIR}")"

cd ${SRC_DIR}

conda env create -f "${RECIPE_DIR}/envs/`uname`.yml" 2>/dev/null
#conda env create -f "${RECIPE_DIR}/envs/`uname`.yml" 2>/dev/null
. "$(conda info --base)/etc/profile.d/conda.sh"
#eval "$(micromamba shell hook --shell=bash)"
#micromamba shell init --shell=bash --prefix=~/micromamba
source activate ncl_build 2>/dev/null || conda activate ncl_build

conda list

export PREFIX="${CONDA_PREFIX}"
export CXXFLAGS="-fPIC $CXXFLAGS"
Expand Down Expand Up @@ -75,3 +79,5 @@ mkdir -p "$DEACTIVATE_DIR"

cp "$RECIPE_DIR/scripts/activate.sh" "$ACTIVATE_DIR/ncl-activate.sh"
cp "$RECIPE_DIR/scripts/deactivate.sh" "$DEACTIVATE_DIR/ncl-deactivate.sh"

conda list
4 changes: 3 additions & 1 deletion .build/envs/Darwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ channels:
- conda-forge
dependencies:
- clang_osx-64
- clangcxx_osx-64
- clangxx_osx-64
- esmf
- gfortran_osx-64
- pkg-config
- blas=1.1=openblas
Expand All @@ -14,6 +15,7 @@ dependencies:
- hdf5
- hdfeos2
- hdfeos5
- imagemagick
- jasper
- jpeg
- libgdal
Expand Down
2 changes: 2 additions & 0 deletions .build/envs/Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ dependencies:
- bzip2
- cairo
- curl
- esmf
- freetype
- gsl
- hdf4
- hdf5
- hdfeos2
- hdfeos5
- imagemagick
- jasper
- jpeg
- libgdal
Expand Down
80 changes: 80 additions & 0 deletions .build/mamba_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/sh
unsetopt EQUALS 2>/dev/null

RECIPE_DIR="$(dirname "$0")"
export SRC_DIR="$(cd `dirname ${RECIPE_DIR}`; pwd)"
export RECIPE_DIR="${SRC_DIR}/$(basename "${RECIPE_DIR}")"

cd ${SRC_DIR}

#. "$(conda info --base)/etc/profile.d/conda.sh"
eval "$(micromamba shell hook --shell=bash)"
micromamba shell init --shell=bash --prefix=~/micromamba
source activate ncl_build 2>/dev/null || micromamba activate ncl_build

export PREFIX="${CONDA_PREFIX}"
export CXXFLAGS="-fPIC $CXXFLAGS"
export LDFLAGS="-L${PREFIX}/lib $LDFLAGS"
export CPPFLAGS="-I${PREFIX}/include $CPPFLAGS"
export CFLAGS="-I${PREFIX}/include $CFLAGS"

if [ "$(uname)" = "Darwin" ]; then
export CC="${CLANG}"
export CPP="${CLANG} -E -traditional"
export CXX="${CLANG}++"
export FC

if [ -d "/opt/X11" ]; then
x11_lib="-L/opt/X11/lib"
x11_inc="-I/opt/X11/include -I/opt/X11/include/freetype2"

CAIROLIB="#define CAIROlib /opt/X11/lib/libcairo.2.dylib /opt/X11/lib/libfontconfig.1.dylib /opt/X11/lib/libpixman-1.0.dylib /opt/X11/lib/libfreetype.6.dylib -lXrender -lexpat -lpng -lz -liconv -lbz2 -lpthread"
CAIROLIBUSER="#define CAIROlibuser /opt/X11/lib/libcairo.2.dylib /opt/X11/lib/libfontconfig.1.dylib /opt/X11/lib/libpixman-1.0.dylib /opt/X11/lib/libfreetype.6.dylib -lXrender -lexpat -lpng -lz -liconv -lbz2 -lpthread"
else
echo "No X11 libs found. Exiting..." 1>&2
exit
fi

LDFLAGS="-headerpad_max_install_names $LDFLAGS"
conf_file=config/Darwin_Intel
elif [ "$(uname)" = "Linux" ]; then
export CC="$GCC"
export CPP="${CPP} -traditional"
export CXX="$GXX"
export FC

conf_file=config/LINUX
fi

export EXTRA_LDFLAGS="$LDFLAGS"

export grib2_dir=${SRC_DIR}/external/g2clib-1.6.0
export EXTRA_INCLUDES=-I${grib2_dir}

# fix malformed sed subsitutions
sed -e 's/+/|/g' -i.backup ni/src/scripts/yMakefile
sed -e 's/+/|/g' -i.backup ni/src/ncl/yMakefile


# fix path to cpp in ymake -- we should fix this in NCL
sed -e "s|^\( set cpp = \)/lib/cpp$|\1'$CPP'|g" -i.backup config/ymake


# generate Site.local
sed -e "s|\${PREFIX}|${PREFIX}|g" -e "s|\${x11_inc}|${x11_inc}|g" -e "s|\${x11_lib}|${x11_lib}|g" -e "s|\${CAIROLIB}|${CAIROLIB}|g" -e "s|\${CAIROLIBUSER}|${CAIROLIBUSER}|g" -e "s|\${grib2_dir}|${grib2_dir}|g" -e "s|\${CC}|${CC}|g" -e "s|\${FC}|${FC}|g" -e "s|\${CPP}|${CPP}|g" -e "s|\${CXX}|${CXX}|g" -e "s|\${LD}|${LD}|g" "${RECIPE_DIR}/Site.local.template" > config/Site.local

patch -N -p1 < ${RECIPE_DIR}/grib2.patch >/dev/null 2>&1

echo -e "n\n" | ./Configure
make Everything

ACTIVATE_DIR="$PREFIX/etc/conda/activate.d"
DEACTIVATE_DIR="$PREFIX/etc/conda/deactivate.d"

mkdir -p "$ACTIVATE_DIR"
mkdir -p "$DEACTIVATE_DIR"

cp "$RECIPE_DIR/scripts/activate.sh" "$ACTIVATE_DIR/ncl-activate.sh"
cp "$RECIPE_DIR/scripts/deactivate.sh" "$DEACTIVATE_DIR/ncl-deactivate.sh"

conda list
69 changes: 0 additions & 69 deletions .circleci/config.yml

This file was deleted.

80 changes: 80 additions & 0 deletions .github/workflows/ci_conda.yml_conflicts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI (conda)
on:
push:
branches:
- 'develop'
- 'master'
pull_request:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Daily “At 00:00”

jobs:
test:
name: (${{ matrix.os }})
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}

strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest", "macos-latest"]

steps:
- uses: actions/checkout@v2

- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Install tcsh and byacc (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install tcsh
sudo apt-get install byacc

- name: Install dependencies (Darwin)
if: matrix.os == 'macos-latest'
run: |
brew update
brew install --cask xquartz

- name: Conda setup
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: ncl_build
python-version: 3.7
channels: conda-forge

- name: Conda install (Darwin)
if: matrix.os == 'macos-latest'
run: |
conda env update --file .build/envs/Darwin.yml --prune

- name: Conda install (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
conda env update --file .build/envs/Linux.yml --prune

- name: Conda install additional dependencies
run: |
conda install -n ncl_build -c conda-forge imagemagick esmf

- name: Conda install libgdal=2.4
run: |
conda install -n ncl_build -c conda-forge libgdal=2.4

- name: Build ncl
run: |
bash .build/conda_build.sh

- name: Run tests
run: |
test "`ncl -V`" = "`cat version`"
git clone https://github.com/NCAR/ncl_ci_test
cd ncl_ci_test
source run_tests.bash
76 changes: 76 additions & 0 deletions .github/workflows/ci_mamba.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: CI (mamba)
on:
push:
branches:
- 'develop'
- 'master'
pull_request:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Daily “At 00:00”

jobs:
test:
name: (${{ matrix.os }})
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}

strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest", "macos-latest"]

steps:
- uses: actions/checkout@v2

- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Install tcsh and byacc (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install tcsh
sudo apt-get install byacc
- name: Install dependencies (Darwin)
if: matrix.os == 'macos-latest'
run: |
brew update
brew install --cask xquartz
- name: Create mamba environment (Darwin)
if: matrix.os == 'macos-latest'
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
uses: mamba-org/provision-with-micromamba@main
with:
micromamba-version: "latest"
environment-name: ncl_build
environment-file: .build/envs/Darwin.yml

- name: Create mamba environment (Linux)
if: matrix.os == 'ubuntu-latest'
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
uses: mamba-org/provision-with-micromamba@main
with:
micromamba-version: "latest"
environment-name: ncl_build
environment-file: .build/envs/Linux.yml

- name: Build ncl
run: |
bash .build/mamba_build.sh
- name: Run tests
run: |
ncl -V
test "`ncl -V`" = "`cat version`"
git clone https://github.com/NCAR/ncl_ci_test
cd ncl_ci_test
bash run_tests.bash
Loading

0 comments on commit 8a96101

Please sign in to comment.