From 3aac757e7cb2022ac6cc6ef83728b8366867ba65 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Wed, 24 Nov 2021 11:56:50 +0100 Subject: [PATCH] CI: Combine smaller linters into a single job (#60279) * CI: Combine smaller linters into a single job * Remove unrelated changhe * Remove stale exit --- .github/workflows/ci.yaml | 237 ++++++-------------------------------- 1 file changed, 38 insertions(+), 199 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d4fab3d1a2d..c9a9ac4eff8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -162,111 +162,6 @@ jobs: . venv/bin/activate pre-commit run --hook-stage manual black --all-files --show-diff-on-failure - lint-codespell: - name: Check codespell - runs-on: ubuntu-latest - needs: prepare-base - steps: - - name: Check out code from GitHub - uses: actions/checkout@v2.4.0 - - name: Set up Python ${{ env.DEFAULT_PYTHON }} - uses: actions/setup-python@v2.3.0 - id: python - with: - python-version: ${{ env.DEFAULT_PYTHON }} - - name: Restore base Python virtual environment - id: cache-venv - uses: actions/cache@v2.1.7 - with: - path: venv - key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ - needs.prepare-base.outputs.python-key }} - - name: Fail job if Python cache restore failed - if: steps.cache-venv.outputs.cache-hit != 'true' - run: | - echo "Failed to restore Python virtual environment from cache" - exit 1 - - name: Restore pre-commit environment from cache - id: cache-precommit - uses: actions/cache@v2.1.7 - with: - path: ${{ env.PRE_COMMIT_CACHE }} - key: ${{ runner.os }}-${{ needs.prepare-base.outputs.pre-commit-key }} - - name: Fail job if pre-commit cache restore failed - if: steps.cache-precommit.outputs.cache-hit != 'true' - run: | - echo "Failed to restore pre-commit environment from cache" - exit 1 - - name: Register codespell problem matcher - run: | - echo "::add-matcher::.github/workflows/matchers/codespell.json" - - name: Run codespell - run: | - . venv/bin/activate - pre-commit run --show-diff-on-failure --hook-stage manual codespell --all-files - - lint-dockerfile: - name: Check Dockerfile - runs-on: ubuntu-latest - needs: prepare-base - steps: - - name: Check out code from GitHub - uses: actions/checkout@v2.4.0 - - name: Register hadolint problem matcher - run: | - echo "::add-matcher::.github/workflows/matchers/hadolint.json" - - name: Check Dockerfile - uses: docker://hadolint/hadolint:v1.18.2 - with: - args: hadolint Dockerfile - - name: Check Dockerfile.dev - uses: docker://hadolint/hadolint:v1.18.2 - with: - args: hadolint Dockerfile.dev - - lint-executable-shebangs: - name: Check executables - runs-on: ubuntu-latest - needs: prepare-base - steps: - - name: Check out code from GitHub - uses: actions/checkout@v2.4.0 - - name: Set up Python ${{ env.DEFAULT_PYTHON }} - uses: actions/setup-python@v2.3.0 - id: python - with: - python-version: ${{ env.DEFAULT_PYTHON }} - - name: Restore base Python virtual environment - id: cache-venv - uses: actions/cache@v2.1.7 - with: - path: venv - key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ - needs.prepare-base.outputs.python-key }} - - name: Fail job if Python cache restore failed - if: steps.cache-venv.outputs.cache-hit != 'true' - run: | - echo "Failed to restore Python virtual environment from cache" - exit 1 - - name: Restore pre-commit environment from cache - id: cache-precommit - uses: actions/cache@v2.1.7 - with: - path: ${{ env.PRE_COMMIT_CACHE }} - key: ${{ runner.os }}-${{ needs.prepare-base.outputs.pre-commit-key }} - - name: Fail job if pre-commit cache restore failed - if: steps.cache-precommit.outputs.cache-hit != 'true' - run: | - echo "Failed to restore pre-commit environment from cache" - exit 1 - - name: Register check executables problem matcher - run: | - echo "::add-matcher::.github/workflows/matchers/check-executables-have-shebangs.json" - - name: Run executables check - run: | - . venv/bin/activate - pre-commit run --hook-stage manual check-executables-have-shebangs --all-files - lint-flake8: name: Check flake8 runs-on: ubuntu-latest @@ -350,8 +245,8 @@ jobs: . venv/bin/activate pre-commit run --hook-stage manual isort --all-files --show-diff-on-failure - lint-json: - name: Check JSON + lint-other: + name: Check other linters runs-on: ubuntu-latest needs: prepare-base steps: @@ -385,6 +280,20 @@ jobs: run: | echo "Failed to restore pre-commit environment from cache" exit 1 + + - name: Run pyupgrade + run: | + . venv/bin/activate + pre-commit run --hook-stage manual pyupgrade --all-files --show-diff-on-failure + + - name: Register yamllint problem matcher + run: | + echo "::add-matcher::.github/workflows/matchers/yamllint.json" + - name: Run yamllint + run: | + . venv/bin/activate + pre-commit run --hook-stage manual yamllint --all-files --show-diff-on-failure + - name: Register check-json problem matcher run: | echo "::add-matcher::.github/workflows/matchers/check-json.json" @@ -393,99 +302,34 @@ jobs: . venv/bin/activate pre-commit run --hook-stage manual check-json --all-files - lint-pyupgrade: - name: Check pyupgrade - runs-on: ubuntu-latest - needs: prepare-base - steps: - - name: Check out code from GitHub - uses: actions/checkout@v2.4.0 - - name: Set up Python ${{ env.DEFAULT_PYTHON }} - uses: actions/setup-python@v2.3.0 - id: python - with: - python-version: ${{ env.DEFAULT_PYTHON }} - - name: Restore base Python virtual environment - id: cache-venv - uses: actions/cache@v2.1.7 - with: - path: venv - key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ - needs.prepare-base.outputs.python-key }} - - name: Fail job if Python cache restore failed - if: steps.cache-venv.outputs.cache-hit != 'true' + - name: Register check executables problem matcher run: | - echo "Failed to restore Python virtual environment from cache" - exit 1 - - name: Restore pre-commit environment from cache - id: cache-precommit - uses: actions/cache@v2.1.7 - with: - path: ${{ env.PRE_COMMIT_CACHE }} - key: ${{ runner.os }}-${{ needs.prepare-base.outputs.pre-commit-key }} - - name: Fail job if pre-commit cache restore failed - if: steps.cache-precommit.outputs.cache-hit != 'true' - run: | - echo "Failed to restore pre-commit environment from cache" - exit 1 - - name: Run pyupgrade + echo "::add-matcher::.github/workflows/matchers/check-executables-have-shebangs.json" + - name: Run executables check run: | . venv/bin/activate - pre-commit run --hook-stage manual pyupgrade --all-files --show-diff-on-failure + pre-commit run --hook-stage manual check-executables-have-shebangs --all-files - # Disabled until we have the existing issues fixed - # lint-shellcheck: - # name: Check ShellCheck - # runs-on: ubuntu-latest - # needs: prepare-base - # steps: - # - name: Check out code from GitHub - # uses: actions/checkout@v2.4.0 - # - name: Run ShellCheck - # uses: ludeeus/action-shellcheck@0.3.0 - - lint-yaml: - name: Check YAML - runs-on: ubuntu-latest - needs: prepare-base - steps: - - name: Check out code from GitHub - uses: actions/checkout@v2.4.0 - - name: Set up Python ${{ env.DEFAULT_PYTHON }} - uses: actions/setup-python@v2.3.0 - id: python - with: - python-version: ${{ env.DEFAULT_PYTHON }} - - name: Restore base Python virtual environment - id: cache-venv - uses: actions/cache@v2.1.7 - with: - path: venv - key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ - needs.prepare-base.outputs.python-key }} - - name: Fail job if Python cache restore failed - if: steps.cache-venv.outputs.cache-hit != 'true' + - name: Register codespell problem matcher run: | - echo "Failed to restore Python virtual environment from cache" - exit 1 - - name: Restore pre-commit environment from cache - id: cache-precommit - uses: actions/cache@v2.1.7 - with: - path: ${{ env.PRE_COMMIT_CACHE }} - key: ${{ runner.os }}-${{ needs.prepare-base.outputs.pre-commit-key }} - - name: Fail job if pre-commit cache restore failed - if: steps.cache-precommit.outputs.cache-hit != 'true' - run: | - echo "Failed to restore pre-commit environment from cache" - exit 1 - - name: Register yamllint problem matcher - run: | - echo "::add-matcher::.github/workflows/matchers/yamllint.json" - - name: Run yamllint + echo "::add-matcher::.github/workflows/matchers/codespell.json" + - name: Run codespell run: | . venv/bin/activate - pre-commit run --hook-stage manual yamllint --all-files --show-diff-on-failure + pre-commit run --show-diff-on-failure --hook-stage manual codespell --all-files + + - name: Register hadolint problem matcher + run: | + echo "::add-matcher::.github/workflows/matchers/hadolint.json" + + - name: Check Dockerfile + uses: docker://hadolint/hadolint:v1.18.2 + with: + args: hadolint Dockerfile + - name: Check Dockerfile.dev + uses: docker://hadolint/hadolint:v1.18.2 + with: + args: hadolint Dockerfile.dev hassfest: name: Check hassfest @@ -708,13 +552,8 @@ jobs: - hassfest - lint-bandit - lint-black - - lint-codespell - - lint-dockerfile - - lint-executable-shebangs + - lint-other - lint-isort - - lint-json - - lint-pyupgrade - - lint-yaml - mypy - prepare-tests strategy: