Skip to content

Commit

Permalink
start dist/lint/test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl committed Mar 12, 2021
1 parent 67352f7 commit b2644b0
Show file tree
Hide file tree
Showing 15 changed files with 404 additions and 1,609 deletions.
293 changes: 274 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,294 @@
name: Build
name: CI

on:
push:
branches: ["master", "next"]
branches: [master, next]
pull_request:
branches: '*'

env:
CACHE_EPOCH: 1

jobs:
build:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}-latest

strategy:
matrix:
os: [ubuntu]
python-version: [3.9]
node-version: [14.x]
lab-version: [2]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Cache (node_modules)
id: cache-node-modules
uses: actions/cache@v2
with:
path: node_modules
key: |
${{ env.CACHE_EPOCH }}-node-modules-${{ runner.os }}-${{ hashFiles('yarn.lock', '.yarnrc') }}
- name: Install packaging pre-dependencies
run: python -m pip install --upgrade pip wheel setuptools

- name: Get pip cache dir
id: cache-pip
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip
uses: actions/cache@v2
with:
path: ${{ steps.cache-pip.outputs.dir }}
key: |
${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-build-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'setup.cfg') }}
restore-keys: |
${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-build-${{ matrix.python-version }}-
${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-
- name: Install packaging dependencies
run: python -m pip install 'jupyterlab==${{ matrix.lab-version }}.*' twine

- name: Install yarn dependencies
if: ${{ steps.cache-node-modules.outputs.cache-hit != 'true' }}
run: jlpm --prefer-offline --frozen-lockfile

- name: Build JS (lib)
run: jlpm build:lib

- name: Build JS (labextension)
run: jlpm build:labextension

- name: Build PyPI distributions
run: python setup.py sdist bdist_wheel

- name: Validate packages
run: twine check dist/*

- name: Collect npmjs.com distribution
run: |
set -eux
cp jupyterlab_pullrequests/labextension/*.tgz dist
- name: Hash distributions
run: |
set -eux
cd dist
sha256sum * | tee SHA256SUMS
- name: Upload distributions
uses: actions/upload-artifact@v2
with:
name: pull-requests dist ${{ github.run_number }}
path: ./dist

lint:
runs-on: ${{ matrix.os }}-latest

strategy:
matrix:
os: [ubuntu]
python-version: [3.9]
node-version: [14.x]
lab-version: [2]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install node
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Cache (node_modules)
id: cache-node-modules
uses: actions/cache@v2
with:
path: node_modules
key: |
${{ env.CACHE_EPOCH }}-node-modules-${{ runner.os }}-${{ hashFiles('yarn.lock', '.yarnrc') }}
- name: Install packaging pre-dependencies
run: python -m pip install --upgrade pip wheel setuptools

- name: Get pip cache dir
id: cache-pip
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip
uses: actions/cache@v2
with:
node-version: '14.x'
path: ${{ steps.cache-pip.outputs.dir }}
key: |
${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-lint-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'setup.cfg') }}
restore-keys: |
${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-lint-${{ matrix.python-version }}-
${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-
- name: Install lint/test dependencies
run: python -m pip install 'jupyterlab==${{ matrix.lab-version }}.*'

- name: Build JS
run: jlpm build

- name: Install lint/test dependencies
run: python -m pip install -e '.[coverage]'

- name: Install yarn dependencies
if: ${{ steps.cache-node-modules.outputs.cache-hit != 'true' }}
run: jlpm --prefer-offline --frozen-lockfile

- name: Lint (JS)
run: jlpm eslint:check

- name: Test (Python)
run: |
set -eux
python -m pytest --pyargs jupyterlab_pullrequests --cov jupyterlab_pullrequests --cov-report term-missing:skip-covered --no-cov-on-fail
- name: Test (JS)
run: jlpm test || echo 'known to be broken'

- name: Upload Coverage
run: codecov

install:
runs-on: ${{ matrix.os }}-latest
needs: [build]

strategy:
# TODO: possibly put back
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python-version: [3.6, 3.9, pypy3]
node-version: [10.x, 14.x]
lab-version: [2]
include:
# cover artifacts
- python-version: 3.6
dist: jupyterlab_pullrequests*.tar.gz
- python-version: 3.9
dist: jupyterlab_pullrequests*.whl
- python-version: pypy3
dist: jupyterlab_pullrequests*.tar.gz
# platform-specific pythons
- os: windows
py-cmd: python
shell: cmd
- os: macos
py-cmd: python3
shell: bash
- os: ubuntu
py-cmd: python
shell: bash
exclude:
# not supported
- os: windows
python-version: pypy3
# don't need the full node/py matrix
- python-version: 3.6
node-version: 14.x
- python-version: 3.9
node-version: 10.x
- python-version: pypy3
node-version: 10.x

defaults:
run:
shell: ${{ matrix.shell }}

steps:
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
architecture: 'x64'
- name: Install dependencies
run: python -m pip install jupyterlab~=2.0
- name: Build the extension
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install pre-dependencies
run: ${{ matrix.py-cmd }} -m pip install --upgrade pip wheel setuptools

- name: Download distributions
uses: actions/download-artifact@v2
with:
name: pull-requests dist ${{ github.run_number }}
path: ./dist

- name: Get pip cache dir and distribution
id: cache-pip
shell: bash -l {0}
run: |
jlpm
jlpm run eslint:check
# jlpm run test
set -eux
echo "::set-output name=dir::$(${{ matrix.py-cmd }} -m pip cache dir)"
echo "::set-output name=pydist::$(ls ./dist/${{ matrix.dist }})"
- name: Cache pip
uses: actions/cache@v2
with:
path: ${{ steps.cache-pip.outputs.dir }}
key: |
${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-install-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'setup.cfg') }}
restore-keys: |
${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-install-${{ matrix.python-version }}-
${{ env.CACHE_EPOCH }}-${{ runner.os }}-pip-
- name: Install package
run: ${{ matrix.py-cmd }} -m pip install ${{ steps.cache-pip.outputs.pydist }}

- name: List pip environment
run: ${{ matrix.py-cmd }} -m pip freeze

- name: Validate pip environment
run: ${{ matrix.py-cmd }} -m pip check

- name: List server extension
run: jupyter serverextension list 2>&1 > serverextensions.txt

- name: Validate server extension
shell: bash -l {0}
run: cat serverextensions.txt | grep -ie "jupyterlab_pullrequests.*enabled"

- name: Install test dependencies
run: ${{ matrix.py-cmd }} -m pip install "mock>=4.0.0" pytest-asyncio pytest diff-match-patch

- name: Test (Python)
run: ${{ matrix.py-cmd }} -m pytest --pyargs jupyterlab_pullrequests -vv

- name: Install node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Install Lab Extension
run: ${{ matrix.py-cmd }} -m jupyter lab build

pip install .[test]
python -m pytest
- name: List Lab Extensions
run: ${{ matrix.py-cmd }} -m jupyter labextension list 2>&1 > labextensions.txt

jupyter lab build
jupyter serverextension list 2>&1 | grep -ie "jupyterlab_pullrequests.*OK"
jupyter labextension list 2>&1 | grep -ie "@jupyterlab/pullrequests.*OK"
- name: Validate Lab Extension
shell: bash -l {0}
run: cat labextensions.txt | grep -ie "@jupyterlab/pullrequests.*ok"

python -m jupyterlab.browser_check
- name: Run browser check
run: ${{ matrix.py-cmd }} -m python -m jupyterlab.browser_check
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.bundle.*
lib/
node_modules/
.yarn-packages/
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo
Expand Down Expand Up @@ -114,4 +115,4 @@ dmypy.json

.pytest_cache/

.DS_Store
.DS_Store
5 changes: 5 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
yarn-offline-mirror "./.yarn-packages"
yarn-offline-mirror-pruning true
ignore-optional true
network-timeout "300000"
disable-self-update-check true
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ include jupyter-config/jupyterlab_pullrequests.json
include package.json
include ts*.json
include jupyterlab_pullrequests/labextension/*.tgz
recursive-include jupyterlab_pullrequests/tests *.json


# Javascript files
graft src
Expand Down
5 changes: 3 additions & 2 deletions jupyterlab_pullrequests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from ._version import __version__
from .base import PRConfig
from .handlers import setup_handlers


def _jupyter_server_extension_paths():
Expand All @@ -15,6 +13,9 @@ def load_jupyter_server_extension(lab_app):
lab_app: jupyterlab.labapp.LabApp
JupyterLab application instance
"""
from .base import PRConfig
from .handlers import setup_handlers

config = PRConfig(config=lab_app.config)
setup_handlers(lab_app.web_app, config)
lab_app.log.info("Registered jupyterlab_pullrequests extension")
3 changes: 1 addition & 2 deletions jupyterlab_pullrequests/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
version_info = (2, 0, 0)
__version__ = ".".join(map(str, version_info))
__version__ = "2.0.0"
2 changes: 0 additions & 2 deletions jupyterlab_pullrequests/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

from typing import List, NamedTuple, Optional

from traitlets import Enum, Unicode, default
Expand Down
2 changes: 0 additions & 2 deletions jupyterlab_pullrequests/handlers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""
Module with all of the individual handlers, which return the results to the frontend.
"""
from __future__ import annotations

import json
import logging
import traceback
Expand Down
2 changes: 0 additions & 2 deletions jupyterlab_pullrequests/managers/manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import abc
import json
import http
Expand Down
Empty file.
Loading

0 comments on commit b2644b0

Please sign in to comment.