-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds CI with sorted imports, style guide and tests (#295)
- Loading branch information
Showing
41 changed files
with
964 additions
and
533 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: test-bundle-workflow | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
env: | ||
PYTHON_VERSION: 3.7 | ||
|
||
defaults: | ||
run: | ||
working-directory: ./bundle-workflow | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ env.PYTHON_VERSION }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
- name: Install Pipenv and Dependencies | ||
run: | | ||
python -m pip install --upgrade pipenv wheel | ||
pipenv install --deploy --dev | ||
- name: Check for Sorted Imports | ||
run: | | ||
pipenv run isort --check . | ||
- name: Enforce Style Guide | ||
run: | | ||
pipenv run flake8 . | ||
- name: Run Tests | ||
run: | | ||
pipenv run pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,99 @@ | ||
<!-- TOC --> | ||
|
||
- [Developer Guide](#developer-guide) | ||
- [Forking and Cloning](#forking-and-cloning) | ||
- [Submitting Changes](#submitting-changes) | ||
- [Forking and Cloning](#forking-and-cloning) | ||
- [Install Prerequisites](#install-prerequisites) | ||
- [Python 3.7](#python-37) | ||
- [Pip](#pip) | ||
- [Pipenv](#pipenv) | ||
- [Run bundle-workflow](#run-bundle-workflow) | ||
- [Code Linting](#code-linting) | ||
- [Unit Tests](#unit-tests) | ||
|
||
## Developer Guide | ||
<!-- /TOC --> | ||
|
||
So you want to contribute code to this project? Excellent! We're glad you're here. Here's what you need to do. | ||
## Developer Guide | ||
|
||
### Forking and Cloning | ||
|
||
Fork this repository on GitHub, and clone locally with `git clone`. | ||
|
||
### Submitting Changes | ||
### Install Prerequisites | ||
|
||
#### Python 3.7 | ||
|
||
Python projects in this repository, including the [bundle-workflow](./bundle-workflow) project, use Python 3.7. See the [Python Beginners Guide](https://wiki.python.org/moin/BeginnersGuide) if you have never worked with the language. | ||
|
||
``` | ||
$ python3 --version | ||
Python 3.7.11 | ||
``` | ||
|
||
#### Pip | ||
|
||
[Pip](https://docs.python.org/3/installing/index.html) in the preferred installer program for Python3 modules. See [Pip Installation](https://pip.pypa.io/en/stable/installation/) for more details. | ||
|
||
``` | ||
$ pip --version | ||
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.7) | ||
``` | ||
|
||
#### Pipenv | ||
|
||
This project uses [pipenv](https://pipenv.pypa.io/en/latest/), which is typically installed with `pip install --user pipenv`. Pipenv automatically creates and manages a virtualenv for your projects, as well as adds/removes packages from your `Pipfile` as you install/uninstall packages. It also generates the ever-important `Pipfile.lock`, which is used to produce deterministic builds. | ||
|
||
``` | ||
$ pipenv --version | ||
pipenv, version 11.9.0 | ||
``` | ||
|
||
### Run bundle-workflow | ||
|
||
Try running `./build.sh` from [bundle-workflow](./bundle-workflow). It should complete and show usage. | ||
|
||
``` | ||
$ ./build.sh | ||
Installing dependencies in . ... | ||
Installing dependencies from Pipfile.lock (41aca1)… | ||
🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 14/14 — 00:00:01 | ||
To activate this project's virtualenv, run the following: | ||
$ pipenv shell | ||
Running ./src/build.py ... | ||
usage: build.py [-h] [-s] [-c COMPONENT] [--keep] manifest | ||
build.py: error: the following arguments are required: manifest | ||
``` | ||
|
||
### Code Linting | ||
|
||
This project uses [isort](https://github.com/PyCQA/isort) to ensure that imports are sorted, and [flake8](https://flake8.pycqa.org/en/latest/) to enforce code style. | ||
|
||
``` | ||
$ pipenv run flake8 | ||
./src/assemble_workflow/bundle_recorder.py:30:13: W503 line break before binary operator | ||
``` | ||
|
||
Use `isort .` to fix any sorting order. | ||
|
||
``` | ||
$ pipenv run isort . | ||
Fixing bundle-workflow/tests/system/test_arch.py | ||
``` | ||
|
||
Use [black](https://black.readthedocs.io/en/stable/) to auto-format your code. | ||
|
||
``` | ||
$ pipenv run black . | ||
All done! ✨ 🍰 ✨ | ||
23 files left unchanged. | ||
``` | ||
|
||
If your code isn't properly formatted, don't worry, [a CI workflow](./github/workflows/test-bundle-workflow.yml) will make sure to remind you. | ||
|
||
### Unit Tests | ||
|
||
This project uses [pytest](https://docs.pytest.org/en/6.2.x/) to ensure code quality. See [bundle-workflow/tests](bundle-workflow). | ||
|
||
See [CONTRIBUTING](CONTRIBUTING.md). | ||
``` | ||
$ pipenv run pytest | ||
2 passed in 0.02s | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
ignore = E722 | ||
max-line-length = 160 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.