diff --git a/.github/workflows/template.yml b/.github/workflows/template.yml new file mode 100644 index 00000000..e5377a4e --- /dev/null +++ b/.github/workflows/template.yml @@ -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__)" \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9058a31a..e99cc8ef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 \ No newline at end of file + python -m pytest -vs tests --cov=nglview --cov-report=html --disable-pytest-warnings \ No newline at end of file diff --git a/.github/workflows/test_nightwatch.yml b/.github/workflows/test_nightwatch.yml new file mode 100644 index 00000000..74ac0cfa --- /dev/null +++ b/.github/workflows/test_nightwatch.yml @@ -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 \ No newline at end of file