Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Black/Python Linting Github Workflow #885

Merged
merged 6 commits into from Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions .github/workflows/process-changes.yml
Expand Up @@ -6,8 +6,8 @@ on: pull_request
# - master

jobs:
eslint_check:
name: "Linter Check"
lint-js:
name: "Javascript Linter Check"
runs-on: ubuntu-latest
steps:
- name: "Checkout Repository"
Expand All @@ -21,6 +21,18 @@ jobs:
- name: "Linter Check (ESLint)"
run: npm run lint

lint-py:
name: "Python Linter Check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@22.10.0
with:
src: "./py"
- name: Check for Linting Errors
if: failure()
run: echo "::warning title='Python Linter Check failed'::Please run \"pip install black; black py\" before committing code changes to python files."

install-and-build:
name: "Install and Build"
runs-on: ubuntu-latest
Expand Down Expand Up @@ -146,4 +158,3 @@ jobs:
with:
name: cypress-screenshots-functional
path: cypress/screenshots

4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.6.2
hooks:
- id: prettier
files: "\\.(\
css\
|js|jsx\
|json\
)$"
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -91,8 +91,12 @@ We actively welcome your pull requests.
5. If you change `js/`, commit the React-compiled version of `main.js`. For details, please see `Contributing to the UI` below.
6. Add demos for new features. Ensure the demos work.
7. Make sure your code lints.
- For JavaScript-Files, use `npm lint`
- For Python-Files, use `black py`
- To do that automatically before each `git commit`, enable pre-commit hooks: `pre-commit install`.
8. If you haven't already, complete the Contributor License Agreement ("CLA").


## Contributing to the UI
The UI is built with [React](https://facebook.github.io/react/). For testing,
this means that `js/` needs to be compiled. This can be done with `yarn` or
Expand Down
13 changes: 0 additions & 13 deletions package.json
Expand Up @@ -18,8 +18,6 @@
"eslint-plugin-ignore-generated-and-nolint": "^1.0.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.29.4",
"husky": "^7.0.4",
"lint-staged": "^12.3.7",
"pixelmatch": "^5.2.1",
"pngjs": "^6.0.0",
"prettier": "^2.6.2",
Expand Down Expand Up @@ -71,16 +69,5 @@
"url": "^0.11.0",
"util": "^0.12.4",
"whatwg-fetch": "^3.6.2"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,json,css}": [
"prettier --write",
"git add"
]
}
}