diff --git a/.github/scripts/matrix.py b/.github/scripts/matrix.py index c94fba4e..6e6cf1c4 100644 --- a/.github/scripts/matrix.py +++ b/.github/scripts/matrix.py @@ -109,10 +109,8 @@ def get_tests(config): # Set run_veristat to false by default. matrix[idx]["run_veristat"] = matrix[idx].get("run_veristat", False) # Feel in the tests - matrix[idx]["tests"] = {"include": [ - generate_test_config(test) - for test in get_tests(matrix[idx]) - ] + matrix[idx]["tests"] = { + "include": [generate_test_config(test) for test in get_tests(matrix[idx])] } # Only a few repository within "kernel-patches" use self-hosted runners. @@ -136,4 +134,4 @@ def get_tests(config): build_matrix = {"include": matrix} -set_output("build_matrix", dumps(build_matrix)) \ No newline at end of file +set_output("build_matrix", dumps(build_matrix)) diff --git a/.github/scripts/veristat-compare.py b/.github/scripts/veristat-compare.py index 0c5944f7..1e38616d 100644 --- a/.github/scripts/veristat-compare.py +++ b/.github/scripts/veristat-compare.py @@ -52,17 +52,22 @@ SUMMARY_HEADERS = ["File", "Program", "Verdict", "States Diff (%)"] # expected format: +0 (+0.00%) / -0 (-0.00%) -TOTAL_STATES_DIFF_REGEX = \ +TOTAL_STATES_DIFF_REGEX = ( r"(?P[+-]\d+) \((?P[+-]\d+\.\d+)\%\)" +) -TEXT_SUMMARY_TEMPLATE: Final[str] = """ +TEXT_SUMMARY_TEMPLATE: Final[ + str +] = """ # {title} {table} """.strip() -HTML_SUMMARY_TEMPLATE: Final[str] = """ +HTML_SUMMARY_TEMPLATE: Final[ + str +] = """ # {title}
@@ -135,21 +140,17 @@ def get_results_summary(self, markup: bool = False) -> str: def get_state_diff(value: str) -> float: - if value == 'N/A': + if value == "N/A": return 0.0 matches = re.match(TOTAL_STATES_DIFF_REGEX, value) if not matches: - raise ValueError( - f"Failed to parse total states diff field value '{value}'" - ) + raise ValueError(f"Failed to parse total states diff field value '{value}'") if percentage_diff := matches.group("percentage_diff"): return float(percentage_diff) - raise ValueError( - f"Invalid {VeristatFields.TOTAL_STATES_DIFF} field value: {value}" - ) + raise ValueError(f"Invalid {VeristatFields.TOTAL_STATES_DIFF} field value: {value}") def parse_table(csv_file): @@ -190,18 +191,16 @@ def parse_table(csv_file): if not add: continue - table.append([ - record[VeristatFields.FILE_NAME], - record[VeristatFields.PROG_NAME], - verdict, - f"{diff:+.2f} %" - ]) - - return VeristatInfo( - table=table, - changes=changes, - new_failures=new_failures - ) + table.append( + [ + record[VeristatFields.FILE_NAME], + record[VeristatFields.PROG_NAME], + verdict, + f"{diff:+.2f} %", + ] + ) + + return VeristatInfo(table=table, changes=changes, new_failures=new_failures) def github_markup_decorate(input_str: str) -> str: @@ -219,8 +218,7 @@ def format_table(headers: List[str], rows: List[List[str]]) -> str: # Row template string in the following format: # "{0:8}|{1:10}|{2:15}|{3:7}|{4:10}" row_template = "|".join( - f"{{{idx}:{width}}}" - for idx, width in enumerate(column_width) + f"{{{idx}:{width}}}" for idx, width in enumerate(column_width) ) row_template_nl = f"|{row_template}|\n" @@ -237,10 +235,7 @@ def format_table(headers: List[str], rows: List[List[str]]) -> str: return out.getvalue() -def main( - compare_csv_filename: os.PathLike, - output_filename: os.PathLike -) -> None: +def main(compare_csv_filename: os.PathLike, output_filename: os.PathLike) -> None: with open(compare_csv_filename, newline="", encoding="utf-8") as csv_file: veristat_results = parse_table(csv_file) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ca51a79b..f9a51a24 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,6 +21,19 @@ jobs: env: SHELLCHECK_OPTS: --severity=warning --exclude=SC1091 + # Ensure some consistency in the formatting. + lint: + if: ${{ github.repository == 'kernel-patches/vmtest' }} + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Run black + uses: psf/black@stable + with: + src: ./.github/scripts + validate_matrix: if: ${{ github.repository == 'kernel-patches/vmtest' }} name: Validate matrix.py