-
Notifications
You must be signed in to change notification settings - Fork 0
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
chore: align with CI workflows of other interface packages #1
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: PR | ||
on: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- reopened | ||
- edited | ||
- synchronize | ||
|
||
jobs: | ||
title-format: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: amannn/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
name: release-please | ||
|
||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
release_created: ${{ steps.release.outputs.release_created }} | ||
steps: | ||
- uses: GoogleCloudPlatform/release-please-action@v3 | ||
id: release | ||
with: | ||
release-type: simple | ||
|
||
setup_and_build: | ||
runs-on: ubuntu-latest | ||
needs: release-please | ||
if: ${{ needs.release-please.outputs.release_created }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install uv | ||
uses: astral-sh/setup-uv@v3 | ||
|
||
- name: "Set up Python" | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version-file: "pyproject.toml" | ||
|
||
- name: Install the project | ||
run: uv sync --all-extras --dev | ||
|
||
- name: Build source and wheel distribution | ||
run: | | ||
uv build | ||
|
||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: dist | ||
path: dist/ | ||
pypi_publish: | ||
name: Upload release to PyPI | ||
needs: [release-please, setup_and_build] | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: release | ||
permissions: | ||
id-token: write | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: dist | ||
path: dist/ | ||
|
||
- name: Publish distribution to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,54 @@ | ||||||
name: CI | ||||||
|
||||||
on: | ||||||
push: | ||||||
branches: | ||||||
- main | ||||||
pull_request: | ||||||
branches-ignore: [] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove empty branches-ignore section. The empty pull_request:
- branches-ignore: [] 📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.4)8-8: "branches-ignore" section should not be empty (syntax-check) |
||||||
|
||||||
jobs: | ||||||
formatting: | ||||||
runs-on: ubuntu-latest | ||||||
steps: | ||||||
- uses: actions/checkout@v4 | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove trailing spaces. There are trailing spaces on lines 15, 29, and 43. - - uses: actions/checkout@v4
-
+ - uses: actions/checkout@v4 Also applies to: 29-29, 43-43 🧰 Tools🪛 YAMLlint (1.35.1)[error] 15-15: trailing spaces (trailing-spaces) |
||||||
- name: Install uv and install project | ||||||
uses: astral-sh/setup-uv@v5 | ||||||
|
||||||
- name: Install the project | ||||||
run: uv sync --all-extras --dev | ||||||
|
||||||
- name: Check formatting | ||||||
run: uv run ruff format --check | ||||||
|
||||||
linting: | ||||||
runs-on: ubuntu-latest | ||||||
steps: | ||||||
- uses: actions/checkout@v4 | ||||||
|
||||||
- name: Install uv and install project | ||||||
uses: astral-sh/setup-uv@v5 | ||||||
|
||||||
- name: Install the project | ||||||
run: uv sync --all-extras --dev | ||||||
|
||||||
- name: Check code | ||||||
run: uv run ruff check | ||||||
|
||||||
testing: | ||||||
runs-on: ubuntu-latest | ||||||
steps: | ||||||
- uses: actions/checkout@v4 | ||||||
|
||||||
- name: Install uv and install project | ||||||
uses: astral-sh/setup-uv@v5 | ||||||
|
||||||
- name: Install the project | ||||||
run: uv sync --all-extras --dev | ||||||
|
||||||
- name: Run pytest | ||||||
run: uv run coverage run -m pytest tests/tests.py | ||||||
|
||||||
- name: Run Coverage | ||||||
run: uv run coverage report -m |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import pytest | ||
from unittest.mock import MagicMock | ||
from logging import Handler | ||
from typing import Optional | ||
from dataclasses import dataclass, field | ||
from snakemake_interface_logger_plugins.settings import LoggerPluginSettingsBase | ||
from snakemake_interface_logger_plugins.registry import ( | ||
LoggerPluginRegistry, | ||
LogHandlerBase, | ||
) | ||
from snakemake_interface_common.plugin_registry.tests import TestRegistryBase | ||
from snakemake_interface_common.plugin_registry import PluginRegistryBase | ||
from snakemake_interface_logger_plugins.registry.plugin import Plugin | ||
|
||
|
||
@dataclass | ||
class MockSettings(LoggerPluginSettingsBase): | ||
"""Mock settings for the logger plugin.""" | ||
|
||
log_level: Optional[str] = field( | ||
default=None, | ||
metadata={ | ||
"help": "set the log level", | ||
"env_var": False, | ||
"required": False, | ||
}, | ||
) | ||
|
||
|
||
class MockPlugin(LogHandlerBase): | ||
settings_cls = MockSettings # Use our mock settings class | ||
|
||
def __init__(self, settings: Optional[LoggerPluginSettingsBase] = None): | ||
if settings is None: | ||
settings = MockSettings() # Provide default mock settings | ||
super().__init__(settings) | ||
|
||
def create_handler( | ||
self, | ||
quiet, | ||
printshellcmds: bool, | ||
printreason: bool, | ||
debug_dag: bool, | ||
nocolor: bool, | ||
stdout: bool, | ||
debug: bool, | ||
mode, | ||
show_failed_logs: bool, | ||
dryrun: bool, | ||
) -> Handler: | ||
"""Mock logging handler.""" | ||
return MagicMock(spec=Handler) | ||
|
||
|
||
class TestRegistry(TestRegistryBase): | ||
__test__ = True | ||
|
||
@pytest.fixture(autouse=True) | ||
def reset_registry(self, monkeypatch): | ||
"""Ensure the registry is completely reset for each test.""" | ||
if LoggerPluginRegistry._instance: | ||
LoggerPluginRegistry._instance.plugins = {} | ||
LoggerPluginRegistry._instance = None | ||
|
||
registry = LoggerPluginRegistry() | ||
registry.plugins = { | ||
"rich": Plugin( | ||
log_handler=MockPlugin, | ||
_logger_settings_cls=MockSettings, | ||
_name="rich", | ||
) | ||
} # Inject the mock plugin | ||
|
||
monkeypatch.setattr(self, "get_registry", lambda: registry) | ||
|
||
def get_registry(self) -> PluginRegistryBase: | ||
return LoggerPluginRegistry() | ||
|
||
def get_test_plugin_name(self) -> str: | ||
return "rich" | ||
|
||
def validate_plugin(self, plugin: LogHandlerBase): | ||
assert plugin.settings_cls is MockSettings # Ensure settings class is correct | ||
|
||
def validate_settings( | ||
self, settings: LoggerPluginSettingsBase, plugin: LogHandlerBase | ||
): | ||
assert isinstance(settings, MockSettings) | ||
assert settings.log_level == "info" | ||
|
||
def get_example_args(self): | ||
return ["--logger-rich-log-level", "info"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Update release-type for Python package.
The
release-type
should be set to "python" instead of "simple" for Python packages to ensure proper version management and changelog generation.📝 Committable suggestion