From 7aeb0dabfb5604c4d179a5f08ff2cbcf2357f596 Mon Sep 17 00:00:00 2001 From: "Kyle D. McCormick" Date: Tue, 29 Oct 2024 11:01:24 -0400 Subject: [PATCH] fix: actually run stylelint --- .github/workflows/quality-checks.yml | 11 ++--- scripts/quality_test.py | 63 ++++++---------------------- 2 files changed, 18 insertions(+), 56 deletions(-) diff --git a/.github/workflows/quality-checks.yml b/.github/workflows/quality-checks.yml index 510059a9d62a..ddbfaaaed101 100644 --- a/.github/workflows/quality-checks.yml +++ b/.github/workflows/quality-checks.yml @@ -60,18 +60,19 @@ jobs: PIP_SRC: ${{ runner.temp }} run: | make test-requirements - + - name: Install npm env: PIP_SRC: ${{ runner.temp }} - run: npm ci - + NODE_ENV: development + run: npm ci + - name: Install python packages env: PIP_SRC: ${{ runner.temp }} run: | pip install -e . - + - name: Run Quality Tests env: PIP_SRC: ${{ runner.temp }} @@ -83,7 +84,7 @@ jobs: make xsslint make pii_check make check_keywords - + - name: Save Job Artifacts if: always() uses: actions/upload-artifact@v4 diff --git a/scripts/quality_test.py b/scripts/quality_test.py index fb7d1e481eb9..5e139faa4d91 100644 --- a/scripts/quality_test.py +++ b/scripts/quality_test.py @@ -117,42 +117,6 @@ def _get_count_from_last_line(filename, file_type): return None -def _get_stylelint_violations(): - """ - Returns the number of Stylelint violations. - """ - REPO_ROOT = repo_root() - REPORT_DIR = REPO_ROOT / 'reports' - stylelint_report_dir = (REPORT_DIR / "stylelint") - stylelint_report = stylelint_report_dir / "stylelint.report" - _prepare_report_dir(stylelint_report_dir) - - command = [ - 'node', 'node_modules/stylelint', - '*scss_files', - '--custom-formatter', 'stylelint-formatter-pretty/index.js' - ] - - with open(stylelint_report, 'w') as report_file: - subprocess.run( - command, - check=True, - stdout=report_file, - stderr=subprocess.STDOUT, - text=True - ) - - try: - return int(_get_count_from_last_line(stylelint_report, "stylelint")) - except TypeError: - fail_quality( - 'stylelint', - "FAILURE: Number of stylelint violations could not be found in {stylelint_report}".format( - stylelint_report=stylelint_report - ) - ) - - def run_eslint(): """ Runs eslint on static asset directories. @@ -211,23 +175,20 @@ def run_eslint(): def run_stylelint(): """ Runs stylelint on Sass files. - If limit option is passed, fails build if more violations than the limit are found. """ - - violations_limit = 0 - num_violations = _get_stylelint_violations() - # Fail if number of violations is greater than the limit - if num_violations > violations_limit: - fail_quality( - 'stylelint', - "FAILURE: Stylelint failed with too many violations: ({count}).\nThe limit is {violations_limit}.".format( - count=num_violations, - violations_limit=violations_limit, - ) + command = ['stylelint', '**/*.scss', '--custom-formatter', 'stylelint-formatter-pretty/index.js'] + import shlex + print(shlex.join(command)) + try: + subprocess.run( + command, + check=True, + text=True, ) - else: - print("successfully run stylelint with violations") - print(num_violations) + except subprocess.CalledProcessError: + print("stylelint failed") + sys.exit(1) + print("stylelint passed") def _extract_missing_pii_annotations(filename):