From fadb67e4254e6dcd67db30d9e2eb35371dc55dae Mon Sep 17 00:00:00 2001 From: LizardByte-bot <108553330+LizardByte-bot@users.noreply.github.com> Date: Sun, 11 Aug 2024 20:03:06 +0000 Subject: [PATCH 1/5] chore: update global workflows --- .github/semantic.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/semantic.yml diff --git a/.github/semantic.yml b/.github/semantic.yml new file mode 100644 index 0000000..b5eb70d --- /dev/null +++ b/.github/semantic.yml @@ -0,0 +1,14 @@ +--- +# This file is centrally managed in https://github.com//.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +# This is the configuration file for https://github.com/Ezard/semantic-prs + +enabled: true +titleOnly: true # We only use the PR title as we squash and merge +commitsOnly: false +titleAndCommits: false +anyCommit: false +allowMergeCommits: false +allowRevertCommits: false From c9123fcd21d61b4f143327190c1a091426958220 Mon Sep 17 00:00:00 2001 From: LizardByte-bot <108553330+LizardByte-bot@users.noreply.github.com> Date: Thu, 29 Aug 2024 14:46:21 +0000 Subject: [PATCH 2/5] chore: update global workflows --- .flake8 | 3 +-- .github/workflows/python-flake8.yml | 32 +++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/.flake8 b/.flake8 index 2d028b2..2ea7395 100644 --- a/.flake8 +++ b/.flake8 @@ -1,7 +1,6 @@ [flake8] filename = - *.py, - *.pys + *.py max-line-length = 120 extend-exclude = venv/ diff --git a/.github/workflows/python-flake8.yml b/.github/workflows/python-flake8.yml index 61e23f7..6077a95 100644 --- a/.github/workflows/python-flake8.yml +++ b/.github/workflows/python-flake8.yml @@ -26,13 +26,37 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 # https://github.com/actions/setup-python with: - python-version: '3.10' + python-version: '3.12' - name: Install dependencies run: | - # pin flake8 before v6.0.0 due to removal of support for type comments (required for Python 2.7 type hints) - python -m pip install --upgrade pip setuptools "flake8<6" + python -m pip install --upgrade \ + pip \ + setuptools \ + wheel \ + flake8 \ + nb-clean \ + nbqa[toolchain] - name: Test with flake8 run: | - python -m flake8 --verbose + python -m flake8 \ + --color=always \ + --verbose + + - name: Test with nbqa + run: | + python -m nbqa flake8 \ + --color=always \ + --verbose \ + . + + - name: Test with nb-clean + run: | + output=$(find . -name '*.ipynb' -exec nb-clean check {} \;) + + # fail if there are any issues + if [ -n "$output" ]; then + echo "$output" + exit 1 + fi From 97937fea0f2c9b8de103569f8b48898302619221 Mon Sep 17 00:00:00 2001 From: LizardByte-bot <108553330+LizardByte-bot@users.noreply.github.com> Date: Sat, 31 Aug 2024 04:48:52 +0000 Subject: [PATCH 3/5] chore: update global workflows --- .github/workflows/python-flake8.yml | 62 --------------------------- .github/workflows/yaml-lint.yml | 66 ----------------------------- 2 files changed, 128 deletions(-) delete mode 100644 .github/workflows/python-flake8.yml delete mode 100644 .github/workflows/yaml-lint.yml diff --git a/.github/workflows/python-flake8.yml b/.github/workflows/python-flake8.yml deleted file mode 100644 index 6077a95..0000000 --- a/.github/workflows/python-flake8.yml +++ /dev/null @@ -1,62 +0,0 @@ ---- -# This action is centrally managed in https://github.com//.github/ -# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in -# the above-mentioned repo. - -# Lint python files with flake8. - -name: flake8 - -on: - pull_request: - branches: [master] - types: [opened, synchronize, reopened] - -concurrency: - group: "${{ github.workflow }}-${{ github.ref }}" - cancel-in-progress: true - -jobs: - flake8: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 # https://github.com/actions/setup-python - with: - python-version: '3.12' - - - name: Install dependencies - run: | - python -m pip install --upgrade \ - pip \ - setuptools \ - wheel \ - flake8 \ - nb-clean \ - nbqa[toolchain] - - - name: Test with flake8 - run: | - python -m flake8 \ - --color=always \ - --verbose - - - name: Test with nbqa - run: | - python -m nbqa flake8 \ - --color=always \ - --verbose \ - . - - - name: Test with nb-clean - run: | - output=$(find . -name '*.ipynb' -exec nb-clean check {} \;) - - # fail if there are any issues - if [ -n "$output" ]; then - echo "$output" - exit 1 - fi diff --git a/.github/workflows/yaml-lint.yml b/.github/workflows/yaml-lint.yml deleted file mode 100644 index 023b836..0000000 --- a/.github/workflows/yaml-lint.yml +++ /dev/null @@ -1,66 +0,0 @@ ---- -# This action is centrally managed in https://github.com//.github/ -# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in -# the above-mentioned repo. - -# Lint yaml files. - -name: yaml lint - -on: - pull_request: - branches: [master] - types: [opened, synchronize, reopened] - -concurrency: - group: "${{ github.workflow }}-${{ github.ref }}" - cancel-in-progress: true - -jobs: - yaml-lint: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Find additional files - id: find-files - run: | - # space separated list of files - FILES=.clang-format - - # empty placeholder - FOUND="" - - for FILE in ${FILES}; do - if [ -f "$FILE" ] - then - FOUND="$FOUND $FILE" - fi - done - - echo "found=${FOUND}" >> $GITHUB_OUTPUT - - - name: yaml lint - id: yaml-lint - uses: ibiqlik/action-yamllint@v3 - with: - # https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration - config_data: | - extends: default - rules: - comments: - level: error - line-length: - max: 120 - truthy: - # GitHub uses "on" for workflow event triggers - # .clang-format file has options of "Yes" "No" that will be caught by this, so changed to "warning" - allowed-values: ['true', 'false', 'on'] - check-keys: true - level: warning - file_or_dir: . ${{ steps.find-files.outputs.found }} - - - name: Log - run: | - cat "${{ steps.yaml-lint.outputs.logfile }}" >> $GITHUB_STEP_SUMMARY From 3ebf9648d27d041ae9a08d7e9d985344d3aedb09 Mon Sep 17 00:00:00 2001 From: LizardByte-bot <108553330+LizardByte-bot@users.noreply.github.com> Date: Sat, 31 Aug 2024 04:52:22 +0000 Subject: [PATCH 4/5] chore: update global workflows --- .github/workflows/common-lint.yml | 245 ++++++++++++++++++++++++++++++ 1 file changed, 245 insertions(+) create mode 100644 .github/workflows/common-lint.yml diff --git a/.github/workflows/common-lint.yml b/.github/workflows/common-lint.yml new file mode 100644 index 0000000..4a62b24 --- /dev/null +++ b/.github/workflows/common-lint.yml @@ -0,0 +1,245 @@ +--- +# This action is centrally managed in https://github.com//.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +# Common linting. + +name: common lint + +on: + pull_request: + branches: [master] + types: [opened, synchronize, reopened] + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + lint: + name: Common Lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install dependencies + run: | + python -m pip install --upgrade \ + pip \ + setuptools \ + wheel \ + cmakelang \ + flake8 \ + nb-clean \ + nbqa[toolchain] + + - name: C++ - find files + id: cpp_files + run: | + # find files + found_files=$(find . -type f \ + -iname "*.c" -o \ + -iname "*.cpp" -o \ + -iname "*.h" -o \ + -iname "*.hpp" -o \ + -iname "*.m" -o \ + -iname "*.mm" \ + ) + ignore_files=$(find . -type f -iname ".clang-format-ignore") + + # Loop through each C++ file + for file in $found_files; do + for ignore_file in $ignore_files; do + ignore_directory=$(dirname "$ignore_file") + # if directory of ignore_file is beginning of file + if [[ "$file" == "$ignore_directory"* ]]; then + echo "ignoring file: ${file}" + found_files="${found_files//${file}/}" + break 1 + fi + done + done + + # remove empty lines + found_files=$(echo "$found_files" | sed '/^\s*$/d') + + echo "found cpp files: ${found_files}" + + # do not quote to keep this as a single line + echo found_files=${found_files} >> $GITHUB_OUTPUT + + - name: C++ - Clang format lint + if: always() && steps.cpp_files.outputs.found_files + uses: DoozyX/clang-format-lint-action@v0.18 + with: + source: ${{ steps.cpp_files.outputs.found_files }} + extensions: 'c,cpp,h,hpp,m,mm' + style: file + inplace: false + + - name: CMake - find files + id: cmake_files + if: always() + run: | + # find files + found_files=$(find . -type f -iname "CMakeLists.txt" -o -iname "*.cmake") + ignore_files=$(find . -type f -iname ".cmake-lint-ignore") + + # Loop through each C++ file + for file in $found_files; do + for ignore_file in $ignore_files; do + ignore_directory=$(dirname "$ignore_file") + # if directory of ignore_file is beginning of file + if [[ "$file" == "$ignore_directory"* ]]; then + echo "ignoring file: ${file}" + found_files="${found_files//${file}/}" + break 1 + fi + done + done + + # remove empty lines + found_files=$(echo "$found_files" | sed '/^\s*$/d') + + echo "found cmake files: ${found_files}" + + # do not quote to keep this as a single line + echo found_files=${found_files} >> $GITHUB_OUTPUT + + - name: CMake - cmake-lint + if: always() && steps.cmake_files.outputs.found_files + run: | + cmake-lint --line-width 120 --tab-size 4 ${{ steps.cmake_files.outputs.found_files }} + + - name: Docker - find files + id: dokcer_files + if: always() + run: | + found_files=$(find . -type f -iname "Dockerfile" -o -iname "*.dockerfile") + + echo "found_files: ${found_files}" + + # do not quote to keep this as a single line + echo found_files=${found_files} >> $GITHUB_OUTPUT + + - name: Docker - hadolint + if: always() && steps.dokcer_files.outputs.found_files + run: | + docker pull hadolint/hadolint + + # create hadolint config file + cat < .hadolint.yaml + --- + ignored: + - DL3008 + - DL3013 + - DL3016 + - DL3018 + - DL3028 + - DL3059 + EOF + + failed=0 + failed_files="" + + for file in ${{ steps.dokcer_files.outputs.found_files }}; do + echo "::group::${file}" + docker run --rm -i \ + -e "NO_COLOR=0" \ + -e "HADOLINT_VERBOSE=1" \ + -v $(pwd)/.hadolint.yaml:/.config/hadolint.yaml \ + hadolint/hadolint < $file || { + failed=1 + failed_files="$failed_files $file" + } + echo "::endgroup::" + done + + if [ $failed -ne 0 ]; then + echo "::error:: hadolint failed for the following files: $failed_files" + exit 1 + fi + + - name: Python - flake8 + if: always() + run: | + python -m flake8 \ + --color=always \ + --verbose + + - name: Python - nbqa flake8 + if: always() + run: | + python -m nbqa flake8 \ + --color=always \ + --verbose \ + . + + - name: Python - nb-clean + if: always() + run: | + output=$(find . -name '*.ipynb' -exec nb-clean check {} \;) + + # fail if there are any issues + if [ -n "$output" ]; then + echo "$output" + exit 1 + fi + + - name: YAML - find files + id: yaml_files + if: always() + run: | + # space separated list of files + FILES=.clang-format + + # empty placeholder + found_files="" + + for FILE in ${FILES}; do + if [ -f "$FILE" ] + then + found_files="$found_files $FILE" + fi + done + + echo "found_files=${found_files}" >> $GITHUB_OUTPUT + + - name: YAML - yamllint + id: yamllint + if: always() + uses: ibiqlik/action-yamllint@v3 + with: + # https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration + config_data: | + extends: default + rules: + comments: + level: error + document-start: + level: error + line-length: + max: 120 + new-line-at-end-of-file: + level: error + new-lines: + type: unix + truthy: + # GitHub uses "on" for workflow event triggers + # .clang-format file has options of "Yes" "No" that will be caught by this, so changed to "warning" + allowed-values: ['true', 'false', 'on'] + check-keys: true + level: warning + file_or_dir: . ${{ steps.yaml_files.outputs.found_files }} + + - name: YAML - log + if: always() && steps.yamllint.outcome == 'failure' + run: | + cat "${{ steps.yamllint.outputs.logfile }}" >> $GITHUB_STEP_SUMMARY From eca269469178b24d486610a5a25e26f6afe86434 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sat, 31 Aug 2024 13:32:16 -0400 Subject: [PATCH 5/5] style(docker): fix hadolint warnings --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e57c681..31a1b74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ FROM python:3.12-alpine3.18 AS base -RUN python -m pip install --upgrade pip setuptools wheel +RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel COPY . /app WORKDIR /app -RUN python -m pip install --upgrade -r requirements.txt +RUN python -m pip install --no-cache-dir --upgrade -r requirements.txt # github will mount the `GITHUB_WORKSPACE` directory to /github/workspace # https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#workdir