-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Various code style automation for dpctl
1. `flake8`, `isort` jobs added to check for Python code style for new PRs against `master`, `gold/2021`, `release` branches. 2. `black` max line width changed to 80 chars. 3. `flake8` and `isort` configs added. 4. `pre-commit` hooks added to make it possible to run all these checks prior to pushing code. 5. `CONTRIBUTION.md` updated.
- Loading branch information
1 parent
8866561
commit 1684403
Showing
8 changed files
with
196 additions
and
23 deletions.
There are no files selected for viewing
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,28 @@ | ||
[flake8] | ||
filename = *.py, *.pyx | ||
max_line_length = 80 | ||
max-doc-length = 80 | ||
extend-ignore = E203, W503 | ||
show-source = True | ||
|
||
exclude = | ||
versioneer.py | ||
dpctl/_version.py | ||
build | ||
conda.recipe | ||
.git | ||
|
||
per-file-ignores = | ||
dpctl/_sycl_context.pyx: E999, E225, E227 | ||
dpctl/_sycl_device.pyx: E999, E225 | ||
dpctl/_sycl_device_factory.pyx: E999, E225 | ||
dpctl/_sycl_event.pyx: E999, E225 | ||
dpctl/_sycl_platform.pyx: E999, E225 | ||
dpctl/_sycl_queue.pyx: E999, E225, E226, E227 | ||
dpctl/_sycl_queue_manager.pyx: E999, E225 | ||
dpctl/memory/_memory.pyx: E999, E225, E226, E227 | ||
dpctl/program/_program.pyx: E999, E225, E226, E227 | ||
dpctl/tensor/numpy_usm_shared.py: F821 | ||
examples/cython/sycl_buffer/_buffer_example.pyx: E999, E225, E402 | ||
examples/cython/sycl_direct_linkage/_buffer_example.pyx: E999, E225, E402 | ||
examples/cython/usm_memory/blackscholes.pyx: E999, E225, E226, E402 |
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,22 @@ | ||
# This is a workflow to format C/C++ sources with clang-format | ||
|
||
name: C++ Code Style | ||
|
||
# Controls when the action will run. Triggers the workflow on push or pull request | ||
# events but only for the master branch | ||
on: | ||
pull_request: | ||
push: | ||
branches: [master] | ||
|
||
jobs: | ||
formatting-check: | ||
name: clang-format | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Run clang-format style check for C/C++ programs. | ||
uses: jidicula/clang-format-action@v3.1.0 | ||
with: | ||
clang-format-version: '11' | ||
check-path: 'dpctl-capi' |
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,58 @@ | ||
# This is a workflow to format Python code with black formatter | ||
|
||
name: Python Code Style | ||
|
||
# Controls when the action will run. Triggers the workflow on push or pull request | ||
# events but only for the master branch | ||
on: | ||
pull_request: | ||
push: | ||
branches: [master] | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# The isort job sorts all imports in .py, .pyx, .pxd files | ||
isort: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
- uses: jamescurtin/isort-action@master | ||
with: | ||
args: ". --check-only" | ||
|
||
black: | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
# Set up a Python environment for use in actions | ||
- uses: actions/setup-python@v2 | ||
|
||
# Run black code formatter | ||
- uses: psf/black@21.4b2 | ||
with: | ||
args: ". --check" | ||
|
||
flake8: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: [3.7] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 | ||
- name: Lint with flake8 | ||
uses: py-actions/flake8@v1 |
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
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
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
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,2 +1,12 @@ | ||
[tool.black] | ||
exclude = 'versioneer.py' | ||
exclude = "versioneer.py|dpctl/_version.py" | ||
line-length = 80 | ||
|
||
[tool.isort] | ||
multi_line_output = 3 | ||
include_trailing_comma = true | ||
force_grid_wrap = 0 | ||
use_parentheses = true | ||
ensure_newline_before_comments = true | ||
line_length = 80 | ||
skip = ["versioneer.py", "dpctl/_version.py"] |
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