Skip to content

Commit

Permalink
Add Pre-commit hook (#244)
Browse files Browse the repository at this point in the history
* Move tests to root

* Pre-Commit Hook

* remove pytest.ini

* Add dev requirements to build

* Add contributing guide
  • Loading branch information
ross-p-smith authored Feb 1, 2024
1 parent 3e780b5 commit 2c29aea
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
},

"postCreateCommand": "pip install -r code/requirements.txt -r code/app/requirements.txt -r extensions/backend/requirements.txt",
"postCreateCommand": "./.devcontainer/postCreate.sh",

"customizations": {
"vscode": {
Expand Down
9 changes: 9 additions & 0 deletions .devcontainer/postCreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

pip install --upgrade pip

pip install -r code/requirements.txt -r code/app/requirements.txt -r extensions/backend/requirements.txt

pip install -r code/dev-requirements.txt

pre-commit install
2 changes: 1 addition & 1 deletion .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ jobs:
architecture: x64
- name: Install dependencies
run: |
pip install -r code/requirements.txt
pip install -r code/requirements.txt -r code/dev-requirements.txt
- name: Run Python tests
run: python -m pytest --rootdir=code -m "not azure"
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
language_version: python3

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
args: [--extend-ignore=E501]
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Before you submit your Pull Request (PR) consider the following guidelines:
* Make your changes in a new git fork:

* Commit your changes using a descriptive commit message
* If you are using the devcontainer, committing code will run black and flake8 to lint python code. You can run `black .` or `flake8 .` at anytime.
* Push your fork to GitHub:
* In GitHub, create a pull request
* If we suggest changes then:
Expand Down
5 changes: 5 additions & 0 deletions code/dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pytest==8.0.0
pytest-cov==4.1.0
flake8==7.0.0
pre-commit==3.5.0
black==23.12.1
3 changes: 0 additions & 3 deletions code/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,3 @@ azure-search-documents==11.4.0b8
opencensus-ext-azure==1.1.13
pandas==2.2.0
python-docx==1.1.0

# Add dev dependencies here - this will be refactored out by Poetry
pytest==8.0.0

0 comments on commit 2c29aea

Please sign in to comment.