From 3f2c03fe7769bde12dff9320955d3066fc73c0cc Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 22 Aug 2023 19:53:55 +0200 Subject: [PATCH] Add input option to skip coverage [ci] (#98821) --- .github/workflows/ci.yaml | 57 +++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5cb51a30ddadf..a96a06024734a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,6 +19,10 @@ on: description: "Skip pytest" default: false type: boolean + skip-coverage: + description: "Skip coverage" + default: false + type: boolean pylint-only: description: "Only run pylint" default: false @@ -79,6 +83,7 @@ jobs: test_groups: ${{ steps.info.outputs.test_groups }} tests_glob: ${{ steps.info.outputs.tests_glob }} tests: ${{ steps.info.outputs.tests }} + skip_coverage: ${{ steps.info.outputs.skip_coverage }} runs-on: ubuntu-22.04 steps: - name: Check out code from GitHub @@ -127,6 +132,7 @@ jobs: test_group_count=10 tests="[]" tests_glob="" + skip_coverage="" if [[ "${{ steps.integrations.outputs.changes }}" != "[]" ]]; then @@ -176,6 +182,12 @@ jobs: test_full_suite="true" fi + if [[ "${{ github.event.inputs.skip-coverage }}" == "true" ]] \ + || [[ "${{ contains(github.event.pull_request.labels.*.name, 'ci-skip-coverage') }}" == "true" ]]; + then + skip_coverage="true" + fi + # Output & sent to GitHub Actions echo "mariadb_groups: ${mariadb_groups}" echo "mariadb_groups=${mariadb_groups}" >> $GITHUB_OUTPUT @@ -195,6 +207,8 @@ jobs: echo "tests=${tests}" >> $GITHUB_OUTPUT echo "tests_glob: ${tests_glob}" echo "tests_glob=${tests_glob}" >> $GITHUB_OUTPUT + echo "skip_coverage: ${skip_coverage}" + echo "skip_coverage=${skip_coverage}" >> $GITHUB_OUTPUT pre-commit: name: Prepare pre-commit base @@ -741,6 +755,11 @@ jobs: . venv/bin/activate python --version set -o pipefail + cov_params=() + if [[ "${{ needs.info.outputs.skip_coverage }}" != "true" ]]; then + cov_params+=(--cov="homeassistant") + cov_params+=(--cov-report=xml) + fi python3 -X dev -m pytest \ -qq \ @@ -750,8 +769,7 @@ jobs: --dist=loadfile \ --test-group-count ${{ needs.info.outputs.test_group_count }} \ --test-group=${{ matrix.group }} \ - --cov="homeassistant" \ - --cov-report=xml \ + ${cov_params[@]} \ -o console_output_style=count \ -p no:sugar \ tests \ @@ -773,13 +791,18 @@ jobs: exit 1 fi + cov_params=() + if [[ "${{ needs.info.outputs.skip_coverage }}" != "true" ]]; then + cov_params+=(--cov="homeassistant.components.${{ matrix.group }}") + cov_params+=(--cov-report=xml) + cov_params+=(--cov-report=term-missing) + fi + python3 -X dev -m pytest \ -qq \ --timeout=9 \ -n auto \ - --cov="homeassistant.components.${{ matrix.group }}" \ - --cov-report=xml \ - --cov-report=term-missing \ + ${cov_params[@]} \ -o console_output_style=count \ --durations=0 \ --durations-min=1 \ @@ -793,6 +816,7 @@ jobs: name: pytest-${{ github.run_number }} path: pytest-*.txt - name: Upload coverage artifact + if: needs.info.outputs.skip_coverage != 'true' uses: actions/upload-artifact@v3.1.2 with: name: coverage-${{ matrix.python-version }}-${{ matrix.group }} @@ -888,14 +912,18 @@ jobs: python --version set -o pipefail mariadb=$(echo "${{ matrix.mariadb-group }}" | sed "s/:/-/g") + cov_params=() + if [[ "${{ needs.info.outputs.skip_coverage }}" != "true" ]]; then + cov_params+=(--cov="homeassistant.components.recorder") + cov_params+=(--cov-report=xml) + cov_params+=(--cov-report=term-missing) + fi python3 -X dev -m pytest \ -qq \ --timeout=20 \ -n 1 \ - --cov="homeassistant.components.recorder" \ - --cov-report=xml \ - --cov-report=term-missing \ + ${cov_params[@]} \ -o console_output_style=count \ --durations=10 \ -p no:sugar \ @@ -912,6 +940,7 @@ jobs: name: pytest-${{ github.run_number }} path: pytest-*.txt - name: Upload coverage artifact + if: needs.info.outputs.skip_coverage != 'true' uses: actions/upload-artifact@v3.1.2 with: name: coverage-${{ matrix.python-version }}-mariadb @@ -1007,14 +1036,18 @@ jobs: python --version set -o pipefail postgresql=$(echo "${{ matrix.postgresql-group }}" | sed "s/:/-/g") + cov_params=() + if [[ "${{ needs.info.outputs.skip_coverage }}" != "true" ]]; then + cov_params+=(--cov="homeassistant.components.recorder") + cov_params+=(--cov-report=xml) + cov_params+=(--cov-report=term-missing) + fi python3 -X dev -m pytest \ -qq \ --timeout=9 \ -n 1 \ - --cov="homeassistant.components.recorder" \ - --cov-report=xml \ - --cov-report=term-missing \ + ${cov_params[@]} \ -o console_output_style=count \ --durations=0 \ --durations-min=10 \ @@ -1032,6 +1065,7 @@ jobs: name: pytest-${{ github.run_number }} path: pytest-*.txt - name: Upload coverage artifact + if: needs.info.outputs.skip_coverage != 'true' uses: actions/upload-artifact@v3.1.0 with: name: coverage-${{ matrix.python-version }}-postgresql @@ -1042,6 +1076,7 @@ jobs: coverage: name: Upload test coverage to Codecov + if: needs.info.outputs.skip_coverage != 'true' runs-on: ubuntu-22.04 needs: - info