Skip to content

Averaged excited state EOM-IP-BE #1957

Averaged excited state EOM-IP-BE

Averaged excited state EOM-IP-BE #1957

# Author(s): Minsik Cho, Shaun Weatherly, Oskar Weser
# Based on: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-python
name: Do static analysis and run tests for quemb
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
analysis:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- &checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Check trailing whitespace
run: |
git diff-tree --check $(git hash-object -t tree /dev/null) HEAD -- '(exclude)docs/make.bat'
- &setup-python
name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: setup-clang-format
run: sudo apt install -y clang-format
- &prepare-pip
name: Prepare pip
run: python -m pip install --upgrade pip
- name: Install static analysis deps
run: |
pip install -r tests/static_analysis_requirements.txt
pip install . --config-settings=cmake.args=-DCMAKE_BUILD_TYPE=RelWithDebInfo
- name: Check formatting python
run: ruff format --diff
- name: Check formatting C++
run: find src -type f -regex '.*\.\(cpp\|hpp\|cc\|h\)$' -print0 | xargs -0 -r clang-format --dry-run --Werror
- name: Static analysis python with ruff
run: ruff check .
- name: Static analysis with mypy
run: mypy tests/ example/ src/
compilations:
runs-on: ubuntu-latest
needs: analysis
strategy:
matrix:
compiler: ["gcc", "clang"]
python-version: ["3.12"]
steps:
- *checkout
- *setup-python
- name: Install compiler
run: |
case "${{ matrix.compiler }}" in
gcc)
sudo apt update
sudo apt install -y build-essential
export CXX=g++
;;
clang)
sudo apt update
sudo apt install -y clang libomp-dev
export CXX=clang++
;;
esac
- name: Run build
run: |
python -m pip install --upgrade pip
CXX=${{ matrix.compiler }} pip install --config-settings=cmake.args=-DCMAKE_BUILD_TYPE=Debug .
testsuite:
runs-on: ubuntu-latest
needs: analysis
strategy:
matrix:
python-version: ["3.10", "3.12"]
expensive: [false]
steps:
- *checkout
- *setup-python
- *prepare-pip
- &install-test-deps
name: Install test dependencies
run: |
pip install -r tests/test_requirements.txt
pip install git+https://github.com/pyscf/dmrgscf
PYSCFHOME=$(pip show pyscf-dmrgscf | grep 'Location' | tr ' ' '\n' | tail -n 1)
wget https://raw.githubusercontent.com/pyscf/dmrgscf/master/pyscf/dmrgscf/settings.py.example
mv settings.py.example ${PYSCFHOME}/pyscf/dmrgscf/settings.py
pip install . --config-settings=cmake.args=-DCMAKE_BUILD_TYPE=RelWithDebInfo
- name: Run pytest
run: |
cd tests
${{ matrix.expensive == 'true' && 'QUEMB_DO_EXPENSIVE_TESTS=true' || '' }} \
pytest --durations=0 --durations-min=1.0 --doctest-modules \
--junitxml=junit/quemb-test-results_${{ matrix.python-version }}.xml
- name: Upload pytest junit results
uses: actions/upload-artifact@v4
with:
name: quemb-test-results_${{ matrix.python-version }}
path: tests/junit/quemb-test-results_${{ matrix.python-version }}.xml
testsuite-expensive:
runs-on: ubuntu-latest
needs: testsuite
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
strategy:
matrix:
python-version: ["3.10", "3.12"]
expensive: [true]
steps:
- *checkout
- *setup-python
- *prepare-pip
- *install-test-deps
- name: Run pytest (expensive)
run: |
cd tests
QUEMB_DO_EXPENSIVE_TESTS=true \
pytest --durations=0 --durations-min=1.0 --doctest-modules \
--junitxml=junit/quemb-test-results_${{ matrix.python-version }}.xml
- name: Upload pytest junit results
uses: actions/upload-artifact@v4
with:
name: quemb-test-results-expensive_${{ matrix.python-version }}
path: tests/junit/quemb-test-results_${{ matrix.python-version }}.xml