Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
build: ci and black
Browse files Browse the repository at this point in the history
  • Loading branch information
zac-li committed Apr 19, 2023
1 parent 24d4366 commit 02cb018
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI

on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'

jobs:
commit-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.5.0
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v4

lint-flake-8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.5.0
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude .git,__pycache__,docs/source/conf.py,old,build,dist,tests/
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude .git,__pycache__,docs/source/conf.py,old,build,dist,tests/
check-black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.5.0
with:
fetch-depth: 0
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: 3.7
- id: file_changes
uses: Ana06/get-changed-files@v1.2
- name: check black
run: ./scripts/black.sh
env:
CHANGED_FILES: ${{ steps.file_changes.outputs.added_modified }}
17 changes: 17 additions & 0 deletions scripts/black.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
pip install black==22.3.0
arrVar=()
echo we ignore non-*.py files
excluded_files=(
)
for changed_file in $CHANGED_FILES; do
if [[ ${changed_file} == *.py ]] && ! [[ " ${excluded_files[@]} " =~ " ${changed_file} " ]]; then
echo checking ${changed_file}
arrVar+=(${changed_file})
fi
done
if (( ${#arrVar[@]} )); then
black -S --check "${arrVar[@]}"
fi
echo "no files left to check"
exit 0

0 comments on commit 02cb018

Please sign in to comment.