diff --git a/.github/workflows/cpp_style_checks.yml b/.github/workflows/cpp_style_checks.yml new file mode 100644 index 0000000000..b5a7def26f --- /dev/null +++ b/.github/workflows/cpp_style_checks.yml @@ -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' diff --git a/.github/workflows/python_style_checks.yml b/.github/workflows/python_style_checks.yml new file mode 100644 index 0000000000..9b425ce3bd --- /dev/null +++ b/.github/workflows/python_style_checks.yml @@ -0,0 +1,56 @@ +# 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 + + 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@20.8b1 + 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 diff --git a/pyproject.toml b/pyproject.toml index 2b233b61c9..23db3c6761 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,11 @@ [tool.black] -exclude = 'versioneer.py' +exclude = "versioneer.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 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000000..daa8c11370 --- /dev/null +++ b/tox.ini @@ -0,0 +1,5 @@ +[flake8] +filename = *.py, *.pyx +max_line_length = 80 +max-doc-length = 72 +show-source = True