diff --git a/.github/workflows/js.yml b/.github/workflows/js.yml new file mode 100644 index 00000000..b9b5f857 --- /dev/null +++ b/.github/workflows/js.yml @@ -0,0 +1,35 @@ +# Based on +# https://github.com/fedarko/strainFlye/blob/main/.github/workflows/main.yml + +# https://github.com/biocore/empress/blob/master/.github/workflows/main.yml +name: MgSc JavaScript CI +on: [push, pull_request] +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14] + + steps: + + # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + - name: Check out code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install MetagenomeScope's Node.js development dependencies + run: npm install -g mocha-headless-chrome nyc prettier@2.0.5 jshint + + - name: Lint and stylecheck the JS code + run: make jsstylecheck + + - name: Run JS tests + run: make jstest + + - name: Upload JS code coverage information to Codecov + uses: codecov/codecov-action@v2 diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 00000000..9bbb54e7 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,37 @@ +# Based on +# https://github.com/fedarko/strainFlye/blob/main/.github/workflows/main.yml +name: MgSc Python CI +on: [push, pull_request] +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: [3.6] + + steps: + + # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + - name: Check out code + uses: actions/checkout@v3 + + # https://github.com/conda-incubator/setup-miniconda#example-3-other-options + - name: Install conda dependencies + uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: mgsc + environment-file: environment.yml + python-version: ${{ matrix.python-version }} + + - name: Install MetagenomeScope (and its pip dependencies) + run: conda run -n mgsc pip install -e .[dev] + + - name: Lint and stylecheck the Python code + run: conda run -n mgsc make pystylecheck + + - name: Run Python tests + run: conda run -n mgsc make pytest + + - name: Upload Python code coverage information to Codecov + uses: codecov/codecov-action@v2 diff --git a/.gitignore b/.gitignore index 4cfd3c07..8058fd57 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,138 @@ -*.pyc +# (This is the basic Python gitignore from GitHub.) +# Byte-compiled / optimized / DLL files __pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# vim +*.swp + +# Extra MgSc-specific stuff metagenomescope/tests/output/ spqrtests/ testgraphs/ @@ -8,9 +141,6 @@ viewer/demotests/ node_modules/ .DS_STORE .DS_Store -*.egg-info/ -*.bak -.coverage js_coverage.json metagenomescope/tests/js_tests/instrumented_js/* dist/ @@ -18,7 +148,6 @@ big-list-of-naughty-strings/ *.gv *.xdot *.db -*.agp mg2/ coverage/ metagenomescope/tests/input/extras/sheepgut_g1217.gfa diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fbe30cd5..00000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -language: python -python: - - "3.6" -install: - # CODELINK: conda installation instructions per https://conda.io/docs/user-guide/tasks/use-conda-with-travis-ci.html - - wget -O miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh - - bash miniconda.sh -b -p $HOME/miniconda - - export PATH="$HOME/miniconda/bin:$PATH" - - hash -r - - conda config --set always_yes yes --set changeps1 no - - conda update -q conda - # Install MetagenomeScope from source - - travis_retry conda create -q -c anaconda -n mgsc python=3.6 graphviz numpy - - source activate mgsc - - pip install -e .[dev] - # Taken from Qurro's .travis.yml file: - # Update Node.js to the latest version, since otherwise installing certain - # packages will fail. See https://stackoverflow.com/a/62639315 (Puppeteer - # needs later versions); https://github.com/nvm-sh/nvm#usage ("node" = - # shortcut for latest version); - # https://github.com/travis-ci/travis-ci/issues/4090#issuecomment-122688955 - # (why we use language: python in this file and can still use Node.js) - - nvm install node - # Install npm packages needed for JS testing - - npm install -g mocha-headless-chrome nyc - # Install npm packages needed for JS style-checking - - npm install -g prettier@2.0.5 jshint -script: - # This runs both the Python and JS tests - - make test - - make stylecheck -after_success: - # This section based on Qurro's Makefile. Upload coverage info to Codecov. - - wget -O codecov.sh https://codecov.io/bash - - bash codecov.sh -c diff --git a/Makefile b/Makefile index 9228bd6e..6ca05116 100644 --- a/Makefile +++ b/Makefile @@ -17,9 +17,9 @@ # based on the initial version of this Makefile, anyway, so it's a silly # chicken-and-egg thing). -.PHONY: pytest jstest test +.PHONY: pytest jstest test pystylecheck jsstylecheck stylecheck pystyle jsstyle style demo -PYTEST_COMMAND = python3 -B -m pytest metagenomescope/tests/ --cov +PYTEST_COMMAND = python3 -B -m pytest metagenomescope/tests/ --cov-report xml --cov-report term --cov metagenomescope PYLOCS = metagenomescope/ setup.py JSLOCS = metagenomescope/support_files/js/*.js metagenomescope/tests/js_tests/*.js docs/js/extra_functionality.js .jshintrc HTMLCSSLOCS = metagenomescope/support_files/index.html metagenomescope/tests/js_tests/*.html metagenomescope/support_files/css/viewer_style.css docs/404.html docs/index.html docs/css/mgsc_docs_style.css @@ -35,25 +35,26 @@ jstest: test: pytest jstest -stylecheck: +pystylecheck: flake8 --ignore=E203,W503,E266,E501 $(PYLOCS) black --check -l 79 $(PYLOCS) + +jsstylecheck: jshint $(JSLOCS) prettier --check --tab-width 4 $(JSLOCS) $(HTMLCSSLOCS) -style: +stylecheck: pystylecheck jsstylecheck + +pystyle: black -l 79 $(PYLOCS) - @# To be extra safe, do a dry run of prettier and check that it hasn't - @# changed the code's abstract syntax tree (AST). (Black does this sort of - @# thing by default.) - prettier --debug-check --tab-width 4 $(JSLOCS) $(HTMLCSSLOCS) - prettier --write --tab-width 4 $(JSLOCS) $(HTMLCSSLOCS) jsstyle: @# Shorthand, for when I'm developing JS code and don't want to waste time @# with python/HTML stuff prettier --write --tab-width 4 $(JSLOCS) +style: pystyle jsstyle + demo: @# makes a simple demo with a tiny graph that lets us test out the viewer @# interface diff --git a/README.md b/README.md index 34cc6b40..58f0882c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # MetagenomeScope -[![Build Status](https://travis-ci.org/marbl/MetagenomeScope.svg?branch=master)](https://travis-ci.org/marbl/MetagenomeScope) [![Code Coverage](https://codecov.io/gh/marbl/MetagenomeScope/branch/master/graph/badge.svg)](https://codecov.io/gh/marbl/MetagenomeScope) + +[![MgSc Python CI](https://github.com/marbl/Metagenomescope/actions/workflows/python.yml/badge.svg)](https://github.com/marbl/MetagenomeScope/actions/workflows/python.yml) +[![MgSc JavaScript CI](https://github.com/marbl/Metagenomescope/actions/workflows/js.yml/badge.svg)](https://github.com/marbl/MetagenomeScope/actions/workflows/js.yml) +[![Code Coverage](https://codecov.io/gh/marbl/MetagenomeScope/branch/master/graph/badge.svg)](https://codecov.io/gh/marbl/MetagenomeScope) ![Screenshot of MetagenomeScope's standard mode, showing an example assembly graph from Nijkamp et al. 2013](https://user-images.githubusercontent.com/4177727/100696036-6aa7ab80-3347-11eb-8017-f693aae08aa2.png "Screenshot of MetagenomeScope showing an example assembly graph from Nijkamp et al. 2013.")