Skip to content

Commit

Permalink
Adds CI with sorted imports, style guide and tests (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock authored Aug 24, 2021
1 parent 44e7472 commit 147cee8
Show file tree
Hide file tree
Showing 41 changed files with 964 additions and 533 deletions.
93 changes: 0 additions & 93 deletions .github/workflows/check-vulnerability-whitesource.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/test-bundle-workflow.yml
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
96 changes: 90 additions & 6 deletions DEVELOPER_GUIDE.md
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
```
3 changes: 3 additions & 0 deletions bundle-workflow/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
ignore = E722
max-line-length = 160
3 changes: 3 additions & 0 deletions bundle-workflow/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ name = "pypi"
[packages]
pyyaml = "~=5.4"
requests = "~=2.26"
isort = "~=5.9"
flake8 = "~=3.9"
pytest = "*"

[dev-packages]

Expand Down
Loading

0 comments on commit 147cee8

Please sign in to comment.