From 3db21f46c6df090ee2942673692e31564ca51939 Mon Sep 17 00:00:00 2001 From: Benoit Chevallier-Mames Date: Tue, 24 Sep 2024 17:47:57 +0200 Subject: [PATCH] chore(ci): fixing the lint errors --- .github/workflows/compiler_benchmark.yml | 18 ++++---- frontends/concrete-python/Makefile | 8 ++++ .../scripts/actionlint/actionlint.sh | 28 ++++++++++++ .../actionlint_check_with_whitelists.py | 44 +++++++++++++++++++ 4 files changed, 90 insertions(+), 8 deletions(-) create mode 100755 frontends/concrete-python/scripts/actionlint/actionlint.sh create mode 100644 frontends/concrete-python/scripts/actionlint/actionlint_check_with_whitelists.py diff --git a/.github/workflows/compiler_benchmark.yml b/.github/workflows/compiler_benchmark.yml index 063a1fe9d..e5136579b 100644 --- a/.github/workflows/compiler_benchmark.yml +++ b/.github/workflows/compiler_benchmark.yml @@ -68,15 +68,17 @@ jobs: - name: Export specific variables (GPU) if: ${{ startswith(inputs.instance_type, 'p3.') }} run: | - echo "CUDA_SUPPORT=ON" >> "${GITHUB_ENV}" - echo "BENCHMARK_TARGET=run-gpu-benchmarks" >> "${GITHUB_ENV}" - echo "CUDA_PATH=$CUDA_PATH" >> "${GITHUB_ENV}" + { echo "CUDA_SUPPORT=ON"; \ + echo "BENCHMARK_TARGET=run-gpu-benchmarks"; \ + echo "CUDA_PATH=$CUDA_PATH"; \ + echo "LD_LIBRARY_PATH=$CUDA_PATH/lib:$LD_LIBRARY_PATH"; \ + echo "CC=/usr/bin/gcc-${{ env.GCC_VERSION }}"; \ + echo "CXX=/usr/bin/g++-${{ env.GCC_VERSION }}"; \ + echo "CUDAHOSTCXX=/usr/bin/g++-${{ env.GCC_VERSION }}"; \ + echo "CUDACXX=$CUDA_PATH/bin/nvcc"; } >> "${GITHUB_ENV}" + + # FIXME: expected to be in another file? echo "$CUDA_PATH/bin" >> "${GITHUB_PATH}" - echo "LD_LIBRARY_PATH=$CUDA_PATH/lib:$LD_LIBRARY_PATH" >> "${GITHUB_ENV}" - echo "CC=/usr/bin/gcc-${{ env.GCC_VERSION }}" >> "${GITHUB_ENV}" - echo "CXX=/usr/bin/g++-${{ env.GCC_VERSION }}" >> "${GITHUB_ENV}" - echo "CUDAHOSTCXX=/usr/bin/g++-${{ env.GCC_VERSION }}" >> "${GITHUB_ENV}" - echo "CUDACXX=$CUDA_PATH/bin/nvcc" >> "${GITHUB_ENV}" - name: Setup rust toolchain for concrete-cpu uses: ./.github/workflows/setup_rust_toolchain_for_concrete_cpu diff --git a/frontends/concrete-python/Makefile b/frontends/concrete-python/Makefile index ef0454580..e8a21469d 100644 --- a/frontends/concrete-python/Makefile +++ b/frontends/concrete-python/Makefile @@ -228,6 +228,14 @@ check-links: linkchecker ../../docs --check-extern \ --no-warnings +actionlint: + ./scripts/actionlint/actionlint.sh + +shelllint: + @# grep -v "^\./\." is to avoid files in .hidden_directories + find . -type f -name "*.sh" | grep -v "^\./\." | \ + xargs shellcheck + pcc: check-format check-sanitize-notebooks mypy pydocstyle pylint ruff check-links # ============ diff --git a/frontends/concrete-python/scripts/actionlint/actionlint.sh b/frontends/concrete-python/scripts/actionlint/actionlint.sh new file mode 100755 index 000000000..9c4a42178 --- /dev/null +++ b/frontends/concrete-python/scripts/actionlint/actionlint.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +set -e + +LOG_FILE=$(mktemp /tmp/actionlint.script.XXXXXX) +SUMMARY_LOG_FILE=$(mktemp /tmp/actionlint.script.XXXXXX) + +# Get actionlint errors +actionlint | cat > "$LOG_FILE" + +# Get only where the errors are, not their type +grep -v .yml "$LOG_FILE" | grep -v ^" |" | cat > "$SUMMARY_LOG_FILE" + +# Check errors which are not whitelisted +if python3 scripts/actionlint/actionlint_check_with_whitelists.py < "$SUMMARY_LOG_FILE"; +then + echo "Successful end" + exit 0 +else + echo "Full log file: " + cat "$LOG_FILE" + + echo + echo "Summary log file:" + cat "$SUMMARY_LOG_FILE" + exit 255 +fi + diff --git a/frontends/concrete-python/scripts/actionlint/actionlint_check_with_whitelists.py b/frontends/concrete-python/scripts/actionlint/actionlint_check_with_whitelists.py new file mode 100644 index 000000000..9e210e5ab --- /dev/null +++ b/frontends/concrete-python/scripts/actionlint/actionlint_check_with_whitelists.py @@ -0,0 +1,44 @@ +""" Check an actionlint log against some whitelists """ + +import sys +from typing import Set + +# Exact lines which are whitelisted +whitelisted_lines: Set[str] = set() + +# Pattern which are whitelisted +whitelisted_pattern: Set[str] = { +} + + +def main(): + """Do the test + + Raises: + ValueError: if non whitelisted error occurred + """ + status = 0 + bad_lines = [] + for line in sys.stdin: + if line in whitelisted_lines: + continue + + is_bad_line = True + + for pattern in whitelisted_pattern: + if pattern in line: + is_bad_line = False + break + + if is_bad_line: + print("->", line) + status = 1 + bad_lines.append(line) + + if status: + errors = "\n------\n".join(bad_lines) + raise ValueError("Some non whitelisted errors, look at full log file:" f"{errors}") + + +if __name__ == "__main__": + main()