Skip to content

Commit

Permalink
feat: add support for PASSED status in case 0 annotations are found
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinDeJong-TomTom committed Jun 11, 2021
1 parent 5c6a600 commit 0ad4ccf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,18 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
# Pull Request number
pull_request: ${{ github.event.number }}

- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov
pip install .
- name: Test with pytest
run: |
pytest --cov=. --cov-report=xml
6 changes: 2 additions & 4 deletions bitbucket_code_insight_reporter/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def retrieve_annotations_from_file(path, workspace):
_data = json.loads(diag_msg.to_json())
_filepath = (
_data["filepath"]
if not workspace
if not workspace or workspace not in _data["filepath"]
else _data["filepath"].replace(workspace, "").lstrip(os.path.sep)
)
_annotations.append(
Expand Down Expand Up @@ -132,9 +132,7 @@ def generate(
_report["annotations"] = _annotations

_failure = len(_annotations) > 0

if _failure:
_report["report"]["result"] = "FAIL"
_report["report"]["result"] = "FAIL" if _failure else "PASS"

LOGGER.debug(f"Generating Report: {json.dumps(_report, indent=4, sort_keys=True)}")

Expand Down

0 comments on commit 0ad4ccf

Please sign in to comment.