Skip to content

CI

CI #921

Workflow file for this run

name: CI
on:
push:
# Run CI on all pushed branches.
branches: "*"
# Run CI on all versioned tags.
tags: "[0-9]+.[0-9]+.[0-9]+"
# Run CI nightly at 03:00 PST (11:00 UTC).
schedule:
- cron: "0 11 * * *"
# Allow maintainers to manually trigger the build.
workflow_dispatch: {}
jobs:
test:
name: Test on py${{ matrix.python-version }}/${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macOS-latest, ubuntu-latest, macOS-13]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
# Cache our conda packages.
# More info: https://github.com/conda-incubator/setup-miniconda#caching-packages
- name: Cache conda environment
uses: actions/cache@v3
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-py${{ matrix.python-version }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }}
# More info on options: https://github.com/conda-incubator/setup-miniconda
- name: Set up Anaconda environment
uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
environment-file: environment.yml
channels: conda-forge,defaults
activate-environment: mdsapt
auto-update-conda: false
auto-activate-base: false
#use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
# TODO: make pyright happier someday in the future
# - name: Type-check
# shell: bash -l {0}
# run: |
# pyright mdsapt
- name: Run tests
shell: bash -l {0}
run: |
pytest -v ./mdsapt --cov=mdsapt --cov-report=xml
- name: Upload CodeCov
uses: codecov/codecov-action@v2
with:
file: ./coverage.xml
flags: unittests
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }}
- name: Install MDSAPT package
shell: bash -l {0}
run: |
python -m pip install . --no-deps
conda list
package:
name: Packaging py${{ matrix.python-version }}/${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: test
if: startsWith(github.ref, 'refs/tags') # only do this on tags
strategy:
fail-fast: true
matrix:
os: [macOS-13, ubuntu-latest]
python-version: [3.9, 3.10, 3.11, 3.12]
include:
- os: macOS-latest
output-folder: osx-64
- os: ubuntu-latest
output-folder: linux-64
steps:
- uses: actions/checkout@v2
# Cache our conda packages.
# More info: https://github.com/conda-incubator/setup-miniconda#caching-packages
- name: Cache conda environment
uses: actions/cache@v2
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-py${{ matrix.python-version }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('devtools/deploy/environment.yml') }}
# More info on options: https://github.com/conda-incubator/setup-miniconda
- name: Set up Anaconda environment
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
environment-file: devtools/deploy/environment.yml
channels: psi4,conda-forge
activate-environment: mdsapt-build
auto-update-conda: false
auto-activate-base: false
#use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
- name: Build MDSAPT conda package
# conda requires this special shell
shell: bash -l {0}
run: conda build -c psi4 -c conda-forge --output-folder . .
- name: Upload MDSAPT conda package
# conda requires this special shell
shell: bash -l {0}
if: startsWith(github.ref, 'refs/tags') # only do this on tags
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
run: anaconda upload --label main ${{ matrix.output-folder }}/*.tar.bz2
verify:
name: Test installing py${{ matrix.python-version }}/${{ matrix.os }}
runs-on: ${{ matrix.os }}
if: startsWith(github.ref, 'refs/tags') # only do this on tags
needs: package
strategy:
fail-fast: false
matrix:
os: [macOS-latest, macOS-13, ubuntu-latest]
python-version: [3.9, 3.10, 3.11, 3.12]
steps:
- uses: actions/checkout@v2
# More info on options: https://github.com/conda-incubator/setup-miniconda
- name: Create Anaconda environment
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
activate-environment: mdsapt-test
auto-update-conda: false
auto-activate-base: false
- name: Install mdsapt from mdsapt-testing
shell: bash -l {0}
# NOTE: psi4 must be first channel
run: >
conda install -c psi4 -c defaults -c conda-forge -c mdsapt-testing mdsapt
- name: Test importing mdsapt
shell: bash -l {0}
run: >
python3 -c "import mdsapt"
lint-and-format:
# These checks are much faster and don't actually need to install any packages.
name: Run fast checks over code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install formatter and linter
run: |
pip install autopep8 pylint
- name: Lint code
run: |
pylint --fail-under=9.5 --disable=E,R mdsapt
- name: Ensure formatting
run: |
autopep8 -r mdsapt --diff --exit-code