#27 color-scheme-check #2
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
name: Lint Code Base | |
on: | |
push: | |
branches: [ main ] | |
paths: | |
- '**.py' | |
pull_request: | |
branches: [ main ] | |
paths: | |
- '**.py' | |
jobs: | |
build: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Fetches all history for all branches and tags | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 | |
- name: Get changed Python files | |
run: | | |
base_sha=$(git merge-base ${{ github.event.pull_request.base.sha || github.base_ref }} ${{ github.sha }}) | |
echo "Base SHA: $base_sha" | |
echo "Head SHA: ${{ github.sha }}" | |
changed_files=$(git diff --name-only $base_sha ${{ github.sha }} | grep '\.py$' || echo "") | |
echo "Changed Python files: $changed_files" | |
if [ -z "$changed_files" ]; then | |
echo "No Python files changed" | |
exit 0 | |
fi | |
echo "changed_files=$changed_files" >> $GITHUB_ENV | |
- name: Run Flake8 on changed files | |
run: | | |
if [ -n "$changed_files" ]; then | |
echo "Running Flake8 on changed files:" | |
echo $changed_files | |
flake8_output=$(flake8 $changed_files --count --select=E9,F63,F7,F82 --show-source --statistics) | |
echo "flake8_output<<EOF" >> $GITHUB_ENV | |
echo "$flake8_output" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
else | |
echo "No Python files changed" | |
fi | |