Skip to content

Commit a9af3ad

Browse files
[HOTFIX] Fixed GHI #455
Changes in file .github/workflows/CI-BUILD.yml: * add pr number details to build info Changes in file .github/workflows/CI-MATs.yml: * add pr number details to build info Changes in file .github/workflows/Tests.yml: * add pr number details to codecov coverage upload Changes in file multicast/__init__.py: * possible fix for PYL-R0401 Changes in file multicast/hear.py: * minor style refactor
1 parent ce6ada7 commit a9af3ad

File tree

5 files changed

+26
-15
lines changed

5 files changed

+26
-15
lines changed

.github/workflows/CI-BUILD.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,11 @@ jobs:
320320
printf "%s\n" "build-artifact-attestation-url=${{ needs.BUILD_ATTEST.outputs.build-artifact-attestation-url }}" >> "$GITHUB_OUTPUT"
321321
printf "%s\n" "build-artifact-attestation-id=${{ needs.BUILD_ATTEST.outputs.build-artifact-attestation-id }}" >> "$GITHUB_OUTPUT"
322322
fi
323+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
324+
printf "%s\n" "build_pr_number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
325+
else
326+
printf "%s\n" "build_pr_number=null" >> $GITHUB_OUTPUT
327+
fi
323328
printf "%s\n" "build_environment=${ENVIRONMENT}" >> "$GITHUB_OUTPUT"
324329
printf "%s\n" "build_id=${{ github.run_id }}" >> "$GITHUB_OUTPUT"
325330
cat <"$GITHUB_OUTPUT" >> "BUILD-info.txt"

.github/workflows/CI-MATs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
build_artifact_url: ${{ steps.load_build_info.outputs.build_artifact_url }}
5454
build_artifact_id: ${{ steps.load_build_info.outputs.build_artifact_id }}
5555
build_artifact_digest: ${{ steps.load_build_info.outputs.build_artifact_digest }}
56+
build_pr_number: ${{ steps.load_build_info.outputs.build_pr_number }}
5657
build_environment: ${{ steps.load_build_info.outputs.build_environment }}
5758
mats_url: ${{ steps.output_run_id.outputs.mats_url }}
5859
mats_id: ${{ steps.output_run_id.outputs.mats_id }}
@@ -342,6 +343,7 @@ jobs:
342343
printf "%s\n" "build_artifact_url=${{ needs.check_build.outputs.build_artifact_url }}" >> "$GITHUB_OUTPUT"
343344
printf "%s\n" "build_artifact_id=${{ needs.check_build.outputs.build_artifact_id }}" >> "$GITHUB_OUTPUT"
344345
printf "%s\n" "build_artifact_digest=${{ needs.check_build.outputs.build_artifact_digest }}" >> "$GITHUB_OUTPUT"
346+
printf "%s\n" "build_pr_number=${{ needs.check_build.outputs.build_pr_number }}" >> "$GITHUB_OUTPUT"
345347
printf "%s\n" "build_environment=${{ needs.check_build.outputs.build_environment }}" >> "$GITHUB_OUTPUT"
346348
printf "%s\n" "build_id=${{ needs.check_build.outputs.build_id }}" >> "$GITHUB_OUTPUT"
347349
cat <"$GITHUB_OUTPUT" >> "BUILD-info.txt"

.github/workflows/Tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ jobs:
6363
build_artifact_url: ${{ steps.load_build_info.outputs.build_artifact_url }}
6464
build_artifact_id: ${{ steps.load_build_info.outputs.build_artifact_id }}
6565
build_artifact_digest: ${{ steps.load_build_info.outputs.build_artifact_digest }}
66+
build_pr_number: ${{ steps.load_build_info.outputs.build_pr_number }}
6667
build_environment: ${{ steps.load_build_info.outputs.build_environment }}
6768
mats_environment: ${{ steps.load_build_info.outputs.mats_environment }}
6869
mats_id: ${{ steps.load_build_info.outputs.mats_id }}
@@ -240,6 +241,7 @@ jobs:
240241
override_branch: ${{ needs.check_mats.outputs.build_ref_name }}
241242
override_build: ${{ needs.check_mats.outputs.build_id }}
242243
override_build_url: ${{ needs.check_mats.outputs.build_url }}
244+
override_pr: ${{ needs.check_mats.outputs.build_pr_number }}
243245
files: ./coverage.xml,./test-reports/coverage.xml,./test-reports/coverage_*.xml
244246
directory: .
245247
env_vars: OS,PYTHON_VERSION
@@ -477,6 +479,7 @@ jobs:
477479
override_branch: ${{ needs.check_mats.outputs.build_ref_name }}
478480
override_build: ${{ needs.check_mats.outputs.build_id }}
479481
override_build_url: ${{ needs.check_mats.outputs.build_url }}
482+
override_pr: ${{ needs.check_mats.outputs.build_pr_number }}
480483
files: ./test-reports/coverage_doctests.xml
481484
directory: .
482485
env_vars: OS,PYTHON_VERSION
@@ -897,6 +900,7 @@ jobs:
897900
override_branch: ${{ needs.check_mats.outputs.build_ref_name }}
898901
override_build: ${{ needs.check_mats.outputs.build_id }}
899902
override_build_url: ${{ needs.check_mats.outputs.build_url }}
903+
override_pr: ${{ needs.check_mats.outputs.build_pr_number }}
900904
report_type: 'coverage'
901905
slug: 'reactive-firewall-org/multicast'
902906
files: ./test-reports/coverage_supplement.xml,./test-reports/coverage.xml,./test-reports/coverage_*.xml

multicast/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,21 +1022,21 @@ def doStep(self, *args, **kwargs) -> tuple: # pragma: no cover
10221022

10231023
if "multicast.recv" not in sys.modules:
10241024
# pylint: disable=cyclic-import - skipcq: PYL-R0401, PYL-C0414
1025-
from . import recv as recv # pylint: disable=cyclic-import - skipcq: PYL-R0401, PYL-C0414
1025+
from . import recv # pylint: disable=cyclic-import - skipcq: PYL-R0401, PYL-C0414
10261026
else: # pragma: no branch
10271027
global recv # skipcq: PYL-W0604
10281028
recv = sys.modules["multicast.recv"]
10291029

10301030
if "multicast.send" not in sys.modules:
10311031
# pylint: disable=cyclic-import - skipcq: PYL-R0401, PYL-C0414
1032-
from . import send as send # pylint: disable=cyclic-import - skipcq: PYL-R0401, PYL-C0414
1032+
from . import send # pylint: disable=cyclic-import - skipcq: PYL-R0401, PYL-C0414
10331033
else: # pragma: no branch
10341034
global send # skipcq: PYL-W0604
10351035
send = sys.modules["multicast.send"]
10361036

10371037
if "multicast.hear" not in sys.modules:
10381038
# pylint: disable=cyclic-import - skipcq: PYL-R0401, PYL-C0414
1039-
from . import hear as hear # pylint: disable=cyclic-import - skipcq: PYL-R0401, PYL-C0414
1039+
from . import hear # pylint: disable=cyclic-import - skipcq: PYL-R0401, PYL-C0414
10401040
else: # pragma: no branch
10411041
global hear # skipcq: PYL-W0604
10421042
hear = sys.modules["multicast.hear"]

multicast/hear.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -726,18 +726,18 @@ def handle(self) -> None:
726726
>>>
727727
"""
728728
(data, sock) = self.request
729-
if data is None or not sock:
729+
if data is None or not sock: # pragma: no branch
730730
return # nothing to do -- fail fast.
731-
else: # skipcq: PYL-R1705 -- otherwise try to decode
732-
try:
733-
data = data.decode('utf8') if isinstance(data, bytes) else str(data)
734-
except UnicodeDecodeError: # pragma: no cover
735-
if __debug__:
736-
module_logger.debug(
737-
"Received invalid UTF-8 data from %s", # lazy formatting to avoid PYL-W1203
738-
self.client_address[0],
739-
)
740-
return # silently ignore invalid UTF-8 data -- fail quickly.
731+
# skipcq: PYL-R1705 -- otherwise can try to decode
732+
try:
733+
data = data.decode('utf8') if isinstance(data, bytes) else str(data)
734+
except UnicodeDecodeError: # pragma: no cover -- defensive code branch
735+
if __debug__:
736+
module_logger.debug(
737+
"Received invalid UTF-8 data from %s", # lazy formatting to avoid PYL-W1203
738+
self.client_address[0],
739+
)
740+
return # silently ignore invalid UTF-8 data -- fail quickly.
741741
_logger = logging.getLogger(f"{type(self).__module__}.{type(self).__qualname__}")
742742
if __debug__:
743743
_logger.info(
@@ -747,7 +747,7 @@ def handle(self) -> None:
747747
me = str(sock.getsockname()[0])
748748
_sender: multicast.send.McastSAY = None
749749
_sender = send.McastSAY()
750-
if __debug__: # pragma: no cover
750+
if __debug__: # pragma: no cover -- defensive code branch
751751
_what = data.strip().replace("""\r""", str()).replace("""%""", """%%""")
752752
_logger.info(
753753
"%s HEAR: [%s SAID %s]", # lazy formatting to avoid PYL-W1203

0 commit comments

Comments
 (0)