CI #1888
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
paths-ignore: | |
- "README.md" | |
- "**/docs/**" | |
- ".github/workflows/docs.yml" | |
pull_request: | |
branches: | |
- master | |
- dev | |
schedule: | |
- cron: "0 11 * * *" | |
jobs: | |
skip_duplicate: | |
runs-on: ubuntu-latest | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
steps: | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@master | |
with: | |
github_token: ${{ github.token }} | |
concurrent_skipping: never | |
skip_after_successful_duplicate: true | |
paths_ignore: '["**/README.md", "**/docs/**"]' | |
do_not_skip: '["pull_request", "schedule"]' | |
test-pip: | |
name: Test with Pip install | |
needs: skip_duplicate | |
if: ${{ needs.skip_duplicate.outputs.should_skip == 'false' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.9", "3.10", "3.11"] | |
os: ["ubuntu-latest", "macos-latest", "macos-12"] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip wheel | |
pip install --upgrade flake8 coverage pytest-cov cython | |
if [[ ${{matrix.os}} == macos-latest ]]; | |
then | |
brew update | |
brew install hdf5 | |
fi | |
pip install -e . | |
- name: Lint with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 | |
- name: Test pip on ${{ matrix.python-version }} | |
run: | | |
python -m pytest -vv --cov=astromodels/ --cov-report=xml --junitxml=junit/test-results.xml | |
env: | |
OMP_NUM_THREADS: 1 | |
MKL_NUM_THREADS: 1 | |
NUMEXPR_NUM_THREADS: 1 | |
MPLBACKEND: "Agg" | |
- name: Publish Unit Test Results Ubuntu | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: runner.os == 'Linux' | |
with: | |
files: junit/test-*.xml | |
comment_mode: off | |
- name: Publish Unit Test Results MacOS | |
uses: EnricoMi/publish-unit-test-result-action/composite@v2 | |
if: runner.os == 'macOS' | |
with: | |
files: junit/test-*.xml | |
comment_mode: off | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
file: ./coverage.xml | |
files: ./coverage1.xml,./coverage2.xml | |
directory: ./coverage/reports/ | |
test-conda: | |
name: Test Conda version | |
needs: skip_duplicate | |
if: ${{ needs.skip_duplicate.outputs.should_skip == 'false' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ["ubuntu-latest", "macos-latest", "macos-12"] | |
python-version: [3.9] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# - name: Cache conda | |
# uses: actions/cache@v4 | |
# env: | |
# # Increase this value to reset cache if etc/example-environment.yml has not changed | |
# CACHE_NUMBER: 0 | |
# with: | |
# path: ~/conda_pkgs_dir | |
# key: conda-${{ matrix.os }}-python-${{ matrix.python-version }}-${{ hashFiles('ci/environment.yml') }} | |
- name: Add conda ${{ matrix.python-version }} to system path | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
activate-environment: "test_env" | |
auto-activate-base: false | |
architecture: "x64" | |
#mamba-version: "*" | |
miniforge-version: latest | |
python-version: ${{ matrix.python-version }} | |
auto-update-conda: true | |
environment-file: ci/environment.yml | |
use-only-tar-bz2: true | |
channel-priority: strict | |
channels: conda-forge, xspecmodels | |
- name: Init Env | |
shell: bash -l {0} | |
run: | | |
# Make sure we fail in case of error | |
if [[ ${{matrix.os}} == ubuntu-latest ]]; | |
then | |
miniconda_os=Linux | |
compilers="gcc_linux-64 gxx_linux-64 gfortran_linux-64" | |
else # osx | |
miniconda_os=MacOSX | |
compilers="clang_osx-64 clangxx_osx-64 gfortran_osx-64" | |
# On macOS we also need the conda libx11 libraries used to build xspec | |
# We also need to pin down ncurses, for now only on macos. | |
xorg="xorg-libx11" | |
fi | |
export PKG_VERSION=$(python -c "import versioneer;print(versioneer.get_version())") | |
mamba install ${PKG} codecov pytest-cov git flake8 | |
- name: Conda list | |
shell: bash -l {0} | |
run: | | |
conda list | |
- name: install it | |
shell: bash -l {0} | |
run: | | |
pip install -e . | |
- name: Lint with flake8 | |
shell: bash -l {0} | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 | |
- name: Test conda install | |
shell: bash -l {0} | |
run: | | |
echo "======> importing XSPEC..." | |
python -c "import astromodels.xspec" | |
python -m pytest -vv --cov=astromodels --cov-report=xml | |
env: | |
OMP_NUM_THREADS: 1 | |
MKL_NUM_THREADS: 1 | |
NUMEXPR_NUM_THREADS: 1 | |
MPLBACKEND: "Agg" | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
file: ./coverage.xml | |
files: ./coverage1.xml,./coverage2.xml | |
directory: ./coverage/reports/ | |