Skip to content

Commit

Permalink
Introduce docformatter tool and lint workflow in the project
Browse files Browse the repository at this point in the history
Added docformatter configuration in 'pyproject.toml' and implemented new 'do-lint.yaml' GitHub action workflow to improve code formatting practices. This workflow activates on push events and ensures the entire codebase is properly formatted. The configuration enables recursive formatting with 'black', and options to control formatting of quotes and blank lines. Adjustments were also made in 'generator-publish-sources.yaml' workflow
  • Loading branch information
Omar Al-Jarrah committed Nov 29, 2023
1 parent 5ee28c7 commit 33ee5c2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/do-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2022 Expedia, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Do Lint
on:
push:
branches:
- '*'
- '*/*'
- '**'
- '!main'
jobs:
flake8-lint:
runs-on: ubuntu-latest
name: Lint
steps:
- name: Check out source repository
uses: actions/checkout@v4
- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Dependencies
run: pip install -r requirements-dev.txt
- name: Run Linters
run: |
isort .
black .
docformatter --check --config pyproject.toml .
docformatter --in-place --config pyproject.toml .
5 changes: 0 additions & 5 deletions .github/workflows/generator-publish-sources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ jobs:
cp -r ./docs ../../../../release/"${{github.event.inputs.name}}"/
find ./ -name \*.py -exec cp {} ../../../../release/"${{github.event.inputs.name}}"/src/ \;
find ./ -name \*.yaml -exec cp {} ../../../../release/"${{github.event.inputs.name}}"/src/ \;
- name: Format Code
run: |
pip3 install -r requirements-dev.txt
isort release
black release
- name: Create PR
uses: peter-evans/create-pull-request@v5
with:
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ line-length = 160
[tool.isort]
profile = "black"
multi_line_output = 1

[tool.docformatter]
recursive = true
black = true
close-quotes-on-newline = true
blank = true
pre-summary-newline = true

0 comments on commit 33ee5c2

Please sign in to comment.