-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev
- Loading branch information
Showing
5 changed files
with
314 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,68 @@ | ||
name: tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
schedule: | ||
- cron: '0 8 * * *' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.12", "3.11"] | ||
steps: | ||
- name: Checkout | ||
run: | | ||
echo $GITHUB_REF $GITHUB_SHA | ||
git clone https://github.com/$GITHUB_REPOSITORY.git . | ||
git fetch origin $GITHUB_SHA:temporary-ci-branch | ||
git checkout $GITHUB_SHA || (git fetch && git checkout $GITHUB_SHA) | ||
- name: 'Set up Python ${{ matrix.python-version }}' | ||
uses: actions/setup-python@v5 | ||
# https://github.com/marketplace/actions/setup-python | ||
with: | ||
python-version: '${{ matrix.python-version }}' | ||
cache: 'pip' # caching pip dependencies | ||
cache-dependency-path: '**/requirements.*.txt' | ||
|
||
- name: 'Bootstrap app venv' | ||
# The first CLI call will create the .venv | ||
run: | | ||
./cli.py version | ||
- name: 'app CLI help' | ||
run: | | ||
./cli.py --help | ||
- name: 'Bootstrap dev venv' | ||
# The first CLI call will create the .venv | ||
run: | | ||
./dev-cli.py version | ||
- name: 'dev CLI help' | ||
run: | | ||
./dev-cli.py --help | ||
- name: 'Run pip-audit' | ||
run: | | ||
./dev-cli.py pip-audit | ||
- name: 'Run tests with Python v${{ matrix.python-version }}' | ||
env: | ||
PYTHONUNBUFFERED: 1 | ||
PYTHONWARNINGS: always | ||
run: | | ||
./dev-cli.py coverage | ||
- name: 'Upload coverage report' | ||
uses: codecov/codecov-action@v4 | ||
# https://github.com/marketplace/actions/codecov | ||
with: | ||
fail_ci_if_error: false | ||
verbose: true |
This file contains 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
This file contains 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
This file contains 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,49 @@ | ||
from bx_py_utils.auto_doc import assert_readme_block | ||
from bx_py_utils.path import assert_is_file | ||
from manageprojects.test_utils.click_cli_utils import invoke_click | ||
from manageprojects.tests.base import BaseTestCase | ||
|
||
from dragonlib import constants | ||
from dragonlib.cli_app import cli | ||
from dragonlib.cli_dev import PACKAGE_ROOT | ||
from dragonlib.cli_dev import cli as dev_cli | ||
|
||
|
||
def assert_cli_help_in_readme(text_block: str, marker: str): | ||
README_PATH = PACKAGE_ROOT / 'README.md' | ||
assert_is_file(README_PATH) | ||
|
||
text_block = text_block.replace(constants.CLI_EPILOG, '') | ||
text_block = f'```\n{text_block.strip()}\n```' | ||
assert_readme_block( | ||
readme_path=README_PATH, | ||
text_block=text_block, | ||
start_marker_line=f'[comment]: <> (✂✂✂ auto generated {marker} start ✂✂✂)', | ||
end_marker_line=f'[comment]: <> (✂✂✂ auto generated {marker} end ✂✂✂)', | ||
) | ||
|
||
|
||
class ReadmeTestCase(BaseTestCase): | ||
def test_main_help(self): | ||
stdout = invoke_click(cli, '--help') | ||
self.assert_in_content( | ||
got=stdout, | ||
parts=( | ||
'Usage: ./cli.py [OPTIONS] COMMAND [ARGS]...', | ||
constants.CLI_EPILOG, | ||
), | ||
) | ||
assert_cli_help_in_readme(text_block=stdout, marker='main help') | ||
|
||
def test_dev_help(self): | ||
stdout = invoke_click(dev_cli, '--help') | ||
self.assert_in_content( | ||
got=stdout, | ||
parts=( | ||
'Usage: ./dev-cli.py [OPTIONS] COMMAND [ARGS]...', | ||
' check-code-style ', | ||
' coverage ', | ||
constants.CLI_EPILOG, | ||
), | ||
) | ||
assert_cli_help_in_readme(text_block=stdout, marker='dev help') |
This file contains 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,29 @@ | ||
import os | ||
from unittest import TestCase, skipIf | ||
|
||
from bx_py_utils.auto_doc import assert_readme_block | ||
from cli_base.cli_tools.git_history import get_git_history | ||
|
||
import dragonlib | ||
from dragonlib.cli_dev import PACKAGE_ROOT | ||
|
||
|
||
class ReadmeHistoryTestCase(TestCase): | ||
@skipIf( | ||
# After a release the history may be "changed" because of version bump | ||
# and we should not block merge requests because of this. | ||
'GITHUB_ACTION' in os.environ, | ||
reason='Skip on github actions', | ||
) | ||
def test_readme_history(self): | ||
git_history = get_git_history( | ||
current_version=dragonlib.__version__, | ||
add_author=False, | ||
) | ||
history = '\n'.join(git_history) | ||
assert_readme_block( | ||
readme_path=PACKAGE_ROOT / 'README.md', | ||
text_block=f'\n{history}\n', | ||
start_marker_line='[comment]: <> (✂✂✂ auto generated history start ✂✂✂)', | ||
end_marker_line='[comment]: <> (✂✂✂ auto generated history end ✂✂✂)', | ||
) |