From 52861b295934ceb7ceba52c9e10f3da67cfd4d78 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 24 Apr 2025 12:27:10 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A7=AA=20Ensure=20all=20GHA=20jobs=20?= =?UTF-8?q?have=20timeouts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the best practice and if unfollowed, it may result in stuck jobs consuming 6 hours each before failing. Setting timeouts close to the typical run times improves responsiveness in case of trouble. --- .../build-manylinux-container-images.yml | 3 +++ .github/workflows/ci-cd.yml | 16 ++++++++++++++++ .github/workflows/reusable-linters.yml | 3 +++ .github/workflows/reusable-tests.yml | 2 ++ .pre-commit-config.yaml | 12 ++++++++++++ 5 files changed, 36 insertions(+) diff --git a/.github/workflows/build-manylinux-container-images.yml b/.github/workflows/build-manylinux-container-images.yml index dfd85b110..42ccecd8a 100644 --- a/.github/workflows/build-manylinux-container-images.yml +++ b/.github/workflows/build-manylinux-container-images.yml @@ -21,6 +21,9 @@ on: # yamllint disable-line rule:truthy jobs: build: runs-on: ubuntu-latest + + timeout-minutes: 120 + strategy: matrix: IMAGE: diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 322c160a3..12de027ab 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -433,6 +433,8 @@ jobs: - pre-setup runs-on: ubuntu-latest + timeout-minutes: 2 # network is slow sometimes + env: TOXENV: make-changelog @@ -756,6 +758,9 @@ jobs: - build-changelog - pre-setup # transitive, for accessing settings runs-on: ${{ matrix.runner-vm-os }} + + timeout-minutes: 2 + strategy: matrix: python-version: @@ -975,6 +980,9 @@ jobs: registry: registry.access.redhat.com runs-on: ubuntu-latest + + timeout-minutes: 5 + container: # NOTE: GHA has poor support for concat which is why I resorted to # NOTE: using this ugly ternary syntax @@ -1302,6 +1310,8 @@ jobs: - pre-setup # transitive, for accessing settings runs-on: ubuntu-latest + timeout-minutes: 1 + env: TOXENV: metadata-validation @@ -1386,6 +1396,8 @@ jobs: runs-on: Ubuntu-latest + timeout-minutes: 1 + steps: - name: Decide whether the needed jobs succeeded or failed uses: re-actors/alls-green@release/v1 @@ -1498,6 +1510,8 @@ jobs: && needs.publish-pypi.result == 'success' runs-on: ubuntu-latest + timeout-minutes: 1 + outputs: pull_request_url: ${{ steps.pr.outputs.pull_request_url }} @@ -1783,6 +1797,8 @@ jobs: ) runs-on: ubuntu-latest + timeout-minutes: 5 + environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }}/simple/ansible-pylibssh/ diff --git a/.github/workflows/reusable-linters.yml b/.github/workflows/reusable-linters.yml index f77d68b62..aa976b1f3 100644 --- a/.github/workflows/reusable-linters.yml +++ b/.github/workflows/reusable-linters.yml @@ -13,6 +13,9 @@ jobs: name: >- ${{ matrix.toxenv }}/${{ matrix.python-version }}@${{ matrix.os }} runs-on: ${{ matrix.os }} + + timeout-minutes: 2 + strategy: fail-fast: false matrix: diff --git a/.github/workflows/reusable-tests.yml b/.github/workflows/reusable-tests.yml index 2a36500a3..dd3993c54 100644 --- a/.github/workflows/reusable-tests.yml +++ b/.github/workflows/reusable-tests.yml @@ -71,6 +71,8 @@ jobs: ${{ inputs.dist-type }} dist runs-on: ${{ inputs.runner-vm-os }} + timeout-minutes: 7 + continue-on-error: >- ${{ ( diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9405c320f..57b2219d4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,6 +24,18 @@ repos: hooks: - id: remove-tabs +- repo: https://github.com/python-jsonschema/check-jsonschema.git + rev: 0.33.0 + hooks: + - id: check-jsonschema + name: Check GitHub Workflows set timeout-minutes + args: + - --builtin-schema + - github-workflows-require-timeout + files: ^\.github/workflows/[^/]+$ + types: + - yaml + - repo: https://github.com/pre-commit/pygrep-hooks.git rev: v1.10.0 hooks: From 768202aba8c48bb123d5ef3c8dafb2fb944b6980 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 24 Apr 2025 12:42:09 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9D=20Add=20a=20change=20note=20fo?= =?UTF-8?q?r=20PR=20#706?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/changelog-fragments/706.contrib.rst | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 docs/changelog-fragments/706.contrib.rst diff --git a/docs/changelog-fragments/706.contrib.rst b/docs/changelog-fragments/706.contrib.rst new file mode 100644 index 000000000..d78d46053 --- /dev/null +++ b/docs/changelog-fragments/706.contrib.rst @@ -0,0 +1,6 @@ +The CI is now configured to always set job timeout values. +This will ensure that the jobs that get stuck don't consume +all 6 hours just hanging, improving responsiveness and the +overall CI/CD resource usage. + +-- by :user:`webknjaz`