From beb23072ecd1bb15db1637a60b1dafb2b140fb35 Mon Sep 17 00:00:00 2001 From: "Kyle D." Date: Thu, 19 Sep 2024 17:47:57 +0200 Subject: [PATCH 1/4] Make warnings require passing state --- .allspice/component_validation.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.allspice/component_validation.py b/.allspice/component_validation.py index df187ab..a69dcb0 100755 --- a/.allspice/component_validation.py +++ b/.allspice/component_validation.py @@ -17,6 +17,8 @@ components_csv_path = sys.argv[1] MIN_TEMP_C: int = -10 MAX_TEMP_C: int = 70 +FAIL_ON_WARNING: bool = True + class ComponentsWarning: def __init__(self): self.part_number: Optional[str] = None @@ -115,3 +117,7 @@ template = template_env.get_template("report.template.md") with open("./.allspice/report.md", mode="w", encoding="utf-8") as report_file: report_file.write(template.render(report_context)) + +if FAIL_ON_WARNING and report_context["warning_count"] > 0: + logger.error('FAIL_ON_WARNING set to "True". Please resolve all warnings.') + exit(1) -- 2.40.3 From 673d883ee16a44567ff2c3c09402436813bc70d2 Mon Sep 17 00:00:00 2001 From: "Kyle D." Date: Thu, 19 Sep 2024 17:50:19 +0200 Subject: [PATCH 2/4] Fix name --- .allspice/workflows/bom-gen.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.allspice/workflows/bom-gen.yml b/.allspice/workflows/bom-gen.yml index f66f4ab..11f4074 100644 --- a/.allspice/workflows/bom-gen.yml +++ b/.allspice/workflows/bom-gen.yml @@ -7,7 +7,7 @@ on: pull_request: jobs: - Generate_BOM: + Check_Components: runs-on: ubuntu-latest steps: # Checkout is only needed if columns.json is committed in your Altium project repo. -- 2.40.3 From 336721282c9002a06bf0863e477acb35467c50c5 Mon Sep 17 00:00:00 2001 From: "Kyle D." Date: Thu, 19 Sep 2024 17:50:50 +0200 Subject: [PATCH 3/4] Update workflow name --- .allspice/workflows/bom-gen.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.allspice/workflows/bom-gen.yml b/.allspice/workflows/bom-gen.yml index 11f4074..96c4831 100644 --- a/.allspice/workflows/bom-gen.yml +++ b/.allspice/workflows/bom-gen.yml @@ -2,7 +2,7 @@ # Action triggers on push and issues # Action runs "generate-bom-altium" action # .allspice/workflows/generate_bom.yml -name: Generate BOM +name: Check Components on: pull_request: -- 2.40.3 From 99097b8b015a125772c42aa137b0779e778d198b Mon Sep 17 00:00:00 2001 From: "Kyle D." Date: Thu, 26 Sep 2024 10:35:09 +0200 Subject: [PATCH 4/4] Generate report even on failure --- .allspice/component_validation.py | 2 +- .allspice/workflows/bom-gen.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.allspice/component_validation.py b/.allspice/component_validation.py index a69dcb0..d97264b 100755 --- a/.allspice/component_validation.py +++ b/.allspice/component_validation.py @@ -91,7 +91,7 @@ with open(components_csv_path, newline="") as components_csv: min_temp, max_temp = [int(x.strip("¡ãC ")) for x in row["Temperature"].split(" to ")] except ValueError: logger.warning( - f"Designators(s) {row['Designator']} have malformed `Temperature` attribute: !" + f"Designators(s) {row['Designator']} have malformed `Temperature` attribute: {row['Temperature']}!" ) component.warnings.append(f"Malformed `Temperature` attribute: `{row['Temperature']}`!") else: diff --git a/.allspice/workflows/bom-gen.yml b/.allspice/workflows/bom-gen.yml index 96c4831..d78e655 100644 --- a/.allspice/workflows/bom-gen.yml +++ b/.allspice/workflows/bom-gen.yml @@ -53,6 +53,7 @@ jobs: run: .allspice/component_validation.py ./bom.csv - name: Post Comment on Design Review + if: always() # Generate the report even if the last step failed. uses: https://hub.allspice.io/Actions/post-dr-comment@v0.1 with: # The path to the markdown file containing the comment body. -- 2.40.3