# HG changeset patch
# User Noe Gaumont <ngaumont@logilab.fr>
# Date 1648825792 -7200
#      Fri Apr 01 17:09:52 2022 +0200
# Node ID 9d9ce3ac468d092b437165c8d540085986e30b83
# Parent  3227c616982b9fcc0935b6b7ef7bf4370352c8da
feat: use the retry command

diff --git a/templates/build-debian-package.yml b/templates/build-debian-package.yml
--- a/templates/build-debian-package.yml
+++ b/templates/build-debian-package.yml
@@ -1,9 +1,12 @@
 ---
+include: 'templates/template.yml'
+
 variables:
   PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}"
 
 
 build-debian:
+  extends: .retry
   stage: build-debian-package
   image: logilab/infra/dockerfiles/buildpackage
   tags:
@@ -22,6 +25,7 @@
       - repo
 
 upload-deb-to-heptapod:
+  extends: .retry
   stage: upload-deb-to-heptapod
   image: curlimages/curl:latest
   tags:
diff --git a/templates/build-docker-image.yml b/templates/build-docker-image.yml
--- a/templates/build-docker-image.yml
+++ b/templates/build-docker-image.yml
@@ -1,5 +1,8 @@
 ---
+include: 'templates/template.yml'
+
 image_build:
+  extends: .retry
   stage: release
   image:
     name: gcr.io/kaniko-project/executor:debug
@@ -17,6 +20,7 @@
     - if: '$CI_COMMIT_REF_NAME != "branch/default"'
 
 image_build_latest:
+  extends: .retry
   stage: release
   image:
     name: gcr.io/kaniko-project/executor:debug
@@ -35,6 +39,7 @@
     - if: '$CI_COMMIT_REF_NAME == "branch/default"'
 
 image_build_tag:
+  extends: .retry
   stage: release
   image:
     name: gcr.io/kaniko-project/executor:debug
diff --git a/templates/create-release-on-heptapod-including-debian-package.yml b/templates/create-release-on-heptapod-including-debian-package.yml
--- a/templates/create-release-on-heptapod-including-debian-package.yml
+++ b/templates/create-release-on-heptapod-including-debian-package.yml
@@ -1,8 +1,11 @@
 ---
 
-include: 'templates/create-release-on-heptapod.yml'
+include:
+  - 'templates/create-release-on-heptapod.yml'
+  - 'templates/template.yml'
 
 create-release-on-heptapod:
+  extends: .retry
   script:
     - |
       release-cli create --name "Release $CI_COMMIT_TAG"
diff --git a/templates/create-release-on-heptapod.yml b/templates/create-release-on-heptapod.yml
--- a/templates/create-release-on-heptapod.yml
+++ b/templates/create-release-on-heptapod.yml
@@ -1,5 +1,8 @@
 ---
+include: 'templates/template.yml'
+
 create-release-on-heptapod:
+  extends: .retry
   stage: release
   image: registry.gitlab.com/gitlab-org/release-cli:latest
   tags:
diff --git a/templates/lint/black.yml b/templates/lint/black.yml
--- a/templates/lint/black.yml
+++ b/templates/lint/black.yml
@@ -1,5 +1,8 @@
 ---
+include: 'templates/template.yml'
+
 black:
+  extends: .retry
   interruptible: true
   image: ${CI_REGISTRY}/cubicweb/dockerfiles/python-logilab:latest
   except:
diff --git a/templates/lint/check-manifest.yml b/templates/lint/check-manifest.yml
--- a/templates/lint/check-manifest.yml
+++ b/templates/lint/check-manifest.yml
@@ -1,5 +1,8 @@
 ---
+include: 'templates/template.yml'
+
 check-manifest:
+  extends: .retry
   interruptible: true
   image: ${CI_REGISTRY}/cubicweb/dockerfiles/python-logilab:latest
   except:
diff --git a/templates/lint/flake8.yml b/templates/lint/flake8.yml
--- a/templates/lint/flake8.yml
+++ b/templates/lint/flake8.yml
@@ -1,5 +1,8 @@
 ---
+include: 'templates/template.yml'
+
 flake8:
+  extends: .retry
   interruptible: true
   image: ${CI_REGISTRY}/cubicweb/dockerfiles/python-logilab:latest
   except:
diff --git a/templates/lint/mypy.yml b/templates/lint/mypy.yml
--- a/templates/lint/mypy.yml
+++ b/templates/lint/mypy.yml
@@ -1,5 +1,8 @@
 ---
+include: 'templates/template.yml'
+
 mypy:
+  extends: .retry
   interruptible: true
   image: ${CI_REGISTRY}/cubicweb/dockerfiles/python-logilab:latest
   except:
diff --git a/templates/lint/safety.yml b/templates/lint/safety.yml
--- a/templates/lint/safety.yml
+++ b/templates/lint/safety.yml
@@ -1,5 +1,8 @@
 ---
+include: 'templates/template.yml'
+
 safety:
+  extends: .retry
   interruptible: true
   allow_failure: true
   stage: lint
diff --git a/templates/lint/yamllint.yml b/templates/lint/yamllint.yml
--- a/templates/lint/yamllint.yml
+++ b/templates/lint/yamllint.yml
@@ -1,5 +1,8 @@
 ---
+include: 'templates/template.yml'
+
 yamllint:
+  extends: .retry
   interruptible: true
   image: ${CI_REGISTRY}/cubicweb/dockerfiles/python-logilab:latest
   tags:
diff --git a/templates/template.yml b/templates/template.yml
new file mode 100644
--- /dev/null
+++ b/templates/template.yml
@@ -0,0 +1,10 @@
+---
+
+.retry:
+  retry:
+    max: 2
+    when:
+      - runner_system_failure
+      - stuck_or_timeout_failure
+      - api_failure
+      - scheduler_failure
diff --git a/templates/tests/py27.yml b/templates/tests/py27.yml
--- a/templates/tests/py27.yml
+++ b/templates/tests/py27.yml
@@ -1,5 +1,8 @@
 ---
+include: 'templates/template.yml'
+
 py27:
+  extends: .retry
   interruptible: true
   before_script:
     - pip install tox
diff --git a/templates/tests/py3.yml b/templates/tests/py3.yml
--- a/templates/tests/py3.yml
+++ b/templates/tests/py3.yml
@@ -1,5 +1,8 @@
 ---
+include: 'templates/template.yml'
+
 py3:
+  extends: .retry
   interruptible: true
   image: ${CI_REGISTRY}/cubicweb/dockerfiles/bullseye-slim-pg13
   stage: tests
diff --git a/templates/upload-python-package-to-heptapod.yml b/templates/upload-python-package-to-heptapod.yml
--- a/templates/upload-python-package-to-heptapod.yml
+++ b/templates/upload-python-package-to-heptapod.yml
@@ -1,5 +1,8 @@
 ---
+include: 'templates/template.yml'
+
 upload-python-package-to-heptapod:
+  extends: .retry
   stage: publish
   image: python
   tags:
diff --git a/templates/upload-to-pypi.yml b/templates/upload-to-pypi.yml
--- a/templates/upload-to-pypi.yml
+++ b/templates/upload-to-pypi.yml
@@ -1,5 +1,8 @@
 ---
+include: 'templates/template.yml'
+
 pypi-publish:
+  extends: .retry
   stage: publish
   image: ${CI_REGISTRY}/cubicweb/dockerfiles/python-logilab:latest
   tags: