From 1fd59a8caa421153687de702c02329c2bfba54d9 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 27 Jul 2023 13:13:16 +0300 Subject: [PATCH] Stop creating linter report files in CI (#6560) Currently, when one of the linters reports a problem, if you want to see what that problem is, you have to do the following: 1. Click on the "Details" link in the PR. 2. Click "Summary". 3. Click the artifact (also, depending on the browser, choose where to save it). 4. Open the downloaded file (which is an archive). 5. Open the report file from the archive. 6. Delete the archive after you're done. That is far too much hassle, and all it gives you is a slightly fancier- looking report (and sometimes not even that, like in the case of black). So just remove all the report building and uploading. Now the above procedure is reduced to: 1. Click "Details". 2. Expand the appropriate build step. --- .github/workflows/bandit.yml | 10 +--------- .github/workflows/black.yml | 10 +--------- .github/workflows/eslint.yml | 11 +---------- .github/workflows/hadolint.yml | 20 +------------------- .github/workflows/isort.yml | 10 +--------- .github/workflows/pylint.yml | 13 +------------ .github/workflows/remark.yml | 16 +--------------- .github/workflows/stylelint.yml | 13 +------------ tests/json_to_html.py | 22 ---------------------- 9 files changed, 8 insertions(+), 117 deletions(-) delete mode 100644 tests/json_to_html.py diff --git a/.github/workflows/bandit.yml b/.github/workflows/bandit.yml index 2bdf459a568e..cab6e202e484 100644 --- a/.github/workflows/bandit.yml +++ b/.github/workflows/bandit.yml @@ -23,19 +23,11 @@ jobs: . .env/bin/activate pip install -U pip wheel setuptools pip install bandit - mkdir -p bandit_report echo "Bandit version: "$(bandit --version | head -1) echo "The files will be checked: "$(echo $CHANGED_FILES) - bandit -a file --ini .bandit -f html -o ./bandit_report/bandit_checks.html $CHANGED_FILES + bandit -a file --ini .bandit $CHANGED_FILES deactivate else echo "No files with the \"py\" extension found" fi - - - name: Upload artifacts - if: failure() - uses: actions/upload-artifact@v3.1.1 - with: - name: bandit_report - path: bandit_report diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index 6f75c038359c..460dc102e044 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -33,23 +33,15 @@ jobs: . .env/bin/activate pip install -U pip wheel setuptools pip install $(egrep "black.*" ./cvat-cli/requirements/development.txt) - mkdir -p black_report echo "Black version: "$(black --version) echo "The dirs will be checked: $UPDATED_DIRS" EXIT_CODE=0 for DIR in $UPDATED_DIRS; do - black --check --diff $DIR >> ./black_report/black_checks.txt || EXIT_CODE=$(($? | $EXIT_CODE)) || true + black --check --diff $DIR || EXIT_CODE=$(($? | $EXIT_CODE)) || true done deactivate exit $EXIT_CODE else echo "No files with the \"py\" extension found" fi - - - name: Upload artifacts - if: failure() - uses: actions/upload-artifact@v3.1.1 - with: - name: black_report - path: black_report diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index 21576df62977..c823f40fdc74 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -13,17 +13,8 @@ jobs: run: | yarn install --frozen-lockfile (cd tests && yarn install --frozen-lockfile) - yarn add eslint-detailed-reporter -D -W - name: Run checks run: | echo "ESLint version: "$(yarn run -s eslint --version) - mkdir -p eslint_report - yarn run eslint . -f node_modules/eslint-detailed-reporter/lib/detailed.js -o ./eslint_report/eslint_checks.html - - - name: Upload artifacts - if: failure() - uses: actions/upload-artifact@v3.1.1 - with: - name: eslint_report - path: eslint_report + yarn run eslint . diff --git a/.github/workflows/hadolint.yml b/.github/workflows/hadolint.yml index 9529f69becba..5978375a8654 100644 --- a/.github/workflows/hadolint.yml +++ b/.github/workflows/hadolint.yml @@ -23,26 +23,8 @@ jobs: curl -sL -o $HADOLINT "https://github.com/hadolint/hadolint/releases/download/v$HADOLINT_VER/hadolint-Linux-x86_64" && chmod 700 $HADOLINT echo "HadoLint version: "$($HADOLINT --version) echo "The files will be checked: "$(echo $CHANGED_FILES) - mkdir -p hadolint_report - $HADOLINT --no-fail --format json $CHANGED_FILES > ./hadolint_report/hadolint_report.json - GET_VERIFICATION_LEVEL=$(cat ./hadolint_report/hadolint_report.json | jq -r '.[] | .level') - for LINE in $GET_VERIFICATION_LEVEL; do - if [[ $LINE =~ $VERIFICATION_LEVEL ]]; then - pip install json2html - python ./tests/json_to_html.py ./hadolint_report/hadolint_report.json - exit 1 - else - exit 0 - fi - done + $HADOLINT -t $VERIFICATION_LEVEL $CHANGED_FILES else echo "No files with the \"Dockerfile*\" name found" fi - - - name: Upload artifacts - if: failure() - uses: actions/upload-artifact@v3.1.1 - with: - name: hadolint_report - path: hadolint_report diff --git a/.github/workflows/isort.yml b/.github/workflows/isort.yml index 4ed521885111..f3157b446c75 100644 --- a/.github/workflows/isort.yml +++ b/.github/workflows/isort.yml @@ -30,23 +30,15 @@ jobs: . .env/bin/activate pip install -U pip wheel setuptools pip install $(egrep "isort.*" ./cvat-cli/requirements/development.txt) - mkdir -p isort_report echo "isort version: $(isort --version-number)" echo "The dirs will be checked: $UPDATED_DIRS" EXIT_CODE=0 for DIR in $UPDATED_DIRS; do - isort --check $DIR >> ./isort_report/isort_checks.txt || EXIT_CODE=$(($? | $EXIT_CODE)) || true + isort --check $DIR || EXIT_CODE=$(($? | $EXIT_CODE)) || true done deactivate exit $EXIT_CODE else echo "No files with the \"py\" extension found" fi - - - name: Upload artifacts - if: failure() - uses: actions/upload-artifact@v3.1.1 - with: - name: isort_report - path: isort_report diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index ca4de7106ba0..f54623bc2984 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -23,24 +23,13 @@ jobs: python3 -m venv .env . .env/bin/activate pip install -U pip wheel setuptools - pip install pylint-json2html pip install $(egrep "pylint.*==.*" ./cvat/requirements/development.txt) pip install $(egrep "django==.*" ./cvat/requirements/base.txt) - mkdir -p pylint_report echo "Pylint version: "$(pylint --version | head -1) echo "The files will be checked: "$(echo $CHANGED_FILES) - pylint $CHANGED_FILES --output-format=json > ./pylint_report/pylint_checks.json || EXIT_CODE=$(echo $?) || true - pylint-json2html -o ./pylint_report/pylint_checks.html ./pylint_report/pylint_checks.json + pylint $CHANGED_FILES deactivate - exit $EXIT_CODE else echo "No files with the \"py\" extension found" fi - - - name: Upload artifacts - if: failure() - uses: actions/upload-artifact@v3.1.1 - with: - name: pylint_report - path: pylint_report diff --git a/.github/workflows/remark.yml b/.github/workflows/remark.yml index 8524364a5746..86e06962013b 100644 --- a/.github/workflows/remark.yml +++ b/.github/workflows/remark.yml @@ -12,20 +12,6 @@ jobs: - name: Run checks run: | yarn install --frozen-lockfile - mkdir -p remark_report echo "Remark version: "`npx remark --version` - npx remark --quiet --report json --no-stdout -i .remarkignore . 2> ./remark_report/remark_report.json - get_report=`cat ./remark_report/remark_report.json | jq -r '.[] | select(.messages | length > 0)'` - if [[ ! -z ${get_report} ]]; then - pip install json2html - python ./tests/json_to_html.py ./remark_report/remark_report.json - exit 1 - fi - - - name: Upload artifacts - if: failure() - uses: actions/upload-artifact@v3.1.1 - with: - name: remark_report - path: remark_report + npx remark --quiet --frail -i .remarkignore . diff --git a/.github/workflows/stylelint.yml b/.github/workflows/stylelint.yml index 3fdfd81cf26e..e47e64fab246 100644 --- a/.github/workflows/stylelint.yml +++ b/.github/workflows/stylelint.yml @@ -21,21 +21,10 @@ jobs: if [[ ! -z $CHANGED_FILES ]]; then yarn install --frozen-lockfile - mkdir -p stylelint_report echo "StyleLint version: "$(npx stylelint --version) echo "The files will be checked: "$(echo $CHANGED_FILES) - npx stylelint --formatter json --output-file ./stylelint_report/stylelint_report.json $CHANGED_FILES || EXIT_CODE=$(echo $?) || true - pip install json2html - python ./tests/json_to_html.py ./stylelint_report/stylelint_report.json - exit $EXIT_CODE + npx stylelint $CHANGED_FILES else echo "No files with the \"css|scss\" extension found" fi - - - name: Upload artifacts - if: failure() - uses: actions/upload-artifact@v3.1.1 - with: - name: stylelint_report - path: stylelint_report diff --git a/tests/json_to_html.py b/tests/json_to_html.py deleted file mode 100644 index 2ef756220939..000000000000 --- a/tests/json_to_html.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright (C) 2021-2022 Intel Corporation -# -# SPDX-License-Identifier: MIT - -from json2html import json2html -import sys -import os -import json - -def json_to_html(path_to_json): - with open(path_to_json) as json_file: - data = json.load(json_file) - hadolint_html_report = json2html.convert(json = data) - - with open(os.path.splitext(path_to_json)[0] + '.html', 'w') as html_file: - html_file.write(hadolint_html_report) - - -if __name__ == '__main__': - json_to_html(sys.argv[1])