From 0b5d1ec16583796c2673411af271ddecb83cd0c9 Mon Sep 17 00:00:00 2001 From: Vaclav Petras Date: Tue, 6 Jun 2023 01:07:08 -0400 Subject: [PATCH] CI: Reduce number of Python jobs (#3014) With increased use of pre-commit, having nice feedback from the CI checks is less important because contributors should get the feedback from pre-commit and CI is just to check that the files are correct, but not primarily to report to the contributor what quality controls did not pass because that's what should happen locally when the contributor follows contributing guidelines. This applies to Black and Flake8. Pylint is not in pre-commit. Assuming the other get checked by pre-commit, the Pylint step is the one to fail most likely at the end of the job in case of issues. Black and Flake8 checks (which are purely static) are done before compilation so that generated files are not checked. Uses matrix with only single configuration to configure versions. Reports all versions of software in one place. --- .github/workflows/black.yml | 48 ------------------- .github/workflows/flake8.yml | 41 ---------------- .../{pylint.yml => python-code-quality.yml} | 33 +++++++++++-- 3 files changed, 29 insertions(+), 93 deletions(-) delete mode 100644 .github/workflows/black.yml delete mode 100644 .github/workflows/flake8.yml rename .github/workflows/{pylint.yml => python-code-quality.yml} (79%) diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml deleted file mode 100644 index c777b9534d0..00000000000 --- a/.github/workflows/black.yml +++ /dev/null @@ -1,48 +0,0 @@ ---- -name: Python Black Formatting - -on: - push: - branches: - - main - - releasebranch_* - pull_request: - branches: - - main - - releasebranch_* - -concurrency: - group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} - cancel-in-progress: true - -jobs: - run-black: - name: Black - - # Using matrix just to get variables which are not environmental variables - # and also to sync with other workflows which use matrix. - strategy: - matrix: - include: - - os: ubuntu-22.04 - python-version: '3.10' - black-version: '23.1.0' - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install - run: | - python -m pip install --upgrade pip - pip install black==${{ matrix.black-version }} - - - name: Run Black - run: | - black --check --diff . diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml deleted file mode 100644 index 75fb07a2025..00000000000 --- a/.github/workflows/flake8.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -name: Python Flake8 Code Quality - -on: - push: - branches: - - main - - releasebranch_* - pull_request: - branches: - - main - - releasebranch_* - -concurrency: - group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} - cancel-in-progress: true - -jobs: - flake8: - runs-on: ubuntu-22.04 - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - - name: Install - run: | - python -m pip install --upgrade pip - pip install flake8==3.9.2 - - - name: Run Flake8 - run: | - flake8 --count --statistics --show-source --jobs=$(nproc) . - - - name: Run Flake8 on additional files - run: | - flake8 --count --statistics --show-source --jobs=$(nproc) python/grass/{script,jupyter}/testsuite/ diff --git a/.github/workflows/pylint.yml b/.github/workflows/python-code-quality.yml similarity index 79% rename from .github/workflows/pylint.yml rename to .github/workflows/python-code-quality.yml index d4e021d8636..7ad02b39960 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/python-code-quality.yml @@ -1,5 +1,5 @@ --- -name: Python Pylint Code Quality +name: Python Code Quality on: push: @@ -12,8 +12,8 @@ on: - releasebranch_* jobs: - pylint: - name: Pylint ${{ matrix.pylint-version }} + python-checks: + name: Python Code Quality concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}-${{ @@ -28,11 +28,22 @@ jobs: - os: ubuntu-22.04 python-version: '3.10' min-python-version: '3.7' - pylint-version: 2.12.2 + black-version: '23.1.0' + flake8-version: '3.9.2' + pylint-version: '2.12.2' runs-on: ${{ matrix.os }} steps: + - name: Versions + run: | + echo OS: ${{ matrix.os }} + echo Python: ${{ matrix.python-version }} + echo Minimimal Python version: ${{ matrix.min-python-version }} + echo Black: ${{ matrix.black-version }} + echo Flake8: ${{ matrix.flake8-version }} + echo Pylint: ${{ matrix.pylint-version }} + - uses: actions/checkout@v3 - name: Set up Python @@ -52,8 +63,22 @@ jobs: python -m pip install --upgrade pip pip install -r .github/workflows/python_requirements.txt pip install -r .github/workflows/optional_requirements.txt + pip install black==${{ matrix.black-version }} + pip install flake8==${{ matrix.flake8-version }} pip install pylint==${{ matrix.pylint-version }} + - name: Run Black + run: | + black --check --diff . + + - name: Run Flake8 + run: | + flake8 --count --statistics --show-source --jobs=$(nproc) . + + - name: Run Flake8 on additional files + run: | + flake8 --count --statistics --show-source --jobs=$(nproc) python/grass/{script,jupyter}/testsuite/ + - name: Create installation directory run: | mkdir $HOME/install