Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX - Ci improvement - Added Kapua docker image caching into Action process #3787

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/actions/cacheDockerRetry/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: 'Cache Docker Retry'
description: 'Retries the caching retrieval of docker images. This is a wrapper of the docker cache gitAction that retries the action with a delay in each retry. This is useful because sometimes concurrent usage of this gitAction causes too many requests error and so it is needed to retry it'
inputs:
key:
description: An explicit key for restoring and saving the cache
required: true
default: docker-layer-caching-${{ github.workflow }}-{hash}
restore-keys:
description: An ordered list of keys to use for restoring the cache if no cache hit occurred for key
required: false
default: docker-layer-caching-${{ github.workflow }}-
#outputs:
runs:
using: "composite"
steps:
- name: Docker images caching - try 1
id: dock1
continue-on-error: true
uses: jpribyl/[email protected]
with:
key: ${{ inputs.key }}
restore-keys: ${{ inputs.restore-keys }}
skip-save: true
- name: retry-sleep-1
if: ${{ always() && steps.dock1.outcome == 'failure' }} # the first status check function call (always) is needed for how status check functions works in GitHub actions (see https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions)
run: sleep 30 #TODO could implement a sleep different for each job. For example something like {JOBIDNUMBER * OFFSETseconds}
shell: bash
- name: Docker images caching - try 2
if: ${{ always() && steps.dock1.outcome == 'failure' }} #NOTE : this failure test could be replaced (or augmented) by a counting of kapua images in the environment. TODO if this check don't work on failure of previous cache retrieval
id: dock2
continue-on-error: true
uses: jpribyl/[email protected]
with:
key: ${{ inputs.key }}
restore-keys: ${{ inputs.restore-keys }}
skip-save: true
- name: retry-sleep-2
if: ${{ always() && steps.dock2.outcome == 'failure' }}
run: sleep 60
shell: bash
- name: Docker images caching - try 3
if: ${{ always() && steps.dock2.outcome == 'failure' }}
continue-on-error: true
id: dock3
uses: jpribyl/[email protected]
with:
key: ${{ inputs.key }}
restore-keys: ${{ inputs.restore-keys }}
skip-save: true
- name: build docker images #worst-case scenario fall-back, when cache cannot be retrieved
if: ${{ always() && steps.dock3.outcome == 'failure' }}
continue-on-error: true
id: buildDock
run: mvn clean install -pl ${APP_PROJECTS} && mvn clean install -Pdocker --f assembly/pom.xml
shell: bash
7 changes: 5 additions & 2 deletions .github/actions/runTestsTaggedAs/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ runs:
key: ${{ github.run_id }}-${{ github.run_number }}-maven-cache
- name: Docker images creation
if: ${{ inputs.needs-docker-images == 'true' }}
run: mvn clean install -pl ${APP_PROJECTS} && mvn clean install -Pdocker --f assembly/pom.xml
shell: bash
uses: ./.github/actions/cacheDockerRetry
with:
key: ${{ github.run_id }}-${{ github.run_number }}-docker-cache-{hash} # cache is valid only for current run on the current repository
restore-keys: |
${{ github.run_id }}-${{ github.run_number }}-docker-cache-
- name: Dns look-up containers needed for tests - message-broker
if: ${{ inputs.needs-docker-images == 'true' }}
run: echo "127.0.0.1 message-broker" | sudo tee -a /etc/hosts
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/kapua-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ jobs:
key: ${{ github.run_id }}-${{ github.run_number }}-maven-cache
- run: mvn -v
- run: docker images -a # used as log (should show only github environment standard docker images; if kapua images are present, something is wrong)
- run: mvn -B ${BUILD_OPTS} -DskipTests clean install
- run: docker rmi $(docker images -aq) # delete pre-existing images to speed up images caching
- uses: jpribyl/[email protected] # docker images cache
continue-on-error: true
with:
key: ${{ github.run_id }}-${{ github.run_number }}-docker-cache-{hash} # cache is valid only for current run on the current repository
restore-keys: |
${{ github.run_id }}-${{ github.run_number }}-docker-cache-
- run: mvn -B ${BUILD_OPTS} -Pdocker -DskipTests clean install
- run: bash <(curl -s https://codecov.io/bash)
test-brokerAcl:
needs: build
Expand Down