From 6d3616a2a0dc5872951ea13b1a17cc3de45fa4f0 Mon Sep 17 00:00:00 2001 From: Thor Whalen Date: Sat, 4 Nov 2023 03:33:52 -0400 Subject: [PATCH 1/6] Update ci.yml --- .github/workflows/ci.yml | 86 ++++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e3cec7..de9d8a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ name: Continuous Integration on: [push, pull_request] env: - PROJECT_NAME: ${{ vars.PROJECT_NAME }} + PROJECT_NAME: titbit jobs: validation: @@ -11,21 +11,38 @@ jobs: strategy: matrix: python-version: [3.8] + steps: - uses: actions/checkout@v3 - - uses: isee/actions/validation@master + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 with: - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} python-version: ${{ matrix.python-version }} - python_packages: ${{ vars.PYTHON_PKGS }} - apt_packages: ${{ vars.APT_GET_PKGS }} - npm_packages: ${{ vars.NPM_PKGS }} - requirements_file: ${{ vars.REQUIREMENTS_FILE_PATH }} - test_requirements_file: ${{ vars.TEST_REQUIREMENTS_FILE_PATH }} + + - name: Install Dependencies + uses: i2mint/isee/actions/install-packages@master + with: + dependency-files: setup.cfg + # ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} # Uncomment this if you need to install private dependencies from source + + - name: Format Source Code + uses: i2mint/isee/actions/format-source-code@master + + - name: Pylint Validation + uses: i2mint/isee/actions/pylint-validation@master + with: + root-dir: ${{ env.PROJECT_NAME }} + enable: C0114,E0401 + + - name: Pytest Validation + uses: i2mint/isee/actions/pytest-validation@master + with: + root-dir: ${{ env.PROJECT_NAME }} publish: name: Publish - if: "!contains(github.event.head_commit.message, '[skip ci]') && ( github.ref == 'refs/heads/master')" + if: "!contains(github.event.head_commit.message, '[skip ci]') && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')" needs: validation runs-on: ubuntu-latest strategy: @@ -33,12 +50,49 @@ jobs: python-version: [3.8] steps: - uses: actions/checkout@v3 - - uses: isee/actions/publish@master + with: + fetch-depth: 0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - python_packages: ${{ vars.PYTHON_PKGS }} - PROJECT_NAME: ${{ vars.PROJECT_NAME }} - PYPI_USERNAME: ${{ vars.PYPI_USERNAME }} - PYPI_PASSWORD: ${{ vars.PYPI_PASSWORD }} - GIT_USER_EMAIL: ${{ vars.GIT_USER_EMAIL }} - GIT_USER_NAME: ${{ vars.GIT_USER_NAME }} + + - name: Format Source Code + uses: i2mint/isee/actions/format-source-code@master + + - name: Update Version Number + uses: i2mint/isee/actions/bump-version-number@master + + - name: Package + uses: i2mint/isee/actions/package@master + # Uncomment this if you need to install private dependencies from source + # with: + # ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Publish + uses: i2mint/isee/actions/publish@master + with: + pypi-username: ${{ secrets.PYPI_USERNAME }} + pypi-password: ${{ secrets.PYPI_PASSWORD }} + + - name: Check In + uses: i2mint/isee/actions/check-in@master + with: + commit-message: "**CI** Formatted code + Updated version number and documentation. [skip ci]" + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Tag Repository With New Version Number + uses: i2mint/isee/actions/tag-repository@master + with: + tag: $VERSION + + github-pages: + name: Publish GitHub Pages + if: "!contains(github.event.head_commit.message, '[skip ci]') && github.ref == 'refs/heads/master'" + needs: publish + runs-on: ubuntu-latest + steps: + - uses: i2mint/epythet/actions/publish-github-pages@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} From 48e7605d3c0277c99aa8c9c4fcce4cad169c5265 Mon Sep 17 00:00:00 2001 From: Thor Whalen Date: Sat, 4 Nov 2023 03:35:37 -0400 Subject: [PATCH 2/6] Update setup.cfg --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 0e190ec..60d6dd8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -17,5 +17,6 @@ packages = find: include_package_data = True zip_safe = False install_requires = + lkj From bfd6bf3525bff55072da242e60c5eaae08c641ae Mon Sep 17 00:00:00 2001 From: Thor Whalen Date: Sat, 4 Nov 2023 03:42:05 -0400 Subject: [PATCH 3/6] Update __init__.py --- titbit/__init__.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/titbit/__init__.py b/titbit/__init__.py index 230ba50..990276e 100644 --- a/titbit/__init__.py +++ b/titbit/__init__.py @@ -9,7 +9,23 @@ def mermaid_to_graphviz( mermaid_code, extra_replacements=(), *, prefix="", suffix="", egress=None ): - """Converts mermaid code to graphviz code.""" + """Converts mermaid code to graphviz code. + + >>> mermaid_code = ''' + ... graph TD + ... A --> B & C + ... B & C --> D + ... ''' + >>> graphviz_code = mermaid_to_graphviz(mermaid_code) + >>> print(graphviz_code) + digraph G { + + graph TD + A -> B , C + B , C -> D + + } + """ from lkj import regex_based_substitution, import_object From c344f5326c87de3246c123d7de60efa27450eba9 Mon Sep 17 00:00:00 2001 From: Thor Whalen Date: Sat, 4 Nov 2023 03:43:47 -0400 Subject: [PATCH 4/6] Update __init__.py --- titbit/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/titbit/__init__.py b/titbit/__init__.py index 990276e..ba4423e 100644 --- a/titbit/__init__.py +++ b/titbit/__init__.py @@ -23,7 +23,7 @@ def mermaid_to_graphviz( graph TD A -> B , C B , C -> D - + } """ From f479a26d342353069fa9dd346ae61191caf7d5a7 Mon Sep 17 00:00:00 2001 From: Thor Whalen Date: Sat, 4 Nov 2023 03:46:11 -0400 Subject: [PATCH 5/6] Update __init__.py --- titbit/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/titbit/__init__.py b/titbit/__init__.py index ba4423e..7c0b27e 100644 --- a/titbit/__init__.py +++ b/titbit/__init__.py @@ -17,7 +17,7 @@ def mermaid_to_graphviz( ... B & C --> D ... ''' >>> graphviz_code = mermaid_to_graphviz(mermaid_code) - >>> print(graphviz_code) + >>> print(graphviz_code) # doctest: +NORMALIZE_WHITESPACE digraph G { graph TD From a11d59141acc03c34c5a8b72a1ad24a8c190471e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 4 Nov 2023 07:47:36 +0000 Subject: [PATCH 6/6] **CI** Formatted code + Updated version number and documentation. [skip ci] --- setup.cfg | 2 +- titbit/__init__.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/setup.cfg b/setup.cfg index 60d6dd8..8f7ce5b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,7 @@ root_url = https://github.com/i2mint/ license = apache-2.0 author = OtoSense -version = 0.0.1 +version = 0.1.0 description = A place to dump might-be-useful-again code as an alternative of leaving in a notebook where it will never be found again description_file = README.md long_description = file:README.md diff --git a/titbit/__init__.py b/titbit/__init__.py index 7c0b27e..7a88e1d 100644 --- a/titbit/__init__.py +++ b/titbit/__init__.py @@ -7,7 +7,7 @@ def mermaid_to_graphviz( - mermaid_code, extra_replacements=(), *, prefix="", suffix="", egress=None + mermaid_code, extra_replacements=(), *, prefix='', suffix='', egress=None ): """Converts mermaid code to graphviz code. @@ -34,20 +34,20 @@ def mermaid_to_graphviz( elif isinstance(egress, str): egress = import_object(egress) else: - assert callable(egress), f"egress must be a callable or a string, not {egress}" + assert callable(egress), f'egress must be a callable or a string, not {egress}' mermaid_to_graphviz_replacements = ( - ("-->", "->"), - ("&", ","), + ('-->', '->'), + ('&', ','), ) mermaid_to_graphviz_replacements = mermaid_to_graphviz_replacements + tuple( extra_replacements ) s = mermaid_code # remove the first line if it starts with 'graph' - s = "\n".join(s.split("\n")[1:]) if s.startswith("graph") else s + s = '\n'.join(s.split('\n')[1:]) if s.startswith('graph') else s # carry out the replacements s = regex_based_substitution(mermaid_to_graphviz_replacements)(s) # add the prefix and suffix and wrap it in the graphviz graph declaration - s = "digraph G {" + "\n" + f"{prefix}" + s + "\n" + suffix - return s + "}" + s = 'digraph G {' + '\n' + f'{prefix}' + s + '\n' + suffix + return s + '}'