From f57a345456fe7940d04ae28278103dd5b82ff783 Mon Sep 17 00:00:00 2001 From: Christian Cwienk Date: Thu, 5 Dec 2024 09:39:37 +0100 Subject: [PATCH] do not require git for linting While it is reasonable for local executions to exempt files not under version-ctrl from linting, this is not actually helpful for pipelines. Guard against absence of git and thus remove the necessity for pipelines to install git. --- .ci/lint-flake8 | 12 ++++++++---- .github/workflows/build-and-test.yaml | 3 --- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.ci/lint-flake8 b/.ci/lint-flake8 index 383ec4c6c..7019641d9 100755 --- a/.ci/lint-flake8 +++ b/.ci/lint-flake8 @@ -8,11 +8,15 @@ src_dir="${1:-"$(readlink -f "$(dirname "${0}")/..")"}" error=0 # ignore files that are not under version-ctrl (helpful for local runs) -GIT_DIR="${src_dir}/.git" \ -GIT_WORKTREE="${src_dir}" \ - untracked=$(git status --porcelain=v2 | grep -e '^? ' | sed 's/^? //g') +if which git &>/dev/null; then + GIT_DIR="${src_dir}/.git" \ + GIT_WORKTREE="${src_dir}" \ + untracked=$(git status --porcelain=v2 | grep -e '^? ' | sed 's/^? //g') -exclude_args=$(echo -n "${untracked}" | tr \\n ,) + exclude_args=$(echo -n "${untracked}" | tr \\n ,) +else + exclude_args="" +fi # flake8 / the linter it instruments cannot handle our special type-hints (CliHint) if flake8 \ diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index 804e2a932..2fc7a187d 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -364,9 +364,6 @@ jobs: container: image: python:3.12-alpine steps: - - name: install git - run: | - apk add --no-cache git - uses: actions/checkout@v4 - name: Retrieve Distribution Packages uses: actions/download-artifact@v4