diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..f7bf89b --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,40 @@ +name: Verify + +on: + push: + pull_request: + +permissions: {} + +jobs: + lint: + name: ESLint + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: yarn + - run: corepack enable + - run: yarn install --immutable + - run: yarn lint + + shexli: + name: Shexli + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: pip + cache-dependency-path: requirements-dev.txt + - run: corepack enable + - run: yarn setup-python + - run: yarn shexli diff --git a/.gitignore b/.gitignore index 2a95f1c..3cb9f9a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ gradienttopbar@pshow.org.shell-extension.zip node_modules +.venv .idea/ .yarn/* diff --git a/README.md b/README.md index feb349d..a231d0c 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ Before you start development, make sure you have the following installed: - GNOME Shell (version 45 or higher) - Node.js and Yarn (the project uses Yarn 4.0.1) +- Python 3.12 or newer - Git ## Setting Up the Development Environment @@ -75,6 +76,7 @@ Before you start development, make sure you have the following installed: 2. Install dependencies: ```bash yarn install + yarn setup-python ``` ## Development Tools @@ -98,12 +100,14 @@ The project includes several scripts to help with development: - `yarn prettify`: Formats code using Prettier. - `yarn lint`: Lints the code using ESLint. +- `yarn shexli`: Runs the extensions.gnome.org static analyzer. +- `yarn verify`: Runs ESLint and Shexli. - `yarn precommit`: Runs lint-staged for pre-commit hooks. ## Workflow 1. Make your changes to the code. -2. Run `yarn prettify` and `yarn lint` to ensure code quality. +2. Run `yarn prettify` and `yarn verify` to ensure code quality. 3. Test your changes using `yarn local-install` and `yarn open-prefs`. 4. If needed, debug using `yarn pref-debug` or `yarn nested-wayland`. 5. Submit a pull request with your changes. diff --git a/package.json b/package.json index 84b77ec..b3b0ea7 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,9 @@ "zip": "cd src && zip -r ../gradienttopbar@pshow.org.shell-extension.zip .", "prettify": "prettier --write 'src/**/*.{css}' && yarn lint --fix", "lint": "eslint 'src/**/*.{js,json}'", + "setup-python": "python3 -m venv .venv && .venv/bin/python -m pip install -r requirements-dev.txt", + "shexli": ".venv/bin/shexli --format json \"$PWD/src\" | .venv/bin/python -c \"import json, sys; report = json.load(sys.stdin); print(json.dumps(report, indent=2)); raise SystemExit(report['summary']['finding_count'] != 0)\"", + "verify": "yarn lint && yarn shexli", "precommit": "lint-staged", "upload": "gnome-extensions upload --accept-tos" }, diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..d7a88e8 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,2 @@ +shexli==0.2.1 +tree-sitter==0.25.2