From da8706cf78aa29376fc092a027fbd3cbea23a83a Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Fri, 17 Oct 2025 07:55:52 -0300 Subject: [PATCH 1/3] SIENTIAPDE-1318 Enhance validation script and CI workflow for improved code quality checks - Added support for a --fix option in validate.sh to apply Ruff auto-fixes for formatting and linting. - Updated GitHub Actions workflow to install development and runtime dependencies separately. - Integrated the validation script execution into the CI pipeline to ensure code quality checks are performed automatically. --- .github/workflows/quality-gate.yml | 12 ++++++++++-- validate.sh | 29 +++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/.github/workflows/quality-gate.yml b/.github/workflows/quality-gate.yml index 0d3ff14..d983984 100644 --- a/.github/workflows/quality-gate.yml +++ b/.github/workflows/quality-gate.yml @@ -57,11 +57,19 @@ jobs: restore-keys: | ${{ runner.os }}-pip- - - name: ๐Ÿ“ฆ Install Dependencies + - name: ๐Ÿ“ฆ Install Development Dependencies run: | python -m pip install --upgrade pip + pip install -r requirements-dev.txt + + - name: ๐Ÿ“ฆ Install Runtime Dependencies + run: | pip install -r ${{ steps.prepare-requirements.outputs.PROCESSED_REQUIREMENTS_FILE }} - pip install pytest pytest-cov pytest-asyncio + + - name: ๐Ÿ” Run Code Validation + run: | + chmod +x validate.sh + ./validate.sh - name: ๐Ÿงช Run Tests with Pytest run: | diff --git a/validate.sh b/validate.sh index aeed301..c7c44fe 100755 --- a/validate.sh +++ b/validate.sh @@ -11,6 +11,27 @@ YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color +# Args +FIX_MODE=false +while [[ $# -gt 0 ]]; do + case "$1" in + --fix) + FIX_MODE=true + shift + ;; + -h|--help) + echo "Usage: $0 [--fix]" + echo " --fix Apply Ruff auto-fixes (format and lint fixes)." + exit 0 + ;; + *) + echo -e "${RED}Unknown option: $1${NC}" + echo "Usage: $0 [--fix]" + exit 2 + ;; + esac +done + echo -e "${BLUE}โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—${NC}" echo -e "${BLUE}โ•‘ Model Manager - Code Validation Suite โ•‘${NC}" echo -e "${BLUE}โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•${NC}" @@ -47,12 +68,16 @@ run_step() { FAILED_STEPS=() # Step 1: Code Formatting Check (Ruff) -if ! run_step "1. Code Formatting (Ruff)" "ruff format laborious/ tests/ && ruff format --check laborious/ tests/"; then +# - default: check only +# - --fix: write changes +if ! run_step "1. Code Formatting (Ruff)" "if \$FIX_MODE; then ruff format laborious/ tests/; else ruff format --check laborious/ tests/; fi"; then FAILED_STEPS+=("Code Formatting") fi # Step 2: Linting (Ruff) -if ! run_step "2. Code Linting (Ruff)" "ruff check --fix laborious/ tests/"; then +# - default: check only +# - --fix: apply autofixes +if ! run_step "2. Code Linting (Ruff)" "if \$FIX_MODE; then ruff check --fix laborious/ tests/; else ruff check laborious/ tests/; fi"; then FAILED_STEPS+=("Linting") fi From 3326a7da005d015370ad6cf6dd37118406a5fd5d Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Fri, 17 Oct 2025 12:14:57 -0300 Subject: [PATCH 2/3] SIENTIAPDE-1318 Remove Pytest test execution from CI workflow and add a blank line in MinioRepository class for improved readability. --- .github/workflows/quality-gate.yml | 4 ---- laborious/utils/repository/minio_repository.py | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/quality-gate.yml b/.github/workflows/quality-gate.yml index d983984..6730856 100644 --- a/.github/workflows/quality-gate.yml +++ b/.github/workflows/quality-gate.yml @@ -71,10 +71,6 @@ jobs: chmod +x validate.sh ./validate.sh - - name: ๐Ÿงช Run Tests with Pytest - run: | - pytest tests --junitxml=pytest.xml --cov=laborious --cov-report=xml --cov-report=term - - name: Run SonarQube Analysis uses: SonarSource/sonarqube-scan-action@v5 env: diff --git a/laborious/utils/repository/minio_repository.py b/laborious/utils/repository/minio_repository.py index 03b0f15..e6686e2 100644 --- a/laborious/utils/repository/minio_repository.py +++ b/laborious/utils/repository/minio_repository.py @@ -33,6 +33,7 @@ class MinioRepository: logger (Logger): Observability logger. notification_handler (NotificationHandler): Notifications handler. """ + def __init__( self, minio_endpoint_url: str, From 04cbce259f05f0849dab20b9547f373fca313d01 Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Fri, 17 Oct 2025 12:34:52 -0300 Subject: [PATCH 3/3] SIENTIAPDE-1318 Enhance CI workflow for comprehensive code quality checks - Added code formatting check, linting, type checking, and security analysis steps using Ruff, mypy, and Bandit. - Integrated pytest for running tests, ensuring a robust quality gate in the CI pipeline. --- .github/workflows/quality-gate.yml | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/quality-gate.yml b/.github/workflows/quality-gate.yml index 6730856..e908b49 100644 --- a/.github/workflows/quality-gate.yml +++ b/.github/workflows/quality-gate.yml @@ -66,10 +66,33 @@ jobs: run: | pip install -r ${{ steps.prepare-requirements.outputs.PROCESSED_REQUIREMENTS_FILE }} - - name: ๐Ÿ” Run Code Validation + - name: ๐Ÿ“ Code Formatting Check (Ruff) run: | - chmod +x validate.sh - ./validate.sh + echo "Checking code formatting..." + ruff format --check laborious/ tests/ + continue-on-error: false + + - name: ๐Ÿ”Ž Code Linting (Ruff) + run: | + echo "Running linting checks..." + ruff check laborious/ tests/ + continue-on-error: false + + - name: ๐Ÿท๏ธ Type Checking (mypy) + run: | + echo "Running type checks..." + mypy laborious/ + continue-on-error: true + + - name: ๐Ÿ”’ Security Analysis (Bandit) + run: | + echo "Running security analysis..." + bandit -r laborious/ -ll -q + continue-on-error: true + + - name: ๐Ÿงช Run Tests with Pytest + run: | + pytest tests --junitxml=pytest.xml --cov=laborious --cov-report=xml --cov-report=term - name: Run SonarQube Analysis uses: SonarSource/sonarqube-scan-action@v5