Skip to content

Commit

Permalink
Merge pull request #56 from wemogy/36-create-test-cases-for-all-our-s…
Browse files Browse the repository at this point in the history
…ceanrios

Create test cases
  • Loading branch information
SebastianKuesters authored Apr 19, 2024
2 parents d0a515b + 04f9ea5 commit c250a08
Show file tree
Hide file tree
Showing 87 changed files with 9,221 additions and 693 deletions.
17 changes: 17 additions & 0 deletions .github/actions/setup-python/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Setup Python
description: Setup python
runs:
using: composite
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml
cache: 'poetry'

- name: Setup poetry
uses: Gr1N/setup-poetry@v9

- name: Install dependencies
run: poetry install --no-root --no-interaction --with dev
shell: bash
103 changes: 103 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Lint
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
app-pylint:
name: pylint (App)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: .github/actions/setup-python

- name: Add pylint annotator
uses: pr-annotators/[email protected]

- name: Run pylint
run: poetry run pylint src

app-flake8:
name: flake8 (App)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: .github/actions/setup-python

- name: Add flake8 annotator
uses: rbialon/[email protected]

- name: Run flake8
run: poetry run flake8 src

app-mypy:
name: mypy (App)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: .github/actions/setup-python

- name: Add mypy annotator
uses: pr-annotators/[email protected]

- name: Run mypy
run: poetry run mypy src

tests-pylint:
name: pylint (Tests)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: .github/actions/setup-python

- name: Add pylint annotator
uses: pr-annotators/pylint-pr-annotator@main

- name: Run pylint
run: poetry run pylint tests

tests-flake8:
name: flake8 (Tests)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: .github/actions/setup-python

- name: Add pylint annotator
uses: rbialon/[email protected]

- name: Run pylint
run: poetry run flake8 tests

tests-mypy:
name: mypy (Tests)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: .github/actions/setup-python

- name: Add mypy annotator
uses: pr-annotators/[email protected]

- name: Run mypy
run: poetry run mypy tests
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
run: |
echo "Version: ${{ steps.get-release-version.outputs.version }}"
echo "Version name: ${{ steps.get-release-version.outputs.version-name }}"
echo "Has changes: ${{ steps.get-release-version.outputs.has-changes }}"
echo "Has changes: ${{ steps.get-release-version.outputs.tag-created }}"
# Create GitHub Release
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
if: steps.get-release-version.outputs.has-changes == 'true'
if: steps.get-release-version.outputs.tag-created == 'true'
with:
tag_name: ${{ steps.get-release-version.outputs.version-name }}
name: Version ${{ steps.get-release-version.outputs.version }}
Expand Down
35 changes: 30 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Test Action
on:
workflow_dispatch:
pull_request:
branches:
- main
push:

jobs:
test:
test-action:
runs-on: ubuntu-latest
name: Test the action
steps:
Expand All @@ -13,16 +15,39 @@ jobs:
with:
fetch-depth: 0

- name: Run
- name: Run the action
id: get-release-version
uses: ./
with:
create-tag: "false"

- name: Show the next version
- name: Print the outputs
run: |
echo "version=${{ steps.get-release-version.outputs.version }}"
echo "version-name=${{ steps.get-release-version.outputs.version-name }}"
echo "previous-version=${{ steps.get-release-version.outputs.previous-version }}"
echo "previous-version-name=${{ steps.get-release-version.outputs.previous-version-name }}"
echo "has-changes=${{ steps.get-release-version.outputs.has-changes }}"
echo "tag-created=${{ steps.get-release-version.outputs.tag-created }}"
run-tests:
runs-on: ubuntu-latest
name: Run E2E Tests
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: .github/actions/setup-python

- name: Run pytest
run: poetry run pytest --junit-xml test-result.xml tests/e2e

- name: Upload test results
if: always()
uses: pmeier/[email protected]
with:
path: test-result.xml
summary: true
display-options: fEX
fail-on-empty: true
title: E2E Test Results
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,5 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

# Test script
.test.env
test/
# Testing
**/.working-directory/
8 changes: 8 additions & 0 deletions .mypy_stubs/semantic_release/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from semantic_release.commit_parser import CommitParser as CommitParser, ParseError as ParseError, ParseResult as ParseResult, ParseResultType as ParseResultType, ParsedCommit as ParsedCommit, ParserOptions as ParserOptions
from semantic_release.enums import LevelBump as LevelBump
from semantic_release.errors import CommitParseError as CommitParseError, InvalidConfiguration as InvalidConfiguration, InvalidVersion as InvalidVersion, SemanticReleaseBaseError as SemanticReleaseBaseError
from semantic_release.version import Version as Version, VersionTranslator as VersionTranslator, next_version as next_version, tags_and_versions as tags_and_versions

__version__: str

def setup_hook(argv: list[str]) -> None: ...
3 changes: 3 additions & 0 deletions .mypy_stubs/semantic_release/changelog/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from semantic_release.changelog.context import ChangelogContext as ChangelogContext, make_changelog_context as make_changelog_context
from semantic_release.changelog.release_history import ReleaseHistory as ReleaseHistory
from semantic_release.changelog.template import environment as environment, recursive_render as recursive_render
16 changes: 16 additions & 0 deletions .mypy_stubs/semantic_release/changelog/context.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from dataclasses import dataclass
from jinja2 import Environment as Environment
from semantic_release.changelog.release_history import ReleaseHistory as ReleaseHistory
from semantic_release.hvcs._base import HvcsBase as HvcsBase
from typing import Any, Callable

@dataclass
class ChangelogContext:
repo_name: str
repo_owner: str
history: ReleaseHistory
filters: tuple[Callable[..., Any], ...] = ...
def bind_to_environment(self, env: Environment) -> Environment: ...
def __init__(self, repo_name, repo_owner, history, filters) -> None: ...

def make_changelog_context(hvcs_client: HvcsBase, release_history: ReleaseHistory) -> ChangelogContext: ...
27 changes: 27 additions & 0 deletions .mypy_stubs/semantic_release/changelog/release_history.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from _typeshed import Incomplete
from datetime import datetime
from git.repo.base import Repo as Repo
from git.util import Actor
from re import Pattern
from semantic_release.commit_parser import CommitParser as CommitParser, ParseError as ParseError, ParseResult as ParseResult, ParserOptions as ParserOptions
from semantic_release.version.algorithm import tags_and_versions as tags_and_versions
from semantic_release.version.translator import VersionTranslator as VersionTranslator
from semantic_release.version.version import Version as Version
from typing import Iterable, Iterator, TypedDict

log: Incomplete

class ReleaseHistory:
@classmethod
def from_git_history(cls, repo: Repo, translator: VersionTranslator, commit_parser: CommitParser[ParseResult, ParserOptions], exclude_commit_patterns: Iterable[Pattern[str]] = ()) -> ReleaseHistory: ...
released: Incomplete
unreleased: Incomplete
def __init__(self, unreleased: dict[str, list[ParseResult]], released: dict[Version, Release]) -> None: ...
def __iter__(self) -> Iterator[dict[str, list[ParseResult]] | dict[Version, Release]]: ...
def release(self, version: Version, tagger: Actor, committer: Actor, tagged_date: datetime) -> ReleaseHistory: ...

class Release(TypedDict):
tagger: Actor
committer: Actor
tagged_date: datetime
elements: dict[str, list[ParseResult]]
12 changes: 12 additions & 0 deletions .mypy_stubs/semantic_release/changelog/template.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os
from _typeshed import Incomplete
from jinja2 import Environment as Environment
from jinja2.sandbox import SandboxedEnvironment
from pathlib import Path
from semantic_release.helpers import dynamic_import as dynamic_import
from typing import Iterable, Literal

log: Incomplete

def environment(template_dir: Path | str = '.', block_start_string: str = '{%', block_end_string: str = '%}', variable_start_string: str = '{{', variable_end_string: str = '}}', comment_start_string: str = '{#', comment_end_string: str = '#}', line_statement_prefix: str | None = None, line_comment_prefix: str | None = None, trim_blocks: bool = False, lstrip_blocks: bool = False, newline_sequence: Literal['\n', '\r', '\r\n'] = '\n', keep_trailing_newline: bool = False, extensions: Iterable[str] = (), autoescape: bool | str = True) -> SandboxedEnvironment: ...
def recursive_render(template_dir: Path, environment: Environment, _root_dir: str | os.PathLike[str] = '.') -> list[str]: ...
5 changes: 5 additions & 0 deletions .mypy_stubs/semantic_release/cli/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from semantic_release.cli.commands.changelog import changelog as changelog
from semantic_release.cli.commands.generate_config import generate_config as generate_config
from semantic_release.cli.commands.main import main as main
from semantic_release.cli.commands.publish import publish as publish
from semantic_release.cli.commands.version import version as version
Empty file.
11 changes: 11 additions & 0 deletions .mypy_stubs/semantic_release/cli/commands/changelog.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from _typeshed import Incomplete
from semantic_release.changelog import ReleaseHistory as ReleaseHistory, recursive_render as recursive_render
from semantic_release.changelog.context import make_changelog_context as make_changelog_context
from semantic_release.cli.commands.cli_context import CliContextObj as CliContextObj
from semantic_release.cli.common import get_release_notes_template as get_release_notes_template, render_default_changelog_file as render_default_changelog_file, render_release_notes as render_release_notes
from semantic_release.cli.util import noop_report as noop_report
from semantic_release.version import Version as Version

log: Incomplete

def changelog(cli_ctx: CliContextObj, release_tag: str | None = None) -> None: ...
17 changes: 17 additions & 0 deletions .mypy_stubs/semantic_release/cli/commands/cli_context.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import click
import logging
from _typeshed import Incomplete
from semantic_release.cli.config import GlobalCommandLineOptions as GlobalCommandLineOptions, RawConfig as RawConfig, RuntimeContext as RuntimeContext
from semantic_release.cli.util import load_raw_config_file as load_raw_config_file, rprint as rprint
from semantic_release.errors import InvalidConfiguration as InvalidConfiguration, NotAReleaseBranch as NotAReleaseBranch

class CliContext(click.Context):
obj: CliContextObj

class CliContextObj:
ctx: Incomplete
logger: Incomplete
global_opts: Incomplete
def __init__(self, ctx: click.Context, logger: logging.Logger, global_opts: GlobalCommandLineOptions) -> None: ...
@property
def runtime_ctx(self) -> RuntimeContext: ...
3 changes: 3 additions & 0 deletions .mypy_stubs/semantic_release/cli/commands/generate_config.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from semantic_release.cli.config import RawConfig as RawConfig

def generate_config(fmt: str = 'toml', is_pyproject_toml: bool = False) -> None: ...
9 changes: 9 additions & 0 deletions .mypy_stubs/semantic_release/cli/commands/main.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import click
from semantic_release.cli.commands.cli_context import CliContextObj as CliContextObj
from semantic_release.cli.config import GlobalCommandLineOptions as GlobalCommandLineOptions
from semantic_release.cli.const import DEFAULT_CONFIG_FILE as DEFAULT_CONFIG_FILE
from semantic_release.cli.util import rprint as rprint

FORMAT: str

def main(ctx: click.Context, config_file: str = ..., verbosity: int = 0, noop: bool = False, strict: bool = False) -> None: ...
8 changes: 8 additions & 0 deletions .mypy_stubs/semantic_release/cli/commands/publish.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from _typeshed import Incomplete
from semantic_release.cli.commands.cli_context import CliContextObj as CliContextObj
from semantic_release.cli.util import noop_report as noop_report
from semantic_release.version import tags_and_versions as tags_and_versions

log: Incomplete

def publish(cli_ctx: CliContextObj, tag: str = 'latest') -> None: ...
24 changes: 24 additions & 0 deletions .mypy_stubs/semantic_release/cli/commands/version.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import subprocess
from _typeshed import Incomplete
from git import Repo as Repo
from git.refs.tag import Tag as Tag
from semantic_release.changelog import ReleaseHistory as ReleaseHistory, environment as environment, recursive_render as recursive_render
from semantic_release.changelog.context import make_changelog_context as make_changelog_context
from semantic_release.cli.commands.cli_context import CliContextObj as CliContextObj
from semantic_release.cli.common import get_release_notes_template as get_release_notes_template, render_default_changelog_file as render_default_changelog_file, render_release_notes as render_release_notes
from semantic_release.cli.github_actions_output import VersionGitHubActionsOutput as VersionGitHubActionsOutput
from semantic_release.cli.util import indented as indented, noop_report as noop_report, rprint as rprint
from semantic_release.const import DEFAULT_SHELL as DEFAULT_SHELL, DEFAULT_VERSION as DEFAULT_VERSION
from semantic_release.enums import LevelBump as LevelBump
from semantic_release.version import Version as Version, VersionTranslator as VersionTranslator, next_version as next_version, tags_and_versions as tags_and_versions
from semantic_release.version.declaration import VersionDeclarationABC as VersionDeclarationABC
from typing import Iterable

log: Incomplete

def is_forced_prerelease(force_prerelease: bool, force_level: str | None, prerelease: bool) -> bool: ...
def last_released(repo: Repo, translator: VersionTranslator) -> tuple[Tag, Version] | None: ...
def version_from_forced_level(repo: Repo, level_bump: LevelBump, translator: VersionTranslator) -> Version: ...
def apply_version_to_source_files(repo: Repo, version_declarations: Iterable[VersionDeclarationABC], version: Version, noop: bool = False) -> list[str]: ...
def shell(cmd: str, *, check: bool = True) -> subprocess.CompletedProcess: ...
def version(cli_ctx: CliContextObj, print_only: bool = False, print_only_tag: bool = False, print_last_released: bool = False, print_last_released_tag: bool = False, force_prerelease: bool = False, prerelease_token: str | None = None, force_level: str | None = None, commit_changes: bool = True, create_tag: bool = True, update_changelog: bool = True, push_changes: bool = True, make_vcs_release: bool = True, build_metadata: str | None = None, skip_build: bool = False) -> str: ...
8 changes: 8 additions & 0 deletions .mypy_stubs/semantic_release/cli/common.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from jinja2 import Environment as Environment
from pathlib import Path
from semantic_release.changelog.release_history import Release as Release
from semantic_release.version import Version as Version

def get_release_notes_template(template_dir: Path) -> str: ...
def render_default_changelog_file(template_environment: Environment) -> str: ...
def render_release_notes(release_notes_template: str, template_environment: Environment, version: Version, release: Release) -> str: ...
Loading

0 comments on commit c250a08

Please sign in to comment.