From 17780ff7fa7f78ef4cc99f1117e3af18e919133d Mon Sep 17 00:00:00 2001 From: Sambhav Saxena Date: Tue, 27 May 2025 12:00:57 +0530 Subject: [PATCH 1/4] Update pylint.yml Signed-off-by: Sambhav Saxena --- .github/workflows/pylint.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index cb75be4..8b19aaf 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -22,13 +22,27 @@ jobs: - name: Install Python Dependencies run: | python -m pip install --upgrade pip - pip install flake8 black + pip install flake8 black diff-cover - name: Configure Flake8 - run: echo -e "[flake8]\nmax-line-length = 256\nindent-size = 4" > .flake8 + run: | + echo "[flake8]" > .flake8 + echo "max-line-length = 256" >> .flake8 + echo "indent-size = 4" >> .flake8 - - name: Run Flake8 (Python Linting) - run: flake8 . --count --show-source --statistics + - name: Get changed Python files + id: get_diff + run: | + git fetch origin ${{ github.base_ref }} + echo "changed_files=$(git diff --name-only origin/${{ github.base_ref }} -- '*.py' | tr '\n' ' ')" >> $GITHUB_OUTPUT - - name: Check Python Formatting with Black - run: black --check --diff --line-length 256 --target-version py310 --skip-string-normalization --fast . || true + - name: Run Flake8 on changed files + if: steps.get_diff.outputs.changed_files != '' + run: | + echo "Linting changed files: ${{ steps.get_diff.outputs.changed_files }}" + flake8 ${{ steps.get_diff.outputs.changed_files }} + + - name: Check Python Formatting with Black (changed files only) + if: steps.get_diff.outputs.changed_files != '' + run: | + black --check --diff --line-length 256 --target-version py310 --skip-string-normalization --fast ${{ steps.get_diff.outputs.changed_files }} From f3a7e45aa59d0b582adcf1bbb71f2699a3ab0eb5 Mon Sep 17 00:00:00 2001 From: Sambhav Saxena Date: Tue, 27 May 2025 12:09:55 +0530 Subject: [PATCH 2/4] Fixes error: `No files matching the pattern were found: "**/*.{js,ts,jsx,tsx,vue,css,html,json}"` The script used to run and throw an error even in cases where no JS or related prettier configured files are found, and eventually lead to a failed workflow. This is not expected behaviour, which has been updated with this patch. Signed-off-by: Sambhav Saxena --- .github/workflows/jslint.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/jslint.yml b/.github/workflows/jslint.yml index 27c54d0..e7c3d03 100644 --- a/.github/workflows/jslint.yml +++ b/.github/workflows/jslint.yml @@ -23,7 +23,13 @@ jobs: run: npm install -g prettier - name: Run Prettier (JS Linting) - run: prettier --check '**/*.{js,ts,jsx,tsx,vue,css,html,json}' --log-level debug --write + run: | + FILES=$(find . -type f \( -name "*.js" -o -name "*.ts" -o -name "*.jsx" -o -name "*.tsx" -o -name "*.vue" -o -name "*.css" -o -name "*.html" -o -name "*.json" \)) + if [ -n "$FILES" ]; then + echo "$FILES" | xargs prettier --check --log-level debug + else + echo "No matching files found for linting." + fi - name: Fail on Lint Errors if: failure() From a7485795a6ebafbbd916ea307fb27662aaf50767 Mon Sep 17 00:00:00 2001 From: Sambhav Saxena Date: Tue, 27 May 2025 15:00:50 +0530 Subject: [PATCH 3/4] Update jslint.yml with write flag Signed-off-by: Sambhav Saxena --- .github/workflows/jslint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jslint.yml b/.github/workflows/jslint.yml index e7c3d03..d1d6011 100644 --- a/.github/workflows/jslint.yml +++ b/.github/workflows/jslint.yml @@ -26,7 +26,7 @@ jobs: run: | FILES=$(find . -type f \( -name "*.js" -o -name "*.ts" -o -name "*.jsx" -o -name "*.tsx" -o -name "*.vue" -o -name "*.css" -o -name "*.html" -o -name "*.json" \)) if [ -n "$FILES" ]; then - echo "$FILES" | xargs prettier --check --log-level debug + echo "$FILES" | xargs prettier --check --log-level debug --write else echo "No matching files found for linting." fi From 01a74797fdaea8773b474d3ba63f200d3e4c2aeb Mon Sep 17 00:00:00 2001 From: Sambhav Saxena Date: Fri, 30 May 2025 13:17:19 +0530 Subject: [PATCH 4/4] Update jslint.yml Signed-off-by: Sambhav Saxena --- .github/workflows/jslint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jslint.yml b/.github/workflows/jslint.yml index d1d6011..0d5dd2c 100644 --- a/.github/workflows/jslint.yml +++ b/.github/workflows/jslint.yml @@ -26,7 +26,7 @@ jobs: run: | FILES=$(find . -type f \( -name "*.js" -o -name "*.ts" -o -name "*.jsx" -o -name "*.tsx" -o -name "*.vue" -o -name "*.css" -o -name "*.html" -o -name "*.json" \)) if [ -n "$FILES" ]; then - echo "$FILES" | xargs prettier --check --log-level debug --write + echo "$FILES" | xargs prettier --log-level debug --write else echo "No matching files found for linting." fi