Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
hainm committed Nov 29, 2024
1 parent 60f0812 commit 9b23167
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 78 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

name: Test Template

on:
pull_request:
workflow_dispatch:

jobs:
test:
runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash -l {0}

strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.10", "3.11", "3.12"]

steps:
- name: Checkout nglview repository
uses: actions/checkout@v4

- name: Cache conda
uses: actions/cache@v4
env:
CACHE_NUMBER: 2 # Increase this value to reset cache if .github/nglview-gha.yml has not changed
with:
path: ~/conda_pkgs_dir
key: ${{ matrix.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('.github/nglview-gha.yml') }}

- name: Set up conda environment
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
auto-activate-base: false
activate-environment: nglview-gha
environment-file: .github/nglview-gha.yml
mamba-version: "*"
channels: conda-forge
channel-priority: true
python-version: ${{ matrix.python-version }}
use-only-tar-bz2: false # https://github.com/conda-incubator/setup-miniconda/issues/264

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'

- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: js/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Install Yarn
run: corepack enable

- name: Build labextension
run: |
cd js
npm install
cd ..
- name: Check installation with pip
run: |
python setup.py sdist
pip install dist/*gz
python -c "import nglview as nv; print(nv.__version__)"
81 changes: 3 additions & 78 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,83 +6,8 @@ on:

jobs:
test:
runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash -l {0}

strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.10", "3.11", "3.12"]

uses: ./.github/workflows/template.yml
steps:
- name: Checkout nglview repository
uses: actions/checkout@v4

- name: Cache conda
uses: actions/cache@v4
env:
CACHE_NUMBER: 2 # Increase this value to reset cache if .github/nglview-gha.yml has not changed
with:
path: ~/conda_pkgs_dir
key:
${{ matrix.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('.github/nglview-gha.yml') }}

- name: Set up conda environment
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
auto-activate-base: false
activate-environment: nglview-gha
environment-file: .github/nglview-gha.yml
mamba-version: "*"
channels: conda-forge
channel-priority: true
python-version: ${{ matrix.python-version }}
use-only-tar-bz2: false # https://github.com/conda-incubator/setup-miniconda/issues/264

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'

- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: js/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Install Yarn
run: corepack enable

- name: Build labextension
- name: Run tests
run: |
cd js
npm install
cd ..
# - name: Run tests
# run: |
# python -m pytest -vs tests --cov=nglview --cov-report=html --disable-pytest-warnings

- name: Check installation with pip
run: |
python setup.py sdist
pip install dist/*gz
python -c "import nglview as nv; print(nv.__version__)"
- name: Generate JS test files
run: |
python3 devtools/make_test_js.py --api
- name: Start Jupyter Lab
run: |
nohup jupyter lab --no-browser --port=8888 &
sleep 10
- name: Run Nightwatch tests
run: npx nightwatch
python -m pytest -vs tests --cov=nglview --cov-report=html --disable-pytest-warnings
21 changes: 21 additions & 0 deletions .github/workflows/test_nightwatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test

on:
pull_request:
workflow_dispatch:

jobs:
test:
uses: ./.github/workflows/template.yml
steps:
- name: Generate JS test files
run: |
python3 devtools/make_test_js.py --api
- name: Start Jupyter Lab
run: |
nohup jupyter lab --no-browser --port=8888 &
sleep 10
- name: Run Nightwatch tests
run: npx nightwatch

0 comments on commit 9b23167

Please sign in to comment.