From 23bac0fc76ad697abb34f3fb327df5cdeb40286a Mon Sep 17 00:00:00 2001 From: undergroundwires Date: Fri, 26 Apr 2024 17:03:38 +0200 Subject: [PATCH] ci/cd: lint Python scripts using `pylint` This commit integrates `pylint` into the CI/CD pipeline to improve the quality of Python scripts within the project. By enforcing stricter linting standards, the aim is to identify and correct potential issues more efficiently, ultimately contributing to more reliable and maintainable code. Changes: - Introduce `npm run lint:pylint` command to facilitate unified way to run linting on different environments. - Include `npm run lint:pylint` in the CI/CD workflow to ensure all commits adhere to established Python coding standards. - Fix an issue identified by `pylint` in `configure_vscode.py`. - Rename the workflow to match the latest naming convention. --- .github/workflows/checks.quality.yaml | 29 ++++++++++++++++++++++++++- README.md | 4 ++-- package.json | 3 ++- scripts/configure_vscode.py | 3 ++- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/.github/workflows/checks.quality.yaml b/.github/workflows/checks.quality.yaml index d60ec8cd..08468192 100644 --- a/.github/workflows/checks.quality.yaml +++ b/.github/workflows/checks.quality.yaml @@ -1,4 +1,4 @@ -name: quality-checks +name: checks.quality on: [ push, pull_request ] @@ -47,3 +47,30 @@ jobs: echo 'No TODO comments found in the latest commit.' exit 0 fi + + pylint: + runs-on: ${{ matrix.os }}-latest + strategy: + matrix: + os: [ macos, ubuntu, windows ] + fail-fast: false # Still interested to see results from other combinations + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Setup node + uses: ./.github/actions/setup-node + - + name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + - + name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pylint + - + name: Analyzing the code with pylint + run: npm run lint:pylint diff --git a/README.md b/README.md index f7eb543b..c025c4f0 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,8 @@
Quality checks status diff --git a/package.json b/package.json index 44645570..58920bcd 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "test:integration": "vitest run --dir tests/integration", "test:cy:run": "start-server-and-test \"vite build && vite preview --port 7070\" http://localhost:7070 \"cypress run --config baseUrl=http://localhost:7070\"", "test:cy:open": "start-server-and-test \"vite --port 7070 --mode production\" http://localhost:7070 \"cypress open --config baseUrl=http://localhost:7070\"", - "lint": "npm run lint:md && npm run lint:md:consistency && npm run lint:md:relative-urls && npm run lint:eslint && npm run lint:yaml", + "lint": "npm run lint:md && npm run lint:md:consistency && npm run lint:md:relative-urls && npm run lint:eslint && npm run lint:yaml && npm run lint:pylint", "install-deps": "node scripts/npm-install.js", "icons:build": "node scripts/logo-update.js", "check:desktop": "vitest run --dir tests/checks/desktop-runtime-errors --environment node", @@ -29,6 +29,7 @@ "lint:md:consistency": "remark . --frail --use remark-preset-lint-consistent", "lint:md:relative-urls": "remark . --frail --use remark-validate-links", "lint:yaml": "yamllint **/*.yaml --ignore=node_modules/**/*.yaml", + "lint:pylint": "pylint **/*.py", "postinstall": "electron-builder install-app-deps", "postuninstall": "electron-builder install-app-deps" }, diff --git a/scripts/configure_vscode.py b/scripts/configure_vscode.py index 71207f96..4c65c2a3 100755 --- a/scripts/configure_vscode.py +++ b/scripts/configure_vscode.py @@ -98,7 +98,8 @@ def locate_vscode_cli() -> Optional[str]: if vscode_alias: return vscode_alias potential_vscode_cli_paths = [ - '/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code' # macOS VS Code may not register 'code' command in PATH + # VS Code on macOS may not register 'code' command in PATH + '/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code' ] for vscode_cli_candidate_path in potential_vscode_cli_paths: if Path(vscode_cli_candidate_path).is_file():