Skip to content

Commit

Permalink
Merge pull request #345 from krassowski/github-actions
Browse files Browse the repository at this point in the history
First attempt to setup GitHub actions
  • Loading branch information
krassowski authored Sep 10, 2020
2 parents 9c56a02 + b45a4b9 commit e97324d
Show file tree
Hide file tree
Showing 19 changed files with 342 additions and 278 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/job.lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: lint
on:
push:
branches:
- master
pull_request:
branches:
- master

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

jobs:
lint:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-16.04]
python: [3.8]
nodejs: ['>=12,<13.0.0a0']
lab: ['>=2,<3.0.0a0']
steps:
- uses: actions/checkout@v2

- uses: cschleiden/replace-tokens@v1
with:
tokenPrefix: '{'
tokenSuffix: '}'
files: '["requirements/github-actions.yml"]'
env:
lab: '${{ matrix.lab }}'
nodejs: '${{ matrix.nodejs }}'

- name: Set up Python and conda
uses: goanpeca/setup-miniconda@v1
with:
python-version: ${{ matrix.python }}
channels: conda-forge, defaults
channel-priority: true
activate-environment: jupyterlab-lsp
environment-file: requirements/github-actions.yml
auto-update-conda: true

- name: linting dependencies
run: conda env update -n jupyterlab-lsp --file requirements/lint.yml --quiet

- name: check integrity of package versions
run: python scripts/integrity.py

- name: install npm dependencies
run: jlpm

- name: lint backend
run: python scripts/lint.py

- name: build schema so linting can complete
run: jlpm build:schema

- name: lint frontend
run: jlpm lint:check
207 changes: 207 additions & 0 deletions .github/workflows/job.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
name: tests
on:
push:
branches:
- master
pull_request:
branches:
- master

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

env:
# TODO extract these from files instead
PY_JLSP_VERSION: 0.9.2
JS_JLLSP_VERSION: 2.0.2
JS_JLG2D_VERSION: 1.0.0

PYTHONUNBUFFERED: 1
ATEST_RETRIES: 3

LINKED_EXTENSIONS: >-
packages/lsp-ws-connection
packages/jupyterlab-go-to-definition
packages/completion-theme
packages/theme-vscode
packages/theme-material
jobs:
acceptance:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }}, Python ${{ matrix.python }}, Node ${{ matrix.nodejs }}
strategy:
matrix:
python: [3.6, 3.7, 3.8]
os: [ubuntu-16.04, macos-10.14, vs2017-win2016]
lab: ['>=2.2.0,<3.0.0a0']
include:
# if using 3.6, use an old node
- python: 3.6
# Node 10 end-of-life: April 2021
nodejs: '>=10,<11.0.0.a0'
# if using 3.7, use newer node, etc...
- python: 3.7
# Node 12 end-of-life: April 2022
nodejs: '>=12,<13.0.0.a0'
- python: 3.8
# Node 14 end-of-life: April 2023
nodejs: '>=14,<15.0.0.a0'

steps:
- uses: actions/checkout@v2

- name: Set JupyterLab and Node versions
uses: cschleiden/replace-tokens@v1
with:
tokenPrefix: '{'
tokenSuffix: '}'
files: '["requirements/github-actions.yml"]'
env:
lab: '${{ matrix.lab }}'
nodejs: '${{ matrix.nodejs }}'

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

- name: Set up Python and conda
uses: goanpeca/setup-miniconda@v1
with:
python-version: ${{ matrix.python }}
channels: conda-forge, defaults
channel-priority: true
auto-activate-base: true
activate-environment: jupyterlab-lsp
environment-file: requirements/github-actions.yml
auto-update-conda: true
use-only-tar-bz2: true # needs to be set for caching to work properly

- name: Install pip dependencies
run: pip install pytest-github-actions-annotate-failures

- name: Describe conda
shell: bash -l {0}
run: |
conda info
conda list
conda config --show-sources
conda config --show
printenv | sort
- name: Cache yarn
uses: actions/cache@v1
with:
path: .yarn-packages
key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-${{ runner.os }}-
yarn-
- name: Install npm dependencies
run: jlpm

- name: Build the extension
run: jlpm build

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

- name: Build npm bundles
run: jlpm lerna run bundle

- name: Install python wheel
run: cd dist && python -m pip install jupyter_lsp-${{ env.PY_JLSP_VERSION }}-py3-none-any.whl --no-deps

- name: Find out jedi cache location
run: python -c 'import jedi; print("::set-env name=JEDI_CACHE_DIR::" + jedi.settings.cache_directory)'

- name: Cache jedi cache
uses: actions/cache@v1
with:
path: ${{ env.JEDI_CACHE_DIR }}
key: jedi-${{ matrix.os }}-${{ hashFiles('scripts/jedi_cache.py') }}-${{ hashFiles('requirements/github-actions.yml') }}

- name: Warm up jedi cache
run: python scripts/jedi_cache.py

- name: Cache tectonic cache
uses: actions/cache@v2
with:
# locations for: Linux, MacOS, Windows
path: |
~/.cache/Tectonic
~/Library/Caches/Tectonic
%LOCALAPPDATA%/TectonicProject/Tectonic
key: ${{ runner.os }}-${{ hashFiles('scripts/tectonic_cache.py') }}

- name: Warm up tectonic cache
run: python scripts/tectonic_cache.py

- name: Run frontend unit tests
run: jlpm test

# js_cov_packages:
# - jupyterlab-go-to-definition
# - jupyterlab-lsp

#- task: PublishTestResults@2
# name: publish frontend test results
# inputs:
# testResultsFiles: packages/**/junit.xml
# testRunTitle: 'Jest ${{ env.name }}${{ python.name }}'
# mergeTestResults: true
# condition: always()

#- ${{ each js_package in parameters.js_cov_packages }}:
# - task: PublishCodeCoverageResults@1
# name: 'publish ${{ js_package }} coverage'
# inputs:
# codeCoverageTool: Cobertura
# summaryFileLocation: 'packages/${{ js_package }}/coverage/cobertura-coverage.xml'
# condition: always()

- name: List server extensions
run: jupyter serverextension list

- name: Run python tests
run: python scripts/utest.py

- name: Install support packages
run: jupyter labextension link --debug --no-build ${{ env.LINKED_EXTENSIONS }}

- name: Install labextensions
run: jupyter labextension install --debug --no-build packages/jupyterlab-lsp/krassowski-jupyterlab-lsp-${{ env.JS_JLLSP_VERSION }}.tgz

- name: List labextensions before build
run: jupyter labextension list

- name: Build lab
run: jupyter lab build --debug --dev-build=False --minimize=True

- name: List labextensions after build
run: jupyter labextension list

- name: Run browser tests
run: python scripts/atest.py --exclude expect:fail

#- task: PublishTestResults@2
# name: publish browser test results
# inputs:
# testResultsFiles: atest/output/*.xunit.xml
# testRunTitle: 'Robot ${{ env.name }}${{ python.name }}'
# mergeTestResults: true
# condition: always()

- name: Publish browser test output
uses: actions/upload-artifact@v2
with:
name: ${{ job.status }} Robot ${{ matrix.os }} Python ${{ matrix.python }} ${{ github.run_number }}
path: ./atest/output
if: always()
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Language Server Protocol integration for Jupyter(Lab)

[![Build Status](https://travis-ci.org/krassowski/jupyterlab-lsp.svg?branch=master)](https://travis-ci.org/krassowski/jupyterlab-lsp) [![Build Status](https://dev.azure.com/krassowskimichal/jupyterlab-lsp/_apis/build/status/jupyterlab-lsp?branchName=master)](https://dev.azure.com/krassowskimichal/jupyterlab-lsp/_build/latest?definitionId=1&branchName=master) [![Documentation Status](https://readthedocs.org/projects/jupyterlab-lsp/badge/?version=latest)](https://jupyterlab-lsp.readthedocs.io/en/latest/?badge=latest) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/krassowski/jupyterlab-lsp/master?urlpath=lab%2Ftree%2Fexamples%2FPython.ipynb)
[![Build Status](https://travis-ci.org/krassowski/jupyterlab-lsp.svg?branch=master)](https://travis-ci.org/krassowski/jupyterlab-lsp) ![tests](https://github.com/krassowski/jupyterlab-lsp/workflows/tests/badge.svg) [![Documentation Status](https://readthedocs.org/projects/jupyterlab-lsp/badge/?version=latest)](https://jupyterlab-lsp.readthedocs.io/en/latest/?badge=latest) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/krassowski/jupyterlab-lsp/master?urlpath=lab%2Ftree%2Fexamples%2FPython.ipynb)

> _This project is still maturing, but you are welcome to check it out, leave feedback and/or a PR_
Expand Down
11 changes: 5 additions & 6 deletions atest/Keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Library SeleniumLibrary
Library OperatingSystem
Library Process
Library String
Library ./logcheck.py
Library ./ports.py

*** Keywords ***
Expand Down Expand Up @@ -70,12 +71,10 @@ Tear Down Everything
Terminate All Processes kill=${True}

Lab Log Should Not Contain Known Error Messages
${log} = Get File ${LAB LOG}
${test log} = Set Variable ${log[${PREVIOUS LAB LOG LENGTH}:]}
${length} = Get Length ${log}
Set Global Variable ${PREVIOUS LAB LOG LENGTH} ${length}
Run Keyword If ("${OS}", "${PY}") !\= ("Windows", "36")
... Should Not Contain Any ${test log} @{KNOWN BAD ERRORS}
Touch ${LAB LOG}
${length} = Get File Size ${LAB LOG}
File Should Not Contain Phrases ${LAB LOG} ${PREVIOUS LAB LOG LENGTH} @{KNOWN BAD ERRORS}
[Teardown] Set Global Variable ${PREVIOUS LAB LOG LENGTH} ${length}

Wait For Splash
Go To ${URL}lab?reset&token=${TOKEN}
Expand Down
28 changes: 28 additions & 0 deletions atest/logcheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from bs4 import UnicodeDammit


def file_should_not_contain_phrases(filename, offset=0, *phrases):
"""don't fail _too_ hard if the file can't be read for some reason"""
with open(filename, "rb") as fp:
raw = fp.read()[offset:]

text = None

try:
text = raw.decode("utf-8")
except Exception as err:
print("Failed to read", filename, "forcing unicode...\n", err)
try:
text = UnicodeDammit.detwingle(raw).decode("utf-8")
except Exception as err:
print("Failed to read", filename, "giving up...\n", err)
text = None

matches = {}

if text is not None:
for phrase in phrases:
if phrase in text:
matches[phrase] = True

assert not matches, "Phrases found in {}: {}".format(filename, matches)
34 changes: 0 additions & 34 deletions azure-pipelines.yml

This file was deleted.

10 changes: 0 additions & 10 deletions ci/env_template.py

This file was deleted.

Loading

0 comments on commit e97324d

Please sign in to comment.