From 89b9116ef134462e5a489a5bc073b3847dd77612 Mon Sep 17 00:00:00 2001 From: John Wilkie Date: Mon, 13 May 2024 10:16:57 +0100 Subject: [PATCH 1/3] Retry logic for GHA dependency installation --- .github/workflows/JOB_tests.yml | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/JOB_tests.yml b/.github/workflows/JOB_tests.yml index 099fe40a5..e5c745b66 100644 --- a/.github/workflows/JOB_tests.yml +++ b/.github/workflows/JOB_tests.yml @@ -34,16 +34,27 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies - shell: bash # stops windows hosts from using powershell + shell: bash # Stops Windows hosts from using PowerShell run: | - pip install poetry pytest - poetry install --no-interaction --no-root -vvv --all-extras - poetry install --no-interaction --no-root --all-extras -vvv - pip install wheel - pip install --upgrade setuptools - pip install --editable ".[test,ml,medical,dev, ocv]" + max_retries=3 + attempt=0 + until [ $attempt -ge $max_retries ] + do + pip install poetry pytest && \ + poetry install --no-interaction --no-root -vvv --all-extras && \ + poetry install --no-interaction --no-root --all-extras -vvv && \ + pip install wheel && \ + pip install --upgrade setuptools && \ + pip install --editable ".[test,ml,medical,dev, ocv]" && break + attempt=$((attempt+1)) + sleep 5 + done + if [ $attempt -eq $max_retries ]; then + echo "Dependency installation failed after ${max_retries} attempts." + exit 1 + fi - name: Run pytest - shell: bash # stops windows hosts from using powershell + shell: bash # Stops Windows hosts from using PowerShell run: | python -m pytest From 0ffec1585e4263ae76b2360c8a81da184e0b51f8 Mon Sep 17 00:00:00 2001 From: John Wilkie Date: Mon, 13 May 2024 11:08:15 +0100 Subject: [PATCH 2/3] Clearner solution with GHA --- .github/workflows/JOB_tests.yml | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/.github/workflows/JOB_tests.yml b/.github/workflows/JOB_tests.yml index e5c745b66..90d388ced 100644 --- a/.github/workflows/JOB_tests.yml +++ b/.github/workflows/JOB_tests.yml @@ -33,26 +33,18 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Install dependencies - shell: bash # Stops Windows hosts from using PowerShell - run: | - max_retries=3 - attempt=0 - until [ $attempt -ge $max_retries ] - do - pip install poetry pytest && \ - poetry install --no-interaction --no-root -vvv --all-extras && \ - poetry install --no-interaction --no-root --all-extras -vvv && \ - pip install wheel && \ - pip install --upgrade setuptools && \ - pip install --editable ".[test,ml,medical,dev, ocv]" && break - attempt=$((attempt+1)) - sleep 5 - done - if [ $attempt -eq $max_retries ]; then - echo "Dependency installation failed after ${max_retries} attempts." - exit 1 - fi + - name: Install dependencies with retry + uses: nick-invision/retry@v3 + with: + timeout_minutes: 10 + max_attempts: 3 + command: | + pip install poetry pytest + poetry install --no-interaction --no-root -vvv --all-extras + poetry install --no-interaction --no-root --all-extras -vvv + pip install wheel + pip install --upgrade setuptools + pip install --editable ".[test,ml,medical,dev, ocv]" - name: Run pytest shell: bash # Stops Windows hosts from using PowerShell From e4f7d7dc293629848cfbad583a8959769722ef13 Mon Sep 17 00:00:00 2001 From: John Wilkie Date: Mon, 13 May 2024 11:57:49 +0100 Subject: [PATCH 3/3] force Windows GHA runs to use bash instead of PowerShell --- .github/workflows/JOB_tests.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/JOB_tests.yml b/.github/workflows/JOB_tests.yml index 90d388ced..bb6d122c1 100644 --- a/.github/workflows/JOB_tests.yml +++ b/.github/workflows/JOB_tests.yml @@ -39,12 +39,12 @@ jobs: timeout_minutes: 10 max_attempts: 3 command: | - pip install poetry pytest - poetry install --no-interaction --no-root -vvv --all-extras - poetry install --no-interaction --no-root --all-extras -vvv - pip install wheel - pip install --upgrade setuptools - pip install --editable ".[test,ml,medical,dev, ocv]" + bash -c "pip install poetry pytest && \ + poetry install --no-interaction --no-root -vvv --all-extras && \ + poetry install --no-interaction --no-root --all-extras -vvv && \ + pip install wheel && \ + pip install --upgrade setuptools && \ + pip install --editable '.[test,ml,medical,dev, ocv]'" - name: Run pytest shell: bash # Stops Windows hosts from using PowerShell