Make warnings require passing state #2

Open
allspice-kyle wants to merge 4 commits from strict_error_check into develop
2 changed files with 10 additions and 3 deletions

View File

@ -17,6 +17,8 @@ components_csv_path = sys.argv[1]
MIN_TEMP_C: int = -10 MIN_TEMP_C: int = -10
MAX_TEMP_C: int = 70 MAX_TEMP_C: int = 70
FAIL_ON_WARNING: bool = True
class ComponentsWarning: class ComponentsWarning:
def __init__(self): def __init__(self):
self.part_number: Optional[str] = None self.part_number: Optional[str] = None
@ -89,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 ")] min_temp, max_temp = [int(x.strip("¡ãC ")) for x in row["Temperature"].split(" to ")]
except ValueError: except ValueError:
logger.warning( 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']}`!") component.warnings.append(f"Malformed `Temperature` attribute: `{row['Temperature']}`!")
else: else:
@ -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: with open("./.allspice/report.md", mode="w", encoding="utf-8") as report_file:
report_file.write(template.render(report_context)) 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)

View File

@ -2,12 +2,12 @@
# Action triggers on push and issues # Action triggers on push and issues
# Action runs "generate-bom-altium" action # Action runs "generate-bom-altium" action
# .allspice/workflows/generate_bom.yml # .allspice/workflows/generate_bom.yml
name: Generate BOM name: Check Components
on: on:
pull_request: pull_request:
jobs: jobs:
Generate_BOM: Check_Components:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
# Checkout is only needed if columns.json is committed in your Altium project repo. # Checkout is only needed if columns.json is committed in your Altium project repo.
@ -53,6 +53,7 @@ jobs:
run: .allspice/component_validation.py ./bom.csv run: .allspice/component_validation.py ./bom.csv
- name: Post Comment on Design Review - 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 uses: https://hub.allspice.io/Actions/post-dr-comment@v0.1
with: with:
# The path to the markdown file containing the comment body. # The path to the markdown file containing the comment body.