From 0b2cf0ad4fb136ee699b7f1eb6b82ae1048c03d9 Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Wed, 28 Apr 2021 11:32:35 -0500 Subject: [PATCH 1/8] Add isort as a style check for dpctl. --- .github/workflows/black.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index 6d7d7bb624..82afef9cf2 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -1,6 +1,6 @@ # This is a workflow to format Python code with black formatter -name: black +name: Code style Python # Controls when the action will run. Triggers the workflow on push or pull request # events but only for the master branch @@ -11,7 +11,14 @@ on: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "black" + # The isort jon sort all imports in .py, .pyx, .pyd sources + 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 From 1cbd353f451b81c08b7dcb0d828c1c8b3a889368 Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Wed, 28 Apr 2021 11:34:27 -0500 Subject: [PATCH 2/8] Rename black.yml to py_style_check.yml --- .github/workflows/{black.yml => py_style_checks.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{black.yml => py_style_checks.yml} (100%) diff --git a/.github/workflows/black.yml b/.github/workflows/py_style_checks.yml similarity index 100% rename from .github/workflows/black.yml rename to .github/workflows/py_style_checks.yml From 6d799cdec7171e12ae6b7cf3a478dff27f94c1f4 Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Wed, 28 Apr 2021 12:54:55 -0500 Subject: [PATCH 3/8] revert name change for now. --- .github/workflows/{py_style_checks.yml => black.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{py_style_checks.yml => black.yml} (100%) diff --git a/.github/workflows/py_style_checks.yml b/.github/workflows/black.yml similarity index 100% rename from .github/workflows/py_style_checks.yml rename to .github/workflows/black.yml From 227b51df01f784a0d0b18349891be181bc46d5d9 Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Wed, 28 Apr 2021 13:37:13 -0500 Subject: [PATCH 4/8] Fixes to job names and typos in comments. --- .github/workflows/black.yml | 4 ++-- .github/workflows/clang-format.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index 82afef9cf2..33fe88f141 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -1,6 +1,6 @@ # This is a workflow to format Python code with black formatter -name: Code style Python +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 @@ -11,7 +11,7 @@ on: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # The isort jon sort all imports in .py, .pyx, .pyd sources + # The isort job sorts all imports in .py, .pyx, .pxd files isort: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index b2fa896dd4..b5a7def26f 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -1,6 +1,6 @@ # This is a workflow to format C/C++ sources with clang-format -name: clang-format Check +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 @@ -11,7 +11,7 @@ on: jobs: formatting-check: - name: Formatting Check + name: clang-format runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 985cad29bd3e261537bedbb656d8f0b433c7a4f1 Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Wed, 28 Apr 2021 18:21:53 -0500 Subject: [PATCH 5/8] Add flak8 job --- .github/workflows/black.yml | 20 ++++++++++++++++++++ pyproject.toml | 11 ++++++++++- tox.ini | 4 ++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tox.ini diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index 33fe88f141..9b425ce3bd 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -34,3 +34,23 @@ jobs: - 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..09fa1727b4 --- /dev/null +++ b/tox.ini @@ -0,0 +1,4 @@ +[flake8] +filename = *.py, *.pyx +max_line_length = 80 +max-doc-length = 72 From 140ce3f76c06807b35c415ee1e32a7346929268d Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Wed, 28 Apr 2021 18:29:16 -0500 Subject: [PATCH 6/8] Show source. --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 09fa1727b4..daa8c11370 100644 --- a/tox.ini +++ b/tox.ini @@ -2,3 +2,4 @@ filename = *.py, *.pyx max_line_length = 80 max-doc-length = 72 +show-source = True From 2d7431661b605b287ab2d519f8efb59c6d08fb06 Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Wed, 28 Apr 2021 19:27:50 -0500 Subject: [PATCH 7/8] Revert changes to black.yml and add a new yml file. Will swap them later. --- .github/workflows/black.yml | 31 +------------ .github/workflows/python_style_checks.yml | 56 +++++++++++++++++++++++ 2 files changed, 58 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/python_style_checks.yml diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index 9b425ce3bd..6d7d7bb624 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -1,6 +1,6 @@ # This is a workflow to format Python code with black formatter -name: Python Code Style +name: black # Controls when the action will run. Triggers the workflow on push or pull request # events but only for the master branch @@ -11,14 +11,7 @@ on: # 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 - + # This workflow contains a single job called "black" black: # The type of runner that the job will run on runs-on: ubuntu-latest @@ -34,23 +27,3 @@ jobs: - 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/.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 From 9a71a080b2cec298973f15a57497ae16f8ee488f Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Wed, 28 Apr 2021 19:29:59 -0500 Subject: [PATCH 8/8] Add cpp style checks in a new yml file and revert changes to old action. Will swap them later. --- .github/workflows/clang-format.yml | 4 ++-- .github/workflows/cpp_style_checks.yml | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/cpp_style_checks.yml diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index b5a7def26f..b2fa896dd4 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -1,6 +1,6 @@ # This is a workflow to format C/C++ sources with clang-format -name: C++ Code Style +name: clang-format Check # Controls when the action will run. Triggers the workflow on push or pull request # events but only for the master branch @@ -11,7 +11,7 @@ on: jobs: formatting-check: - name: clang-format + name: Formatting Check runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 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'