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

Split CI into build, lint, test #32

Merged
merged 4 commits into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
315 changes: 295 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,314 @@
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 node
uses: actions/setup-node@v1

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

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

- name: Cache JS
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 Python Setup Dependencies
run: python -m pip install --upgrade pip wheel setuptools

- name: Get Python Cache
id: cache-pip
run: |
echo "::set-output name=dir::$(pip cache dir)"

- name: Cache Python Dependencies
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 Python Packaging Dependencies
run: python -m pip install 'jupyterlab==${{ matrix.lab-version }}.*' twine

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

- name: Build JS Library
run: jlpm build:lib

- name: Build JupyterLab Extension
run: jlpm build:labextension

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

- name: Validate Python Distributions
run: twine check dist/*

- name: Collect JS 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 NodeJS
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Cache JS
id: cache-node-modules
uses: actions/cache@v2
with:
node-version: '14.x'
path: node_modules
key: |
${{ env.CACHE_EPOCH }}-node-modules-${{ runner.os }}-${{ hashFiles('yarn.lock', '.yarnrc') }}

- name: Install Python Setup Dependencies
run: python -m pip install --upgrade pip wheel setuptools

- name: Get Python Cache
id: cache-pip
run: |
echo "::set-output name=dir::$(pip cache dir)"

- name: Cache Python Dependencies
uses: actions/cache@v2
with:
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 Setup Dependencies
run: python -m pip install 'jupyterlab==${{ matrix.lab-version }}.*'

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

- name: Build JS
run: jlpm build

- name: Install Python Lint/Test Dependencies
run: python -m pip install -e '.[coverage]'

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to install JS dependencies once more (already in l154)?

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup!

- name: Lint JS
run: jlpm eslint:check

- name: Unit Test Server Extension
run: |
set -eux
python -m pytest --pyargs jupyterlab_pullrequests --cov jupyterlab_pullrequests --cov-report term-missing:skip-covered --no-cov-on-fail

- name: Unit Test JS (known to be broken)
run: jlpm test || echo "TODO"

- 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 Setup 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 Python Cache Location and Distribution
id: cache-pip
shell: bash -l {0}
run: |
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 Python Dependencies
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 Python Environment
run: ${{ matrix.py-cmd }} -m pip freeze

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

- name: List Server Extensions
run: jupyter serverextension list > serverextensions.txt 2>&1

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

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

- name: Unit Test Server Extension
run: ${{ matrix.py-cmd }} -m pytest --pyargs jupyterlab_pullrequests -vv

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

- name: List JupyterLab Extensions
run: ${{ matrix.py-cmd }} -m jupyter labextension list > labextensions.txt 2>&1

- name: Check JupyterLab Preconditions
shell: bash -l {0}
run: |
jlpm
jlpm run eslint:check
# jlpm run test
cat labextensions.txt
cat labextensions.txt | grep -ie "jupyterlab/pullrequests.*enabled.*OK"
cat labextensions.txt | grep "jupyterlab/pullrequests needs to be included in build"

pip install .[test]
python -m pytest
- name: Rebuild JupyterLab
run: ${{ matrix.py-cmd }} -m jupyter lab build --debug

jupyter lab build
jupyter serverextension list 2>&1 | grep -ie "jupyterlab_pullrequests.*OK"
jupyter labextension list 2>&1 | grep -ie "@jupyterlab/pullrequests.*OK"
- name: List JupyterLab Extensions
run: ${{ matrix.py-cmd }} -m jupyter labextension list > labextensions.txt 2>&1

- name: Validate JupyterLab Build
shell: bash -l {0}
run: |
cat labextensions.txt
cat labextensions.txt | grep -ie "jupyterlab/pullrequests.*enabled.*OK"
cat labextensions.txt | grep -v "jupyterlab/pullrequests needs to be included in build"

python -m jupyterlab.browser_check
- name: Run JupyterLab Browser Check
if: ${{ matrix.os != 'windows' && matrix.python-version != '3.6' }}
run: ${{ matrix.py-cmd }} -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
Loading