diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml index 051d9d7b..34ecb443 100644 --- a/.github/workflows/code_quality.yml +++ b/.github/workflows/code_quality.yml @@ -10,7 +10,6 @@ on: jobs: build: - runs-on: ubuntu-latest # runs-on: self-hosted strategy: @@ -19,10 +18,12 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + - name: Install dependencies run: | python -m pip install --upgrade pip @@ -30,11 +31,27 @@ jobs: pip install flake8 pip install flake8-polyfill if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Get all Python changed and modified files + id: changed-python-files + uses: tj-actions/changed-files@v42 + with: + since_last_remote_commit: true + files: | + **.py + - name: Code complexity + if: steps.changed-python-files.outputs.any_changed == 'true' + env: + ALL_CHANGED_PYTHON_FILES: ${{ steps.changed-python-files.outputs.all_changed_files }} run: | # Runs Radon quality check - radon cc python --total-average --show-complexity + radon cc --total-average --show-complexity ${ALL_CHANGED_PYTHON_FILES[@]/#/} + - name: Code quality with flake8 + if: steps.changed-python-files.outputs.any_changed == 'true' + env: + ALL_CHANGED_PYTHON_FILES: ${{ steps.changed-python-files.outputs.all_changed_files }} run: | # Runs code quality check - flake8 python --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 --count --max-complexity=10 --max-line-length=127 --statistics ${ALL_CHANGED_PYTHON_FILES[@]/#/}