From c231f3e4b8dd00be538334c5f6f7afd3089db991 Mon Sep 17 00:00:00 2001 From: Timid Robot Zehta Date: Sat, 28 Jan 2023 12:10:23 -0800 Subject: [PATCH 1/2] add static analysis GitHub Action of python files using black, flake8, and isort --- .github/workflows/python_static_analysis.yml | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/python_static_analysis.yml diff --git a/.github/workflows/python_static_analysis.yml b/.github/workflows/python_static_analysis.yml new file mode 100644 index 00000000..b43879fa --- /dev/null +++ b/.github/workflows/python_static_analysis.yml @@ -0,0 +1,39 @@ +name: Python Static Analysis + +on: + pull_request: + push: + branches: [main] + workflow_dispatch: + +jobs: + job: + runs-on: ubuntu-latest + + steps: + + # https://github.com/actions/setup-python + - name: Install Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install Python dependencies + run: | + pip install --upgrade pip + pip install black + pip install flake8 + pip install isort + + # https://github.com/actions/checkout + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Run isort + run: isort --check . + + - name: Run flake8 + run: flake8 + + - name: Run black + run: black --check . From 27b3d853a438502e056894a607e640e220d23b68 Mon Sep 17 00:00:00 2001 From: Timid Robot Zehta Date: Sat, 28 Jan 2023 13:24:18 -0800 Subject: [PATCH 2/2] reduce number of pip invocations and include jupyter support for black --- .github/workflows/python_static_analysis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/python_static_analysis.yml b/.github/workflows/python_static_analysis.yml index b43879fa..c44dc591 100644 --- a/.github/workflows/python_static_analysis.yml +++ b/.github/workflows/python_static_analysis.yml @@ -21,9 +21,7 @@ jobs: - name: Install Python dependencies run: | pip install --upgrade pip - pip install black - pip install flake8 - pip install isort + pip install black 'black[jupyter]' flake8 isort # https://github.com/actions/checkout - name: Checkout repository