Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests and github workflow #20

Merged
merged 6 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Test

on: [push, pull_request]

jobs:
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
cache: 'pip'
cache-dependency-path: |
**/requirements*.txt
- name: Install dependencies
run: |
sudo apt-get install -y pandoc
python -m pip install --upgrade pip
python -m pip install -e .
python -m pip install -r ./docs/requirements.txt
- name: Build docs
run: |
cd docs/source
python -m sphinx -T -E -b html -d ../build/doctrees -D language=en . ../build/html

python:
name: Python
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
**/setup.cfg
**/requirements*.txt

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install "pytest<8"
- name: Test with pytest
run: |
cd tests
pytest


ui-test:
name: Visual Regression
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: |
**/setup.cfg
**/requirements*.txt

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -U jupyterlab==4.1.2 jupyter-packaging~=0.12
pip install -e .

- name: Install Test Dependencies
run: |
jlpm --immutable
npx playwright install chromium
working-directory: tests/notebooks

- name: Execute integration tests
shell: bash -l {0}
working-directory: tests/notebooks
run: |
npx playwright test

- name: Upload Playwright Test assets
if: always()
uses: actions/upload-artifact@v3
with:
name: test-assets
path: |
tests/notebooks/test-results

- name: Upload Playwright Test report
if: always()
uses: actions/upload-artifact@v3
with:
name: test-report
path: |
tests/notebooks/playwright-report

- name: Update snapshots
if: failure()
working-directory: tests/notebooks
run: |
jlpm test:update

- name: Upload updated snapshots
if: failure()
uses: actions/upload-artifact@v3
with:
name: updated-snapshots
path: tests/notebooks/tests
30 changes: 29 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,37 @@ dmypy.json
# Pyre type checker
.pyre/

# javascript
docs/man/*.gz
docs/source/api/generated
docs/source/.cache
*.doit.db
_contents
node_modules
*.py[co]
__pycache__
*.egg-info
*~
*.bak
.ipynb_checkpoints
.tox
.DS_Store
\#*#
.#*
.coverage
.xunit.xml
.tern-project
npm-debug.log
.pytest_cache
.vscode/*
!.vscode/extensions.json

#
*.pdf
tests/work
/tests/**/*.png
*.xyz
test.ipynb

tests/notebooks/test-results
tests/notebooks/playwright-report
tests/notebooks/.yarn/cache
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Welcome to WEAS Widget!
[![PyPI version](https://badge.fury.io/py/weas-widget.svg)](https://badge.fury.io/py/weas-widget)
[![Docs status](https://readthedocs.org/projects/weas-widget/badge)](http://weas-widget.readthedocs.io/)

[![Unit test](https://github.com/superstar54/weas-widget/actions/workflows/ci.yaml/badge.svg)](https://github.com/superstar54/weas-widget/actions/workflows/ci.yaml)

A widget to visualize and edit atomistic structures in Jupyter Notebook. It uses [WEAS](https://github.com/superstar54/weas) (Web Environment For Atomistic Structure) in the backend.

Expand Down Expand Up @@ -148,7 +148,7 @@ trajectory = generate_phonon_trajectory(atoms, eigenvector, repeat=[4, 4, 1])
viewer = WeasWidget()
viewer.from_ase(trajectory)
# set a vector field to show the arrow
viewer.vectorField = {"origins": "positions", "vectors": "movement", "radius": 0.1}
viewer.vectorField = [{"origins": "positions", "vectors": "movement", "radius": 0.1}]
viewer
```

Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ A widget to visualize and interact with atomistic structures in Jupyter Notebook
measurement
isosurface
vector_field
selection


Indices and tables
Expand Down
2 changes: 1 addition & 1 deletion docs/source/quick_start.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@
"origins = atoms.positions\n",
"# the vertor\n",
"vectors = [[0, 0, 1]]*len(atoms)\n",
"viewer.vectorField = {\"origins\": origins, \"vectors\": vectors, \"color\": \"red\"}"
"viewer.vectorField = [{\"origins\": origins, \"vectors\": vectors, \"color\": \"red\"}]"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/source/vector_field.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ One can visualize the phonon dispersion via lattice vibrations. One only need to
viewer = WeasWidget()
viewer.from_ase(trajectory)
# set a vector field to show the arrow
viewer.vectorField = {"origins": "positions", "vectors": "movement", "radius": 0.1}
viewer.vectorField = [{"origins": "positions", "vectors": "movement", "radius": 0.1}]
viewer


Expand Down
Loading
Loading