feat(scripts): add npm run scripts for Python linting and testing#933
feat(scripts): add npm run scripts for Python linting and testing#933JasonOA888 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
- Add lint:py for ruff check - Add lint:py:fix for ruff check --fix - Add test:py for pytest Follows existing npm run script patterns for consistency. Fixes microsoft#886
|
Hi @JasonOA888 — thank you for taking the time to contribute to this project! We really appreciate the effort you've put into this PR. Before we can review and merge your changes, we need you to sign the Microsoft Contributor License Agreement (CLA). The CLA bot should have posted instructions on this PR when it was opened. You can sign by posting the following comment:
If you're contributing on behalf of a company, use:
We'd love to include your work, but unfortunately we won't be able to accept the contribution without a signed CLA. If we don't hear back, we'll eventually need to close this PR and potentially redo the work under a signed agreement. Thanks again, and please let us know if you have any questions! |
|
PR Compliance Update — The PR body was reformatted to use the project's PR template with all required sections (Related Issue(s), Type of Change, Checklist, Security Considerations, etc.). The original description and No content was changed — only formatting alignment. Thank you for the contribution! 🙏 |
| "lint:frontmatter": "pwsh -NoProfile -Command \"& './scripts/linting/Validate-MarkdownFrontmatter.ps1' -WarningsAsErrors -EnableSchemaValidation\"", | ||
| "lint:collections-metadata": "pwsh -File scripts/collections/Validate-Collections.ps1", | ||
| "lint:marketplace": "pwsh -File scripts/plugins/Validate-Marketplace.ps1", | ||
| "lint:py": "ruff check .", |
There was a problem hiding this comment.
@JasonOA888 thanks for taking the time for creating a contribution.
We noticed there are a few small things missing to align the change with the issue description: primarily each of these new additions should ensure dynamic discovery of each Skill using Python through their pyproject.yaml files, using find. Could you update your PR to match the issue requirements?
Thanks for the alphabetical ordering, this is helpful too!
|
@microsoft-github-policy-service agree |
|
Thanks for the review @katriendg and @WilliamBerryiii! The CLA has been signed. Regarding the dynamic discovery of Python Skills using
Are you asking for these commands to dynamically discover Python files rather than running on Happy to update the PR once I understand the requirements better. |
@JasonOA888 I'll get you an example in a min ... basically getting ruff mapped into all the various skills folders that have python in them. Obviously, right now we only have 1 skill still in PR form with python code in it, but we are anticipating needed to support a TON of skills where python is the backing code for the skill ... so we want to make sure the CLI commands for devs, go and find all the skills that py project toml files and lints them all. (Hope that clears things up) |
Implements dynamic discovery of Python skills by finding all pyproject.toml files and running ruff/pytest on each. ## Changes - Add Invoke-PythonLint.ps1 - discovers Python skills and runs ruff - Add Invoke-PythonTests.ps1 - discovers Python skills and runs pytest - Update package.json scripts: - lint:py -> uses Invoke-PythonLint.ps1 - test:py -> uses Invoke-PythonTests.ps1 ## How it works 1. Scans repository for pyproject.toml files (excludes node_modules) 2. For each Python skill directory: - lint:py runs ruff check - test:py runs pytest (if tests/ exists) 3. Reports summary of passed/failed skills ## Example output ``` Found 3 Python skill(s): - ./skills/my-python-skill - ./skills/another-skill Running ruff in ./skills/my-python-skill... ✓ No linting issues Running ruff in ./skills/another-skill... ❌ Linting issues found ❌ Linting completed with errors ``` Addresses feedback from microsoft#933
|
Thanks for the clarification @WilliamBerryiii! I've created a new PR that implements dynamic discovery of Python skills: PR: #935 ImplementationThe new approach:
Scripts AddedExample Outputpackage.json Updates{
"lint:py": "pwsh -NoProfile -File ./scripts/linting/Invoke-PythonLint.ps1",
"test:py": "pwsh -NoProfile -File ./scripts/linting/Invoke-PythonTests.ps1"
}This design will automatically discover and lint/test ALL Python skills as they're added, without needing to update the npm scripts. Closing this PR in favor of #935. |
|
Ref #957 as the replacement! Closing this one |
Implements dynamic discovery of Python skills by finding all
`pyproject.toml` files and running ruff/pytest on each.
## Motivation
As the project grows to support more Python skills, we need a way to
automatically discover and lint/test all of them without manually
updating npm scripts.
## Changes
### New Scripts
```
scripts/linting/
├── Invoke-PythonLint.ps1 # Discovers Python skills, runs ruff
└── Invoke-PythonTests.ps1 # Discovers Python skills, runs pytest
```
### How It Works
1. **Scans repository** for `pyproject.toml` files (excludes
`node_modules`)
2. **For each Python skill**:
- `lint:py` runs `ruff check`
- `test:py` runs `pytest` (if `tests/` directory exists)
3. **Reports summary** of passed/failed skills
### Example Output
```
Found 3 Python skill(s):
- ./skills/my-python-skill
- ./skills/another-skill
Running ruff in ./skills/my-python-skill...
✓ No linting issues
Running ruff in ./skills/another-skill...
❌ Linting issues found
❌ Linting completed with errors
```
### package.json
```json
{
"lint:py": "pwsh -NoProfile -File ./scripts/linting/Invoke-PythonLint.ps1",
"test:py": "pwsh -NoProfile -File ./scripts/linting/Invoke-PythonTests.ps1"
}
```
## Benefits
- **Automatic discovery**: New Python skills are automatically included
- **Cross-platform**: PowerShell scripts work on Windows/Linux/macOS
- **Clear output**: Shows which skills passed/failed
- **Fail-fast**: Returns non-zero exit code on any failure
## Testing
- Tested with multiple `pyproject.toml` files
- Handles missing ruff/pytest gracefully
- Excludes node_modules correctly
Addresses feedback from #933
Closes #933
---------
Co-authored-by: Bill Berry <WilliamBerryiii@users.noreply.github.com>
Co-authored-by: Bill Berry <wberry@microsoft.com>
Description
Add npm run scripts for Python linting and testing:
lint:py— ruff checklint:py:fix— ruff check --fixtest:py— pytestFollows existing npm script patterns.
Related Issue(s)
Fixes #886
Type of Change
Select all that apply:
Code & Documentation:
Infrastructure & Configuration:
AI Artifacts:
prompt-builderagent and addressed all feedback.github/instructions/*.instructions.md).github/prompts/*.prompt.md).github/agents/*.agent.md).github/skills/*/SKILL.md)Other:
.ps1,.sh,.py)Testing
Checklist
Required Checks
Required Automated Checks
The following validation commands must pass before merging:
npm run lint:mdnpm run spell-checknpm run lint:frontmatternpm run validate:skillsnpm run lint:md-linksnpm run lint:ps