From ae5061ba098f6ee439640ff8a95a075678c64ece Mon Sep 17 00:00:00 2001 From: Jesse Mapel <jmapel@usgs.gov> Date: Fri, 19 Mar 2021 10:12:45 -0700 Subject: [PATCH] Getting github actions CI working (#412) * Update ci_testing.yml * Added flag to not activate base * Added default to bash shell * Update ci_testing.yml * Removed os walk to get data dir * Add submodule checkout * Run ctest in build directory * Added build matrix * Disabled fast-fail * Axe python 3.6 build * Adding coveralls step * Switching to codecov.io * Axed Travis and added Python coverage * Added pytest-cov * Only upload coverage once * Testing adding windows * Disabled windows pytest for now * Testing different Python component * Removed windows CI for now * Trigger on push --- .github/workflows/ci_testing.yml | 36 ++++++++++++++++--- .travis.yml | 61 -------------------------------- environment.yml | 1 + tests/pytests/conftest.py | 7 ++-- 4 files changed, 35 insertions(+), 70 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/ci_testing.yml b/.github/workflows/ci_testing.yml index fee3c9b..ed7d728 100644 --- a/.github/workflows/ci_testing.yml +++ b/.github/workflows/ci_testing.yml @@ -4,30 +4,56 @@ on: pull_request: branches: - master + push: + branches: + - master jobs: - Continuous-Integration: - runs-on: ubuntu-latest + Build-and-Test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + python-version: ["3.7", "3.8", "3.9"] + defaults: + run: + shell: bash -l {0} steps: - uses: actions/checkout@v2 + with: + submodules: true - uses: conda-incubator/setup-miniconda@v2 with: miniconda-version: "latest" activate-environment: ale environment-file: environment.yml + auto-activate-base: false + auto-update-conda: true + python-version: ${{ matrix.python-version }} + - name: Check build environment + run: | + conda list - name: Install Python Package run: | python setup.py install - name: Test Python Package run: | - pytest tests/pytests -vv + pytest --cov-report=xml --cov=ale tests/pytests -vv - name: Build C++ Package run: | mkdir -p build cd build - cmake -DCMAKE_BUILD_TYPE=RELEASE .. + cmake -DCMAKE_BUILD_TYPE=RELEASE -DCOVERAGE=ON .. cmake --build . - name: Test C++ Package run: | + cd build ctest -VV - + - name: Upload Coverage + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true + verbose: true + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.9' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 26de9b5..0000000 --- a/.travis.yml +++ /dev/null @@ -1,61 +0,0 @@ -language: cpp -sudo: false - -branches: - only: - - master - -matrix: - include: - - os: linux - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-7 - env: - - MATRIX_EVAL="CXX=g++-7 && CC=gcc-7" - - os: osx - osx_image: xcode9.4 - env: - - MATRIX_EVAL="CXX=clang++ && CC=clang" - -before_install: - - echo "$TRAVIS_PULL_REQUEST" - - eval "${MATRIX_EVAL}" - - | - if [ "$TRAVIS_OS_NAME" == "linux" ]; then - pip install --user cpp-coveralls; - fi - -install: - # Install a supported cmake version (>= 3.10) - - | - if [ "$TRAVIS_OS_NAME" == "linux" ]; then - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; - else - curl -o miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh; - fi - - bash miniconda.sh -b -p $HOME/miniconda - - export PATH="$HOME/miniconda/bin:$PATH" - - conda config --set always_yes yes - - conda env create -n ale - - conda env update -f environment.yml -n ale - - source activate ale - - conda install pytest - -script: - - PYTHONPATH=. pytest tests/pytests -vv - - python setup.py install # install to use python lib in c code - - mkdir -p build - - cd build - - cmake -DCMAKE_BUILD_TYPE=RELEASE -DCOVERAGE=ON .. - - cmake --build . - - ctest -VV - -after_success: - - | - if [ "$TRAVIS_OS_NAME" == linux ]; then - coveralls --root $(dirname $PWD) -i src/ --verbose; - fi diff --git a/environment.yml b/environment.yml index b86dfe6..2d4e741 100644 --- a/environment.yml +++ b/environment.yml @@ -18,5 +18,6 @@ dependencies: - spiceypy>=2.3.0 - pyyaml - pytest + - pytest-cov - networkx - breathe diff --git a/tests/pytests/conftest.py b/tests/pytests/conftest.py index 9c33638..ea183c9 100644 --- a/tests/pytests/conftest.py +++ b/tests/pytests/conftest.py @@ -5,13 +5,13 @@ import warnings import numpy as np import json import pvl +from glob import glob +from pathlib import Path import ale from ale.base.data_isis import read_table_data -from glob import glob - class SimpleSpice(): def scs2e(self, *args): return 0.1 @@ -73,8 +73,7 @@ def compare_dicts(ldict, rdict): differences.append(f'Values of key {key} are not equal {item} : {rdict[key]}.') return differences -ale_root = os.path.split(ale.__file__)[0] -data_root = os.path.join(ale_root, '../tests/pytests/data') +data_root = os.path.join(Path(__file__).parent.absolute(), 'data') dirs = next(os.walk(data_root, topdown=True))[1] dirs = [d for d in dirs if not d.startswith('.')] image_2_data = {} -- GitLab