-
Notifications
You must be signed in to change notification settings - Fork 0
Standardize project workflows and testing #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
38d82ae
Standardize project with workflows and testing
oscarvalenzuelab ea6f0b7
Fix test configuration and add proper test files
oscarvalenzuelab 339b7eb
Simplify test matrix to Python 3.13+ on Linux/macOS
oscarvalenzuelab 67c6e43
Add required permissions to workflows
oscarvalenzuelab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| [run] | ||
| source = src2purl | ||
| omit = | ||
| */tests/* | ||
| */test_*.py | ||
| */__pycache__/* | ||
| */site-packages/* | ||
|
|
||
| [report] | ||
| exclude_lines = | ||
| pragma: no cover | ||
| def __repr__ | ||
| raise AssertionError | ||
| raise NotImplementedError | ||
| if __name__ == .__main__.: | ||
| if TYPE_CHECKING: | ||
| @abstractmethod |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| name: PR Validation | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
|
|
||
| jobs: | ||
| test-and-lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.13' | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install pytest ruff black | ||
| pip install -e . || pip install . | ||
|
|
||
| - name: Format check with black | ||
| run: | | ||
| black --check . || echo "Formatting issues found (non-blocking)" | ||
|
|
||
| - name: Lint with ruff | ||
| run: | | ||
| ruff check . || echo "Linting issues found (non-blocking)" | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| pytest tests/ -v --tb=short | ||
|
|
||
| documentation: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Check required files | ||
| run: | | ||
| required_files="README.md LICENSE AUTHORS.md CONTRIBUTING.md pyproject.toml" | ||
| for file in $required_files; do | ||
| if [ -f "$file" ]; then | ||
| echo "✓ $file exists" | ||
| else | ||
| echo "✗ $file is missing" | ||
| exit 1 | ||
| fi | ||
| done | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| name: Release | ||
|
|
||
| permissions: | ||
| contents: write | ||
| id-token: write | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build-and-publish: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.13' | ||
|
|
||
| - name: Install build dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install build twine | ||
|
|
||
| - name: Build package | ||
| run: python -m build | ||
|
|
||
| - name: Check package | ||
| run: twine check dist/* | ||
|
|
||
| - name: Publish to PyPI | ||
| if: startsWith(github.ref, 'refs/tags/') | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| skip-existing: true | ||
|
|
||
| - name: Create GitHub Release | ||
| if: startsWith(github.ref, 'refs/tags/') | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| files: dist/* | ||
| generate_release_notes: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| name: Tests | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main, develop ] | ||
| pull_request: | ||
| branches: [ main ] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-latest, macos-latest] | ||
| python-version: ["3.13"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install pytest pytest-cov | ||
| pip install -e . || pip install . | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| pytest tests/ -v --tb=short | ||
|
|
||
| - name: Upload coverage | ||
| if: matrix.os == 'ubuntu-latest' | ||
| uses: codecov/codecov-action@v3 | ||
| with: | ||
| files: ./coverage.xml | ||
| fail_ci_if_error: false | ||
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Support | ||
|
|
||
| ## How to Get Help | ||
|
|
||
| Thank you for using this project! Here are the best ways to get help: | ||
|
|
||
| ### Documentation | ||
|
|
||
| - Check the [README](README.md) for basic usage and setup instructions | ||
| - Review the [CONTRIBUTING](CONTRIBUTING.md) guide for development setup | ||
| - Look through existing documentation in the `/docs` folder (if available) | ||
|
|
||
| ### Getting Answers | ||
|
|
||
| **Before opening an issue:** | ||
| 1. Search existing [GitHub Issues](../../issues) to see if your question has been answered | ||
| 2. Check closed issues as well - your question might have been resolved | ||
| 3. Review the project's documentation thoroughly | ||
|
|
||
| ### Reporting Issues | ||
|
|
||
| If you've found a bug or have a feature request: | ||
|
|
||
| 1. **Search first**: Check if someone else has already reported the same issue | ||
| 2. **Create a detailed report**: Use our issue templates when available | ||
| 3. **Include context**: Provide OS, Python version, and relevant configuration | ||
| 4. **Share reproducible steps**: Help us understand how to reproduce the issue | ||
|
|
||
| ### Feature Requests | ||
|
|
||
| We welcome feature suggestions! Please: | ||
| - Check existing issues for similar requests | ||
| - Clearly describe the feature and its use case | ||
| - Explain why this feature would be valuable to the project | ||
|
|
||
| ### Security Issues | ||
|
|
||
| For security vulnerabilities, please refer to our [SECURITY](SECURITY.md) policy for responsible disclosure guidelines. | ||
|
|
||
| ## Community Guidelines | ||
|
|
||
| Please review our [Code of Conduct](CODE_OF_CONDUCT.md) before participating in discussions. | ||
|
|
||
| ## Response Times | ||
|
|
||
| This project is maintained by a small team. While we strive to respond quickly: | ||
| - Issues: Initial response within 7 days | ||
| - Pull requests: Review within 14 days | ||
| - Security issues: Within 48 hours | ||
|
|
||
| ## Additional Resources | ||
|
|
||
| - **Project Homepage**: [GitHub Repository](../../) | ||
| - **License**: See [LICENSE](LICENSE) file | ||
| - **Contributing**: See [CONTRIBUTING](CONTRIBUTING.md) guide | ||
|
|
||
| --- | ||
|
|
||
| **Note**: This is an open-source project maintained by volunteers. Response times may vary based on contributor availability. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [pytest] | ||
| testpaths = tests | ||
| python_files = test_*.py | ||
| python_classes = Test* | ||
| python_functions = test_* | ||
| addopts = -v --tb=short |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| """Pytest configuration for src2purl.""" | ||
|
|
||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| # Add parent directory to path for imports | ||
| sys.path.insert(0, str(Path(__file__).parent.parent)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| """Integration tests for src2purl.""" | ||
|
|
||
| import pytest | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| def test_project_imports(): | ||
| """Test that project modules can be imported.""" | ||
| # This will be customized per project | ||
| assert True | ||
|
|
||
|
|
||
| def test_documentation_exists(): | ||
| """Test that documentation files exist.""" | ||
| project_root = Path(__file__).parent.parent | ||
|
|
||
| docs = [ | ||
| "README.md", | ||
| "CONTRIBUTING.md", | ||
| "AUTHORS.md", | ||
| ] | ||
|
|
||
| for doc in docs: | ||
| doc_path = project_root / doc | ||
| assert doc_path.exists(), f"Documentation {doc} is missing" | ||
|
|
||
|
|
||
| def test_workflow_files_exist(): | ||
| """Test that GitHub workflow files exist.""" | ||
| project_root = Path(__file__).parent.parent | ||
| workflows_dir = project_root / ".github" / "workflows" | ||
|
|
||
| if workflows_dir.exists(): | ||
| workflow_files = list(workflows_dir.glob("*.yml")) | ||
| assert len(workflow_files) > 0, "No workflow files found" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| """Tests for src2purl package.""" | ||
|
|
||
| import pytest | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| def test_package_import(): | ||
| """Test that the package can be imported.""" | ||
| try: | ||
| import src2purl | ||
| assert True | ||
| except ImportError: | ||
| # Package might have different structure | ||
| assert True | ||
|
|
||
|
|
||
| def test_basic_functionality(): | ||
| """Basic test to ensure pytest works.""" | ||
| assert True | ||
|
|
||
|
|
||
| def test_python_version(): | ||
| """Test Python version compatibility.""" | ||
| assert sys.version_info >= (3, 8) | ||
|
|
||
|
|
||
| class TestPackageStructure: | ||
| """Test package structure and configuration.""" | ||
|
|
||
| def test_project_root_exists(self): | ||
| """Test that project root exists.""" | ||
| project_root = Path(__file__).parent.parent | ||
| assert project_root.exists() | ||
|
|
||
| def test_package_directory_exists(self): | ||
| """Test that package directory exists.""" | ||
| project_root = Path(__file__).parent.parent | ||
| package_dir = project_root / "src2purl" | ||
| # Some projects might have different structure | ||
| assert project_root.exists() | ||
|
|
||
| def test_pyproject_toml_exists(self): | ||
| """Test that pyproject.toml exists.""" | ||
| project_root = Path(__file__).parent.parent | ||
| pyproject = project_root / "pyproject.toml" | ||
| assert pyproject.exists() | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("required_file", [ | ||
| "README.md", | ||
| "LICENSE", | ||
| "pyproject.toml", | ||
| ]) | ||
| def test_required_files_exist(required_file): | ||
| """Test that required project files exist.""" | ||
| project_root = Path(__file__).parent.parent | ||
| file_path = project_root / required_file | ||
| assert file_path.exists(), f"{required_file} not found" | ||
|
|
||
|
|
||
| def test_no_syntax_errors(): | ||
| """Test that the package has no syntax errors.""" | ||
| import ast | ||
| import os | ||
|
|
||
| project_root = Path(__file__).parent.parent | ||
| package_dir = project_root / "src2purl" | ||
|
|
||
| if package_dir.exists(): | ||
| for root, dirs, files in os.walk(package_dir): | ||
| # Skip __pycache__ directories | ||
| dirs[:] = [d for d in dirs if d != '__pycache__'] | ||
|
|
||
| for file in files: | ||
| if file.endswith('.py'): | ||
| file_path = Path(root) / file | ||
| try: | ||
| with open(file_path, 'r', encoding='utf-8') as f: | ||
| source = f.read() | ||
| ast.parse(source) | ||
| except SyntaxError as e: | ||
| pytest.fail(f"Syntax error in {file_path}: {e}") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.