Add Persistence #110
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: GH Actions CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
schedule: | |
# Weekly tests at midnight on Sundays: | |
- cron: "0 0 * * 0" | |
concurrency: | |
group: ${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash -l {0} | |
jobs: | |
main-tests: | |
if: github.repository == 'yuxuanzhuang/ggmolvis' | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
mdanalysis-version: ["latest", "develop"] | |
molecular-nodes-version: ["main", "v4.2.9", "v4.2.10"] | |
python-version: ["3.11"] | |
exclude: | |
# Temporarily skip Windows with "latest" MDAnalysis version | |
- os: windows-latest | |
mdanalysis-version: "latest" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build information | |
run: | | |
uname -a | |
df -h | |
ulimit -a | |
- name: Set MolecularNodes version | |
run: | | |
cp devtools/conda-envs/test_env.yaml devtools/conda-envs/test_env_temp.yaml | |
perl -pi -e "s/v4.2.9/${{ matrix.molecular-nodes-version }}/g" devtools/conda-envs/test_env_temp.yaml | |
- name: Install conda dependencies | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
environment-file: devtools/conda-envs/test_env_temp.yaml | |
add-pip-as-python-dependency: true | |
miniforge-variant: Miniforge3 | |
use-mamba: true | |
channels: conda-forge, defaults | |
activate-environment: ggmolvis-test | |
auto-update-conda: true | |
auto-activate-base: false | |
show-channel-urls: true | |
- name: Install MDAnalysis version | |
uses: MDAnalysis/install-mdanalysis@main | |
with: | |
version: ${{ matrix.mdanalysis-version }} | |
install-tests: true | |
installer: mamba | |
shell: bash -l {0} | |
- name: Install package | |
run: | | |
python --version | |
python -m pip install . --no-deps | |
- name: Python information | |
run: | | |
which python | |
which pip | |
pip list | |
conda info | |
conda list | |
- name: Run tests | |
run: | | |
pytest -n 2 -v --cov=ggmolvis --cov-report=xml --color=yes ggmolvis/tests/ || true | |
exit_code=$? | |
if [ $exit_code -eq 139 ]; then | |
echo "Segmentation fault occurred. Ignoring and continuing CI." | |
exit 0 | |
elif [ $exit_code -ne 0 ]; then | |
echo "Tests failed with exit code $exit_code." | |
exit $exit_code | |
fi | |
- name: codecov | |
if: github.repository == 'yuxuanzhuang/ggmolvis' && github.event_name != 'schedule' | |
uses: codecov/codecov-action@v4 | |
with: | |
file: coverage.xml | |
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }} | |
verbose: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: true | |
pylint_check: | |
if: "github.repository == 'yuxuanzhuang/ggmolvis'" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install Pylint | |
run: | | |
which pip | |
which python | |
pip install pylint mdanalysis | |
- name: Run Pylint | |
env: | |
PYLINTRC: .pylintrc | |
run: | | |
pylint ggmolvis | |
pypi_check: | |
if: "github.repository == 'yuxuanzhuang/ggmolvis'" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
pip install pipx twine | |
- name: Build package | |
run: | | |
python -m pipx run build --sdist | |
- name: Check package build | |
run: | | |
DISTRIBUTION=$(ls -t1 dist/ggmolvis-*.tar.gz | head -n 1) | |
test -n "${DISTRIBUTION}" || { echo "no distribution dist/ggmolvis-*.tar.gz found"; exit 1; } | |
echo "twine check $DISTRIBUTION" | |
twine check $DISTRIBUTION | |
build_docs: | |
if: "github.repository == 'yuxuanzhuang/ggmolvis'" | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
env: | |
CYTHON_TRACE_NOGIL: 1 | |
MPLBACKEND: agg | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Build information | |
run: | | |
uname -a | |
df -h | |
ulimit -a | |
- name: Install conda dependencies | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
python-version: "3.11" | |
environment-file: docs/requirements.yaml | |
add-pip-as-python-dependency: true | |
miniforge-variant: Miniforge3 | |
use-mamba: true | |
channels: conda-forge, defaults | |
activate-environment: ggmolvis-docs | |
auto-update-conda: true | |
auto-activate-base: false | |
show-channel-urls: true | |
- name: Install package | |
run: | | |
python --version | |
python -m pip install . --no-deps | |
- name: Python information | |
run: | | |
which python | |
which pip | |
pip list | |
conda info | |
conda list | |
- name: build docs with sphinx | |
# if: github.event_name == 'pull_request' | |
continue-on-error: true | |
run: | | |
sphinx-build --keep-going ./docs/source ./docs/_build/html || true | |
- name: Setup SSH | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.DEPLOY_KEY_PRIVATE }} | |
- name: Clone Pages Repo using SSH | |
run: | | |
# Set folder name based on event type | |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
export FOLDER_NAME="main" | |
else | |
export FOLDER_NAME="latest" | |
fi | |
# Get version and branch details | |
python devtools/write_version.py || true | |
export VERSION=$(cat VERSION.txt) | |
echo "VERSION: $VERSION" | |
BRANCH="${GITHUB_REF#refs/heads/}" | |
echo "Branch: $BRANCH" | |
# Move built docs into versioned folder | |
cd docs/_build/html | |
mkdir -p ../${VERSION} | |
mv * ../${VERSION} | |
mv ../${VERSION} $VERSION | |
# Get Git revision hash | |
REV=$(git rev-parse --short HEAD) | |
echo "Git Revision: $REV" | |
# Initialize and configure Git | |
git init | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git remote add upstream "[email protected]:yuxuanzhuang/ggmolvis.github.io.git" | |
git fetch --depth 50 upstream gh-pages | |
git reset upstream/gh-pages | |
# Create redirects and copies | |
mkdir -p ${FOLDER_NAME} | |
cp -r ${VERSION}/* ${FOLDER_NAME}/ | |
touch .nojekyll | |
cp ../../../devtools/index.html . | |
# Add changes to Git | |
git add -A ${VERSION}/ | |
git add -A ${FOLDER_NAME}/ | |
git add .nojekyll *.html index.html | |
# Add additional directories if they exist | |
for dirname in dev stable documentation_pages; do | |
if [ -d "$dirname" ]; then | |
git add "$dirname" | |
fi | |
done | |
# Check for uncommitted changes and commit | |
git diff-index --quiet HEAD -- || \ | |
git commit -m "Rebuilt HTML docs for version ${VERSION} from branch ${BRANCH} with Sphinx at ${REV}" | |
# Push changes to upstream gh-pages branch | |
git push -q upstream HEAD:gh-pages |