Skip to content

Commit

Permalink
Universum 0.19.15
Browse files Browse the repository at this point in the history
  • Loading branch information
k-dovgan committed May 10, 2023
2 parents 184a711 + 9f0894a commit bc1740a
Show file tree
Hide file tree
Showing 49 changed files with 1,117 additions and 531 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/precommit-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Universum check
on: push

jobs:
universum_check:
name: Universum check
runs-on: ubuntu-latest

steps:
- name: Setup python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install dependency
run: pip install universum[test]

- name: Universum
run:
python -u -m universum
--fail-unsuccessful
--vcs-type=git
--git-repo $GITHUB_SERVER_URL/$GITHUB_REPOSITORY
--git-refspec $GITHUB_REF_NAME
--no-archive
--no-diff

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
if: always()
with:
files: artifacts/*.xml

- name: Collect artifacts
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: artifacts
path: artifacts
75 changes: 75 additions & 0 deletions .github/workflows/telegram-bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Telegram bot
on:
pull_request:
types: [opened, synchronize, closed]
issue_comment:
types: [created]
workflow_run:
workflows: [Universum check]
types: [completed]
pull_request_review:
types: [submitted, edited, dismissed]

jobs:
make-comment:
name: Send comment to TG
runs-on: ubuntu-latest
env:
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
PR_NAME: ${{ github.event.pull_request.title }}
PR_BASE: ${{ github.event.pull_request.base.ref }}
PR_URL: ${{ github.event.pull_request.html_url }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_MERGED: ${{ github.event.pull_request.merged_by.login }}
REVIEW_STATE: ${{ github.event.review.state }}
REVIEW_AUTHOR: ${{ github.event.review.user.login }}
REVIEW_COMMENT: ${{ github.event.review.body }}
COMMENT_AUTHOR: ${{ github.event.comment.user.login }}
COMMENT_URL: ${{ github.event.comment.html_url }}
COMMENT_BODY: ${{ github.event.comment.body }}
COMMENT_NUMBER: ${{ github.event.issue.number }}
UNIVERUM_COMMIT: ${{ github.event.workflow_run.head_sha }}
UNIVERSUM_BRANCH: ${{ github.event.workflow_run.head_branch }}
UNIVERSUM_LOG: ${{ github.event.workflow_run.html_url }}

steps:
- name: Send message to TG
run: |
if [[ ! -z "${{ github.event.pull_request }}" && "${{ github.event.action }}" == "opened" ]]; then
ESCAPED_NAME=`echo -e "${{ env.PR_NAME }}" | sed 's/\&/\&amp;/g' | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g'`
TEXT=`echo -e "<b>${{ env.PR_AUTHOR }}</b> created new <a href=\"${{ env.PR_URL }}\">PR#${{ env.PR_NUMBER }}</a> '$ESCAPED_NAME' to branch '${{ env.PR_BASE }}'"`
elif [[ ! -z "${{ github.event.pull_request }}" && "${{ github.event.action }}" == "synchronize" ]]; then
TEXT=`echo -e "<b>${{ env.PR_AUTHOR }}</b> updated <a href=\"${{ env.PR_URL }}\">PR#${{ env.PR_NUMBER }}</a>"`
elif [[ ! -z "${{ github.event.pull_request }}" && "${{ github.event.action }}" == "closed" && "${{ github.event.pull_request.merged }}" == "true" ]]; then
TEXT=`echo -e "<b>${{ env.PR_MERGED }}</b> merged <a href=\"${{ env.PR_URL }}\">PR#${{ env.PR_NUMBER }}</a> to branch <b>'${{ env.PR_BASE }}'</b>"`
elif [[ ! -z "${{ github.event.pull_request }}" && "${{ github.event.action }}" == "closed" ]]; then
TEXT=`echo -e "<b>${{ env.PR_AUTHOR }}</b> closed <a href=\"${{ env.PR_URL }}\">PR#${{ env.PR_NUMBER }}</a>"`
elif [[ ! -z "${{ github.event.comment }}" ]]; then
ESCAPED_TEXT=`echo -e "${{ env.COMMENT_BODY }}"| sed 's/\&/\&amp;/g' | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g'`
TEXT=`echo -e "<b>${{ env.COMMENT_AUTHOR }}</b> posted the following comment to issue <a href=\"${{ env.COMMENT_URL }}\">#${{ env.COMMENT_NUMBER }}</a>:\n<i>$ESCAPED_TEXT</i>"`
elif [[ ! -z "${{ github.event.review }}" && "${{ env.REVIEW_STATE }}" == "changes_requested" ]]; then
TEXT=`echo -e "<b>${{ env.REVIEW_AUTHOR }}</b> requested changes for <a href=\"${{ env.PR_URL }}\">PR#${{ env.PR_NUMBER }}</a>"`
elif [[ ! -z "${{ github.event.review }}" && "${{ env.REVIEW_STATE }}" == "commented" ]]; then
ESCAPED_TEXT=`echo -e "${{ env.REVIEW_COMMENT }}"| sed 's/\&/\&amp;/g' | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g'`
TEXT=`echo -e "<b>${{ env.REVIEW_AUTHOR }}</b> posted the following comment to <a href=\"${{ env.PR_URL }}\">PR#${{ env.PR_NUMBER }}</a>:\n<i>$ESCAPED_TEXT</i>"`
elif [[ ! -z "${{ github.event.review }}" ]]; then
TEXT=`echo -e "<b>${{ env.REVIEW_AUTHOR }}</b> ${{ env.REVIEW_STATE }} <a href=\"${{ env.PR_URL }}\">PR#${{ env.PR_NUMBER }}</a>"`
elif [[ -z "${{ github.event.review }}" && "${{ github.event.action }}" == "submitted" ]]; then
TEXT=`echo -e "Due to GitHub Actions bug we cannot identify, who approved <a href=\"${{ env.PR_URL }}\">PR#${{ env.PR_NUMBER }}</a>"`
elif [[ ! -z "${{ github.event.workflow_run }}" && "${{ github.event.workflow_run.conclusion }}" == "success" ]]; then
TEXT=`echo -e "<a href=\"${{ env.UNIVERSUM_LOG }}\">Universum run for branch '${{ env.UNIVERSUM_BRANCH }}'</a> <b>SUCCEDED</b>; commit ${{ env.UNIVERUM_COMMIT }} "`
elif [[ ! -z "${{ github.event.workflow_run }}" && "${{ github.event.workflow_run.conclusion }}" == "failure" ]]; then
TEXT=`echo -e "<a href=\"${{ env.UNIVERSUM_LOG }}\">Universum run for branch '${{ env.UNIVERSUM_BRANCH }}'</a> <b>FAILED</b>; commit ${{ env.UNIVERUM_COMMIT }} "`
fi
if [[ ! -z $TEXT ]]; then
curl --get --data-urlencode "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" --data-urlencode "disable_web_page_preview=True" \
--data-urlencode "text=$TEXT" --data-urlencode "parse_mode=HTML" $URL
fi
env:
URL: https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage
3 changes: 2 additions & 1 deletion .universum.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ def pip_install(module_name):
configs = Variations([Step(name="Create virtual environment", command=[python, "-m", "venv", env_name]),
Step(name="Update Docker images", command=run_virtual("make images")),

Step(name="Install Universum for tests", artifacts="junit_results.xml",
Step(name="Install Universum for tests",
command=run_virtual(pip_install(".[test]"))),
Step(name="Make", artifacts="doc/_build",
command=run_virtual("make")),
Step(name="Make tests", artifacts="htmlcov",
command=run_virtual("export LANG=en_US.UTF-8; make test")),
Step(name="Collect test results", artifacts="junit_results.xml"),

Step(name="Run static pylint", code_report=True,
command=run_virtual(f"{python} -m universum.analyzers.pylint "
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
Change log
==========

0.19.15 (2023-05-10)
--------------------

New features
~~~~~~~~~~~~

* **analyzer:** code report based on clang-format

Bug fixes
~~~~~~~~~

* **config:** fixed returning "None" instead of "False" for Step custom keys set to "False"
* **artifact:** remove redundant Static_analysis_report.json from artifacts
* **analyzer:** incorrect program name in help
* **report:** set exit code even if reporting crashes


0.19.14 (2022-11-14)
--------------------

Expand Down
42 changes: 37 additions & 5 deletions doc/code_report.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The following analysing modules (analysers) are currently added to Universum:
* `pylint`_
* `mypy`_
* `uncrustify`_
* `clang-format`_

Analysers are separate scripts, fully compatible with Universum. It is possible to use them
as independent Python modules.
Expand Down Expand Up @@ -62,7 +63,6 @@ Pylint

.. argparse::
:ref: universum.analyzers.pylint.pylint_argument_parser
:prog: {python} -m universum.analyzers.pylint

Config example for ``universum.analyzers.pylint``:

Expand Down Expand Up @@ -99,7 +99,6 @@ Mypy

.. argparse::
:ref: universum.analyzers.mypy.mypy_argument_parser
:prog: {python} -m universum.analyzers.mypy

Config example for ``universum.analyzers.mypy``:

Expand Down Expand Up @@ -136,7 +135,6 @@ Uncrustify

.. argparse::
:ref: universum.analyzers.uncrustify.uncrustify_argument_parser
:prog: {python} -m universum.analyzers.uncrustify
:nodefault:

Config example for ``universum.analyzers.uncrustify``:
Expand All @@ -146,7 +144,7 @@ Config example for ``universum.analyzers.uncrustify``:
from universum.configuration_support import Configuration, Step

configs = Configuration([Step(name="uncrustify", code_report=True, command=[
"{python}", "-m", "universum.analyzers.uncrustify", "--files", "/home/user/workspace/temp",
"{python}", "-m", "universum.analyzers.uncrustify", "--files", "/home/user/workspace/temp/*.c",
"--cfg-file", "file_name.cfg", "--result-file", "${CODE_REPORT_FILE}", "--output-directory", "uncrustify"
])])
Expand All @@ -164,4 +162,38 @@ will produce this list of configurations:
.. testoutput::

$ ./.universum.py
[{'name': 'uncrustify', 'code_report': True, 'command': '{python} -m universum.analyzers.uncrustify --files /home/user/workspace/temp --cfg-file file_name.cfg --result-file ${CODE_REPORT_FILE} --output-directory uncrustify'}]
[{'name': 'uncrustify', 'code_report': True, 'command': '{python} -m universum.analyzers.uncrustify --files /home/user/workspace/temp/*.c --cfg-file file_name.cfg --result-file ${CODE_REPORT_FILE} --output-directory uncrustify'}]
Clang-format
------------

.. argparse::
:ref: universum.analyzers.clang-format.clang_format_argument_parser
:nodefault:

Config example for ``universum.analyzers.clang-format``:

.. testcode::

from universum.configuration_support import Configuration, Step

configs = Configuration([Step(name="clang-format", code_report=True, command=[
"{python}", "-m", "universum.analyzers.clang-format", "--files", "/home/user/workspace/temp/*.c",
"--result-file", "${CODE_REPORT_FILE}", "--output-directory", "clang-format", "-e", "clang-format-15",
])])
if __name__ == '__main__':
print(configs.dump())

will produce this list of configurations:

.. testcode::
:hide:

print("$ ./.universum.py")
print(configs.dump())

.. testoutput::

$ ./.universum.py
[{'name': 'clang-format', 'code_report': True, 'command': '{python} -m universum.analyzers.clang-format --files /home/user/workspace/temp/*.c --result-file ${CODE_REPORT_FILE} --output-directory clang-format -e clang-format-15'}]
8 changes: 6 additions & 2 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ disable = missing-docstring,
no-member,
unsupported-assignment-operation,
super-init-not-called,
wildcard-import
wildcard-import,
use-dict-literal

[BASIC]
no-docstring-rgx = .*
Expand All @@ -36,4 +37,7 @@ max-parents = 10
max-line-length = 130

[SIMILARITIES]
ignore-imports=yes
ignore-imports=yes

[TYPECHECK]
signature-mutators=universum.analyzers.utils.analyzer
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def readme():
'sh',
'lxml',
'typing-extensions',
'ansi2html'
'ansi2html',
'pyyaml==6.0'
],
extras_require={
'p4': [p4],
Expand All @@ -56,7 +57,8 @@ def readme():
'coverage',
'mypy',
'types-requests',
'selenium==3.141'
'selenium==3.141',
'types-PyYAML==6.0'
]
},
package_data={'': ['*.css', '*.js']}
Expand Down
23 changes: 13 additions & 10 deletions tests/deployment_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import getpass
import os
import shutil
import pathlib
from pwd import getpwnam

import docker
import py
import pytest
from requests.exceptions import ReadTimeout

Expand Down Expand Up @@ -41,7 +42,8 @@ def add_bind_dirs(self, directories):
if self._container:
self.request.raiseerror("Container is already running, no dirs can be bound!")
for directory in directories:
self._volumes[directory] = {'bind': directory, 'mode': 'rw'}
absolute_dir = str(pathlib.Path(directory).absolute())
self._volumes[absolute_dir] = {'bind': absolute_dir, 'mode': 'rw'}

def add_environment_variables(self, variables):
if self._container:
Expand Down Expand Up @@ -154,26 +156,27 @@ def clean_execution_environment(request):


class LocalSources(utils.BaseVcsClient):
def __init__(self, root_directory: py.path.local, repo_file: py.path.local):
def __init__(self, root_directory: pathlib.Path, repo_file: pathlib.Path):
super().__init__()
self.root_directory = root_directory
self.repo_file = repo_file


@pytest.fixture()
def local_sources(tmpdir: py.path.local):
def local_sources(tmp_path: pathlib.Path):
if utils.reuse_docker_containers():
source_dir = py.path.local(".work")
source_dir = pathlib.Path(".work")
try:
source_dir.remove(rec=1, ignore_errors=True)
shutil.rmtree(source_dir, ignore_errors=True)
except OSError:
pass
source_dir.ensure(dir=True)
source_dir.mkdir()

else:
source_dir = tmpdir.mkdir("project_sources")
local_file = source_dir.join("readme.txt")
local_file.write("This is a an empty file")
source_dir = tmp_path / "project_sources"
source_dir.mkdir()
local_file = source_dir / "readme.txt"
local_file.write_text("This is a an empty file", encoding="utf-8")

yield LocalSources(root_directory=source_dir, repo_file=local_file)

Expand Down
Loading

0 comments on commit bc1740a

Please sign in to comment.