-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(workflows): code formatting and linting
Overhaul workflow (jobs) for code formatting and linting, i.e. Black, Flake8, isort: rename file, allow manual triggering of workflow, set ENV variable for Python version, make equivalent steps in individual jobs more consistent, give every step a name. In setup.cfg, use black profile for isort to avoid redundancy; use same Python version as in workflow file. Add SPDX identifiers.
- Loading branch information
Showing
3 changed files
with
71 additions
and
60 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,69 @@ | ||
# SPDX-FileCopyrightText: 2024 K Kollmann | ||
# SPDX-License-Identifier: MIT | ||
|
||
name: Code formatting and linting | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
workflow_dispatch: | ||
|
||
env: | ||
PYTHON_VERSION: "3.9" | ||
|
||
jobs: | ||
black: | ||
name: Black code formatter | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4.1.6 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: Run Black | ||
uses: psf/black@24.4.2 | ||
with: | ||
options: "--version --check --diff --color" # default: "--check --diff" | ||
|
||
flake8: | ||
name: Flake8 linter | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4.1.6 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: Set up Python environment – ${{ env.PYTHON_VERSION }} | ||
uses: actions/setup-python@v5.1.0 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade wheel pip | ||
pip install .[lint] | ||
- name: Show Flake8 version | ||
run: flake8 --version | ||
- name: Run Flake8 | ||
run: flake8 -v --show-source moviepy setup.py scripts docs/conf.py examples tests | ||
|
||
isort: | ||
name: isort import sorter | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4.1.6 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: Set up Python environment – ${{ env.PYTHON_VERSION }} | ||
uses: actions/setup-python@v5.1.0 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade wheel pip | ||
pip install .[lint] | ||
- name: Run isort | ||
run: isort --check-only --diff moviepy setup.py scripts docs/conf.py examples tests |
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