Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions .github/workflows/black.yml

This file was deleted.

94 changes: 94 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Black and Pylint (python)

on: [pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@40853de9f8ce2d6cfdc73c1b96f14e22ba44aec4 # v45.0.0
with:
files: "**/*.py"

- name: Check if any files changed
id: check-changed-files
run: |
if [ -z "${{ steps.changed-files.outputs.all_changed_files }}" ]; then
echo "✅ No Python File Change in this PR, skipping CI Check." >> "$GITHUB_STEP_SUMMARY"
exit 0
else
echo "Python files changed. Continuing."
echo "file_changed=true" >> $GITHUB_ENV
fi

- name: Setup Python env
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'

- name: Install linters
run: pip install black pylint

- name: Create and install dependencies in virtual environment
if: env.file_changed == 'true'
run: |
python3 -m venv venv
./venv/bin/python -m pip install --upgrade pip
./venv/bin/python -m pip install "black~=23.0" "pylint~=2.17"

- name: Check formatting and lint changed Python files
if: env.file_changed == 'true'
env:
PYTHON3: ./venv/bin/python
run: |
set +euo pipefail
format_exit_status=0
lint_exit_status=0
files=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | xargs)

$PYTHON3 -m black --check $files
format_exit_status=$?
if [ $format_exit_status -ne 0 ]; then
echo "Python formatting issue detected by Black."
BLACK_OUTPUT=$($PYTHON3 -m black --diff $files 2>&1)
fi
echo "Black exit status: $format_exit_status"

$PYTHON3 -m pylint $files
lint_exit_status=$?
if [ $lint_exit_status -ne 0 ]; then
echo "Python linting issue detected by pylint."
PYLINT_OUTPUT=$($PYTHON3 -m pylint $files 2>&1)
fi
echo "Pylint exit status: $lint_exit_status"

SUMMARY=""
echo $lint_exit_status
echo $format_exit_status
echo "black and pylint output for changed files: $files" >> "$GITHUB_STEP_SUMMARY"
if [ -n "$BLACK_OUTPUT" ]; then
SUMMARY="${SUMMARY}\n### Black Output\n\`\`\`\n$BLACK_OUTPUT\n\`\`\`\n"
fi
if [ -n "$PYLINT_OUTPUT" ]; then
SUMMARY="${SUMMARY}\n### Pylint Output\n\`\`\`\n$PYLINT_OUTPUT\n\`\`\`\n"
fi

if [ $format_exit_status -ne 0 ] || [ $lint_exit_status -ne 0 ]; then
echo "❌ Black or pylint found issues in the code. Please fix them before committing." >> "$GITHUB_STEP_SUMMARY"
if [ -n "$SUMMARY" ]; then
echo -e "$SUMMARY" >> "$GITHUB_STEP_SUMMARY"
fi
else
echo "✅ No formatting or lint issues detected." >> "$GITHUB_STEP_SUMMARY"
fi

# TODO: Fail the CI pipeline if there are any issues
exit 0
25 changes: 25 additions & 0 deletions .github/workflows/pr-format-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: PR Format Checker

on:
pull_request:
types: [opened, edited, synchronize, reopened, labeled, unlabeled]

permissions:
contents: read
checks: read
statuses: read

jobs:
aviatrix-check:
runs-on: ubuntu-latest
steps:
- name: Run Merge Gatekeeper
# NOTE: v1 is updated to reflect the latest v1.x.y. Please use any tag/branch that suits your needs:
# https://github.com/upsidr/merge-gatekeeper/tags
# https://github.com/upsidr/merge-gatekeeper/branches
uses: upsidr/merge-gatekeeper@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ignored: "aviatrix-check"
timeout: 3600
interval: 10
1 change: 0 additions & 1 deletion pytest_testrail/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import os
import pytest
import re
import sys
import warnings
import logging
from datetime import datetime
Expand Down