From a279038e8d67f295d89145b102a382e467267903 Mon Sep 17 00:00:00 2001 From: Morgan Christiansson Date: Sun, 30 May 2021 08:09:46 +0100 Subject: [PATCH 1/4] Extract retry logic into scripts/retry I like the consistency in the copy paste here.. All instances are identical and find-replace easily addresses the duplication :+1: TIMEOUT/RETRIES have same value everywhere --- .github/workflows/build-helm.yml | 149 ++-------------- .github/workflows/build-kops.yml | 149 ++-------------- .github/workflows/build.yml | 265 +++-------------------------- .github/workflows/nightly-helm.yml | 149 ++-------------- .github/workflows/nightly-kops.yml | 149 ++-------------- .github/workflows/nightly.yml | 265 +++-------------------------- scripts/retry | 14 ++ 7 files changed, 112 insertions(+), 1028 deletions(-) create mode 100755 scripts/retry diff --git a/.github/workflows/build-helm.yml b/.github/workflows/build-helm.yml index 6cba404..9d8253b 100644 --- a/.github/workflows/build-helm.yml +++ b/.github/workflows/build-helm.yml @@ -109,42 +109,13 @@ jobs: # ------------------------------------------------------------ - name: Pull Base Image run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make pull-base-image - env: - RETRIES: 20 - PAUSE: 10 + scripts/retry make pull-base-image - name: Build Builder Image run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make _build_builder + scripts/retry make _build_builder env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -152,23 +123,9 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible Base run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=base + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=base env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -176,23 +133,9 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible Tools run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=tools + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=tools env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -200,23 +143,9 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible AWS run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=aws + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=aws env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -224,23 +153,9 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible AWS K8s run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=awsk8s + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=awsk8s env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -248,45 +163,17 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible AWS Helm run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=awshelm HELM=${HELM} + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=awshelm HELM=${HELM} env: HELM: ${{ matrix.helm }} VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 - name: Test Ansible AWS Helm run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test ANSIBLE=${VERSION} FLAVOUR=awshelm HELM=${HELM} + scripts/retry make test ANSIBLE=${VERSION} FLAVOUR=awshelm HELM=${HELM} env: HELM: ${{ matrix.helm }} VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -294,18 +181,6 @@ jobs: # ------------------------------------------------------------ - name: Publish images (only repo owner) run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } # Output echo "GIT_TYPE=${GIT_TYPE}" @@ -313,19 +188,17 @@ jobs: echo "DOCKER_TAG_AWSHELM=${DOCKER_TAG_AWSHELM}" # Tag image - retry make tag ANSIBLE=${VERSION} FLAVOUR=awshelm HELM=${HELM} TAG=${DOCKER_TAG_AWSHELM} + scripts/retry make tag ANSIBLE=${VERSION} FLAVOUR=awshelm HELM=${HELM} TAG=${DOCKER_TAG_AWSHELM} docker images | grep cytopia/ansible # Login - retry make login USERNAME=${{ secrets.DOCKERHUB_USERNAME }} PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} + scripts/retry make login USERNAME=${{ secrets.DOCKERHUB_USERNAME }} PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} # Push - retry make push TAG=${DOCKER_TAG_AWSHELM} + scripts/retry make push TAG=${DOCKER_TAG_AWSHELM} env: HELM: ${{ matrix.helm }} VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id && ( diff --git a/.github/workflows/build-kops.yml b/.github/workflows/build-kops.yml index f23110f..a1c4625 100644 --- a/.github/workflows/build-kops.yml +++ b/.github/workflows/build-kops.yml @@ -110,42 +110,13 @@ jobs: # ------------------------------------------------------------ - name: Pull Base Image run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make pull-base-image - env: - RETRIES: 20 - PAUSE: 10 + scripts/retry make pull-base-image - name: Build Builder Image run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make _build_builder + scripts/retry make _build_builder env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -153,23 +124,9 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible Base run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=base + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=base env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -177,23 +134,9 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible Tools run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=tools + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=tools env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -201,23 +144,9 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible AWS run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=aws + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=aws env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -225,23 +154,9 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible AWS K8s run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=awsk8s + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=awsk8s env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -249,45 +164,17 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible AWS Kops run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=awskops KOPS=${KOPS} + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=awskops KOPS=${KOPS} env: KOPS: ${{ matrix.kops }} VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 - name: Test Ansible AWS Kops run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test ANSIBLE=${VERSION} FLAVOUR=awskops KOPS=${KOPS} + scripts/retry make test ANSIBLE=${VERSION} FLAVOUR=awskops KOPS=${KOPS} env: KOPS: ${{ matrix.kops }} VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -295,18 +182,6 @@ jobs: # ------------------------------------------------------------ - name: Publish images (only repo owner) run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } # Output echo "GIT_TYPE=${GIT_TYPE}" @@ -314,19 +189,17 @@ jobs: echo "DOCKER_TAG_AWSKOPS=${DOCKER_TAG_AWSKOPS}" # Tag image - retry make tag ANSIBLE=${VERSION} FLAVOUR=awskops KOPS=${KOPS} TAG=${DOCKER_TAG_AWSKOPS} + scripts/retry make tag ANSIBLE=${VERSION} FLAVOUR=awskops KOPS=${KOPS} TAG=${DOCKER_TAG_AWSKOPS} docker images | grep cytopia/ansible # Login - retry make login USERNAME=${{ secrets.DOCKERHUB_USERNAME }} PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} + scripts/retry make login USERNAME=${{ secrets.DOCKERHUB_USERNAME }} PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} # Push - retry make push TAG=${DOCKER_TAG_AWSKOPS} + scripts/retry make push TAG=${DOCKER_TAG_AWSKOPS} env: KOPS: ${{ matrix.kops }} VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id && ( diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0496344..a2f22a6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -115,42 +115,13 @@ jobs: # ------------------------------------------------------------ - name: Pull Base Image run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make pull-base-image - env: - RETRIES: 20 - PAUSE: 10 + scripts/retry make pull-base-image - name: Build Builder Image run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make _build_builder + scripts/retry make _build_builder env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -158,43 +129,15 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible Base run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=base + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=base env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 - name: Test Ansible Base run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test ANSIBLE=${VERSION} FLAVOUR=base + scripts/retry make test ANSIBLE=${VERSION} FLAVOUR=base env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -202,43 +145,15 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible Tools run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=tools + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=tools env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 - name: Test Ansible Tools run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test ANSIBLE=${VERSION} FLAVOUR=tools + scripts/retry make test ANSIBLE=${VERSION} FLAVOUR=tools env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -246,43 +161,15 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible Infra run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=infra + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=infra env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 - name: Test Ansible Infra run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test ANSIBLE=${VERSION} FLAVOUR=infra + scripts/retry make test ANSIBLE=${VERSION} FLAVOUR=infra env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -290,43 +177,15 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible Azure run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=azure + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=azure env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 - name: Test Ansible Azure run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test ANSIBLE=${VERSION} FLAVOUR=azure + scripts/retry make test ANSIBLE=${VERSION} FLAVOUR=azure env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -334,43 +193,15 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible AWS run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=aws + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=aws env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 - name: Test Ansible AWS run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test ANSIBLE=${VERSION} FLAVOUR=aws + scripts/retry make test ANSIBLE=${VERSION} FLAVOUR=aws env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -378,43 +209,15 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible AWS K8s run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=awsk8s + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=awsk8s env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 - name: Test Ansible AWS K8s run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test ANSIBLE=${VERSION} FLAVOUR=awsk8s + scripts/retry make test ANSIBLE=${VERSION} FLAVOUR=awsk8s env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -422,18 +225,6 @@ jobs: # ------------------------------------------------------------ - name: Publish images (only repo owner) run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } # Output echo "GIT_TYPE=${GIT_TYPE}" @@ -446,28 +237,26 @@ jobs: echo "DOCKER_TAG_AWSK8S=${DOCKER_TAG_AWSK8S}" # Tag image - retry make tag ANSIBLE=${VERSION} FLAVOUR=base TAG=${DOCKER_TAG_BASE} - retry make tag ANSIBLE=${VERSION} FLAVOUR=tools TAG=${DOCKER_TAG_TOOLS} - retry make tag ANSIBLE=${VERSION} FLAVOUR=infra TAG=${DOCKER_TAG_INFRA} - retry make tag ANSIBLE=${VERSION} FLAVOUR=azure TAG=${DOCKER_TAG_AZURE} - retry make tag ANSIBLE=${VERSION} FLAVOUR=aws TAG=${DOCKER_TAG_AWS} - retry make tag ANSIBLE=${VERSION} FLAVOUR=awsk8s TAG=${DOCKER_TAG_AWSK8S} + scripts/retry make tag ANSIBLE=${VERSION} FLAVOUR=base TAG=${DOCKER_TAG_BASE} + scripts/retry make tag ANSIBLE=${VERSION} FLAVOUR=tools TAG=${DOCKER_TAG_TOOLS} + scripts/retry make tag ANSIBLE=${VERSION} FLAVOUR=infra TAG=${DOCKER_TAG_INFRA} + scripts/retry make tag ANSIBLE=${VERSION} FLAVOUR=azure TAG=${DOCKER_TAG_AZURE} + scripts/retry make tag ANSIBLE=${VERSION} FLAVOUR=aws TAG=${DOCKER_TAG_AWS} + scripts/retry make tag ANSIBLE=${VERSION} FLAVOUR=awsk8s TAG=${DOCKER_TAG_AWSK8S} docker images | grep cytopia/ansible # Login - retry make login USERNAME=${{ secrets.DOCKERHUB_USERNAME }} PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} + scripts/retry make login USERNAME=${{ secrets.DOCKERHUB_USERNAME }} PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} # Push - retry make push TAG=${DOCKER_TAG_BASE} - retry make push TAG=${DOCKER_TAG_TOOLS} - retry make push TAG=${DOCKER_TAG_INFRA} - retry make push TAG=${DOCKER_TAG_AZURE} - retry make push TAG=${DOCKER_TAG_AWS} - retry make push TAG=${DOCKER_TAG_AWSK8S} + scripts/retry make push TAG=${DOCKER_TAG_BASE} + scripts/retry make push TAG=${DOCKER_TAG_TOOLS} + scripts/retry make push TAG=${DOCKER_TAG_INFRA} + scripts/retry make push TAG=${DOCKER_TAG_AZURE} + scripts/retry make push TAG=${DOCKER_TAG_AWS} + scripts/retry make push TAG=${DOCKER_TAG_AWSK8S} env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id && ( diff --git a/.github/workflows/nightly-helm.yml b/.github/workflows/nightly-helm.yml index a6f1dd7..7893154 100644 --- a/.github/workflows/nightly-helm.yml +++ b/.github/workflows/nightly-helm.yml @@ -108,42 +108,13 @@ jobs: # ------------------------------------------------------------ - name: Pull Base Image run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make pull-base-image - env: - RETRIES: 20 - PAUSE: 10 + scripts/retry make pull-base-image - name: Build Builder Image run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make _build_builder + scripts/retry make _build_builder env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -151,23 +122,9 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible Base run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=base + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=base env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -175,23 +132,9 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible Tools run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=tools + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=tools env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -199,23 +142,9 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible AWS run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=aws + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=aws env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -223,23 +152,9 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible AWS K8s run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=awsk8s + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=awsk8s env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -247,45 +162,17 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible AWS Helm run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=awshelm HELM=${HELM} + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=awshelm HELM=${HELM} env: HELM: ${{ matrix.helm }} VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 - name: Test Ansible AWS Helm run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test ANSIBLE=${VERSION} FLAVOUR=awshelm HELM=${HELM} + scripts/retry make test ANSIBLE=${VERSION} FLAVOUR=awshelm HELM=${HELM} env: HELM: ${{ matrix.helm }} VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -293,18 +180,6 @@ jobs: # ------------------------------------------------------------ - name: Publish images (only repo owner) run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } # Output echo "GIT_TYPE=${GIT_TYPE}" @@ -312,19 +187,17 @@ jobs: echo "DOCKER_TAG_AWSHELM=${DOCKER_TAG_AWSHELM}" # Tag image - retry make tag ANSIBLE=${VERSION} FLAVOUR=awshelm HELM=${HELM} TAG=${DOCKER_TAG_AWSHELM} + scripts/retry make tag ANSIBLE=${VERSION} FLAVOUR=awshelm HELM=${HELM} TAG=${DOCKER_TAG_AWSHELM} docker images | grep cytopia/ansible # Login - retry make login USERNAME=${{ secrets.DOCKERHUB_USERNAME }} PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} + scripts/retry make login USERNAME=${{ secrets.DOCKERHUB_USERNAME }} PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} # Push - retry make push TAG=${DOCKER_TAG_AWSHELM} + scripts/retry make push TAG=${DOCKER_TAG_AWSHELM} env: HELM: ${{ matrix.helm }} VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id && ( diff --git a/.github/workflows/nightly-kops.yml b/.github/workflows/nightly-kops.yml index 4e95aa7..022d6c7 100644 --- a/.github/workflows/nightly-kops.yml +++ b/.github/workflows/nightly-kops.yml @@ -109,65 +109,22 @@ jobs: # ------------------------------------------------------------ - name: Pull Base Image run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make pull-base-image - env: - RETRIES: 20 - PAUSE: 10 + scripts/retry make pull-base-image - name: Build Builder Image run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make _build_builder + scripts/retry make _build_builder env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ # Base # ------------------------------------------------------------ - name: Build Ansible Base run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=base + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=base env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -175,23 +132,9 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible Tools run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=tools + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=tools env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -199,23 +142,9 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible AWS run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=aws + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=aws env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -223,23 +152,9 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible AWS K8s run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=awsk8s + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=awsk8s env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -247,45 +162,17 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible AWS Kops run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=awskops KOPS=${KOPS} + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=awskops KOPS=${KOPS} env: KOPS: ${{ matrix.kops }} VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 - name: Test Ansible AWS Kops run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test ANSIBLE=${VERSION} FLAVOUR=awskops KOPS=${KOPS} + scripts/retry make test ANSIBLE=${VERSION} FLAVOUR=awskops KOPS=${KOPS} env: KOPS: ${{ matrix.kops }} VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -293,18 +180,6 @@ jobs: # ------------------------------------------------------------ - name: Publish images (only repo owner) run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } # Output echo "GIT_TYPE=${GIT_TYPE}" @@ -312,19 +187,17 @@ jobs: echo "DOCKER_TAG_AWSKOPS=${DOCKER_TAG_AWSKOPS}" # Tag image - retry make tag ANSIBLE=${VERSION} FLAVOUR=awskops KOPS=${KOPS} TAG=${DOCKER_TAG_AWSKOPS} + scripts/retry make tag ANSIBLE=${VERSION} FLAVOUR=awskops KOPS=${KOPS} TAG=${DOCKER_TAG_AWSKOPS} docker images | grep cytopia/ansible # Login - retry make login USERNAME=${{ secrets.DOCKERHUB_USERNAME }} PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} + scripts/retry make login USERNAME=${{ secrets.DOCKERHUB_USERNAME }} PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} # Push - retry make push TAG=${DOCKER_TAG_AWSKOPS} + scripts/retry make push TAG=${DOCKER_TAG_AWSKOPS} env: KOPS: ${{ matrix.kops }} VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id && ( diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c622b77..1d96096 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -114,42 +114,13 @@ jobs: # ------------------------------------------------------------ - name: Pull Base Image run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make pull-base-image - env: - RETRIES: 20 - PAUSE: 10 + scripts/retry make pull-base-image - name: Build Builder Image run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make _build_builder + scripts/retry make _build_builder env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -157,43 +128,15 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible Base run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=base + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=base env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 - name: Test Ansible Base run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test ANSIBLE=${VERSION} FLAVOUR=base + scripts/retry make test ANSIBLE=${VERSION} FLAVOUR=base env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -201,43 +144,15 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible Tools run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=tools + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=tools env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 - name: Test Ansible Tools run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test ANSIBLE=${VERSION} FLAVOUR=tools + scripts/retry make test ANSIBLE=${VERSION} FLAVOUR=tools env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -245,43 +160,15 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible Infra run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=infra + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=infra env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 - name: Test Ansible Infra run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test ANSIBLE=${VERSION} FLAVOUR=infra + scripts/retry make test ANSIBLE=${VERSION} FLAVOUR=infra env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -289,43 +176,15 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible Azure run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=azure + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=azure env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 - name: Test Ansible Azure run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test ANSIBLE=${VERSION} FLAVOUR=azure + scripts/retry make test ANSIBLE=${VERSION} FLAVOUR=azure env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -333,43 +192,15 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible AWS run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=aws + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=aws env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 - name: Test Ansible AWS run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test ANSIBLE=${VERSION} FLAVOUR=aws + scripts/retry make test ANSIBLE=${VERSION} FLAVOUR=aws env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -377,43 +208,15 @@ jobs: # ------------------------------------------------------------ - name: Build Ansible AWS K8s run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make build ANSIBLE=${VERSION} FLAVOUR=awsk8s + scripts/retry make build ANSIBLE=${VERSION} FLAVOUR=awsk8s env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 - name: Test Ansible AWS K8s run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } - retry make test ANSIBLE=${VERSION} FLAVOUR=awsk8s + scripts/retry make test ANSIBLE=${VERSION} FLAVOUR=awsk8s env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # ------------------------------------------------------------ @@ -421,18 +224,6 @@ jobs: # ------------------------------------------------------------ - name: Publish images (only repo owner) run: | - retry() { - for n in $(seq ${RETRIES}); do - echo "[${n}/${RETRIES}] ${*}"; - if eval "${*}"; then - echo "[SUCC] ${n}/${RETRIES}"; - return 0; - fi; - sleep ${PAUSE}; - echo "[FAIL] ${n}/${RETRIES}"; - done; - return 1; - } # Output echo "GIT_TYPE=${GIT_TYPE}" @@ -445,28 +236,26 @@ jobs: echo "DOCKER_TAG_AWSK8S=${DOCKER_TAG_AWSK8S}" # Tag image - retry make tag ANSIBLE=${VERSION} FLAVOUR=base TAG=${DOCKER_TAG_BASE} - retry make tag ANSIBLE=${VERSION} FLAVOUR=tools TAG=${DOCKER_TAG_TOOLS} - retry make tag ANSIBLE=${VERSION} FLAVOUR=infra TAG=${DOCKER_TAG_INFRA} - retry make tag ANSIBLE=${VERSION} FLAVOUR=azure TAG=${DOCKER_TAG_AZURE} - retry make tag ANSIBLE=${VERSION} FLAVOUR=aws TAG=${DOCKER_TAG_AWS} - retry make tag ANSIBLE=${VERSION} FLAVOUR=awsk8s TAG=${DOCKER_TAG_AWSK8S} + scripts/retry make tag ANSIBLE=${VERSION} FLAVOUR=base TAG=${DOCKER_TAG_BASE} + scripts/retry make tag ANSIBLE=${VERSION} FLAVOUR=tools TAG=${DOCKER_TAG_TOOLS} + scripts/retry make tag ANSIBLE=${VERSION} FLAVOUR=infra TAG=${DOCKER_TAG_INFRA} + scripts/retry make tag ANSIBLE=${VERSION} FLAVOUR=azure TAG=${DOCKER_TAG_AZURE} + scripts/retry make tag ANSIBLE=${VERSION} FLAVOUR=aws TAG=${DOCKER_TAG_AWS} + scripts/retry make tag ANSIBLE=${VERSION} FLAVOUR=awsk8s TAG=${DOCKER_TAG_AWSK8S} docker images | grep cytopia/ansible # Login - retry make login USERNAME=${{ secrets.DOCKERHUB_USERNAME }} PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} + scripts/retry make login USERNAME=${{ secrets.DOCKERHUB_USERNAME }} PASSWORD=${{ secrets.DOCKERHUB_PASSWORD }} # Push - retry make push TAG=${DOCKER_TAG_BASE} - retry make push TAG=${DOCKER_TAG_TOOLS} - retry make push TAG=${DOCKER_TAG_INFRA} - retry make push TAG=${DOCKER_TAG_AZURE} - retry make push TAG=${DOCKER_TAG_AWS} - retry make push TAG=${DOCKER_TAG_AWSK8S} + scripts/retry make push TAG=${DOCKER_TAG_BASE} + scripts/retry make push TAG=${DOCKER_TAG_TOOLS} + scripts/retry make push TAG=${DOCKER_TAG_INFRA} + scripts/retry make push TAG=${DOCKER_TAG_AZURE} + scripts/retry make push TAG=${DOCKER_TAG_AWS} + scripts/retry make push TAG=${DOCKER_TAG_AWSK8S} env: VERSION: ${{ matrix.version }} - RETRIES: 20 - PAUSE: 10 # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id && ( diff --git a/scripts/retry b/scripts/retry new file mode 100755 index 0000000..1e78ed9 --- /dev/null +++ b/scripts/retry @@ -0,0 +1,14 @@ +#!/bin/bash +RETRIES=${RETRIES:-20} +PAUSE=${PAUSE:-10} + +for n in $(seq ${RETRIES}); do + echo "[${n}/${RETRIES}] ${*}" + if eval "${*}"; then + echo "[SUCC] ${n}/${RETRIES}" + exit 0 + fi + sleep ${PAUSE} + echo "[FAIL] ${n}/${RETRIES}" +done +exit 1 From ee23a822a62c1e6e2fc7a343ac26eda6709df576 Mon Sep 17 00:00:00 2001 From: cytopia Date: Wed, 2 Jun 2021 00:06:33 +0200 Subject: [PATCH 2/4] Update git tags for nightly build --- .github/workflows/nightly-helm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly-helm.yml b/.github/workflows/nightly-helm.yml index 7893154..fc7eed8 100644 --- a/.github/workflows/nightly-helm.yml +++ b/.github/workflows/nightly-helm.yml @@ -48,7 +48,7 @@ jobs: - "3.5" refs: - 'master' - - '0.33' + - '0.34' steps: # ------------------------------------------------------------ From 57c651fe8fcd1eacadbd7278d90678a3a843037d Mon Sep 17 00:00:00 2001 From: cytopia Date: Wed, 2 Jun 2021 00:11:49 +0200 Subject: [PATCH 3/4] Update nightly tag --- .github/workflows/nightly-kops.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly-kops.yml b/.github/workflows/nightly-kops.yml index 022d6c7..4a23844 100644 --- a/.github/workflows/nightly-kops.yml +++ b/.github/workflows/nightly-kops.yml @@ -49,7 +49,7 @@ jobs: - "1.20" refs: - 'master' - - '0.33' + - '0.34' steps: # ------------------------------------------------------------ From c463acd338d3dcb070d583d9ed6b14f40119fdc1 Mon Sep 17 00:00:00 2001 From: cytopia Date: Wed, 2 Jun 2021 00:12:26 +0200 Subject: [PATCH 4/4] Update nightly tag --- .github/workflows/nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 1d96096..1eb84ae 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -35,7 +35,7 @@ jobs: - 'latest' refs: - 'master' - - '0.33' + - '0.34' steps: # ------------------------------------------------------------