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

Feat/revise GitHub docker cache images #584

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4b8f03c
feat: added gauge metrics for batch, blob, aggregation size
jonesho Jan 20, 2025
ab80c05
feat: upgrade actions/cache save and restore to 4.2.0
jonesho Jan 21, 2025
8f10375
feat: add secret inherit for transaction-exclusion-api
jonesho Jan 21, 2025
1788447
feat: revert to include cache-docker-images job in coordinator-testin…
jonesho Jan 21, 2025
e68bf18
feat: move cache-docker-images out from coordinator-testing and state…
jonesho Jan 21, 2025
19e9c73
feat: text changes for testing
jonesho Jan 21, 2025
0bdc2ab
feat: set restore-keys as cached-images
jonesho Jan 21, 2025
802dc40
feat: add step to create directory for cached docker images
jonesho Jan 21, 2025
380fc22
feat: change cache dir from ~/docker-images to ./docker-images
jonesho Jan 21, 2025
87dddf2
feat: change actions cache version and keys
jonesho Jan 21, 2025
b2d81c7
fix: cache-docker-images folder name
jonesho Jan 21, 2025
25d5f64
feat: temp disable cache-docker-images
jonesho Jan 21, 2025
f232c4a
feat: makeover with cache-docker-images and restore-cached-images
jonesho Jan 21, 2025
45a27ad
feat: put restore-cached-images in actions folder
jonesho Jan 21, 2025
1476117
feat: change runner for save cache step and revise hash
jonesho Jan 22, 2025
10536a7
feat: testing with diff cache path
jonesho Jan 22, 2025
8d07d11
feat: testing with diff hash
jonesho Jan 22, 2025
730d601
feat: testing with original runner
jonesho Jan 22, 2025
33bd01f
feat: added composite action for Compute Docker Images Hash
jonesho Jan 22, 2025
7579c42
feat: remove action permissions and use cache restore
jonesho Jan 22, 2025
7cbf625
Revert "feat: added gauge metrics for batch, blob, aggregation size"
jonesho Jan 22, 2025
af9aa60
feat: removed internal built images from cache
jonesho Jan 22, 2025
b7fa2c2
feat: fix docker_images_unique command line
jonesho Jan 22, 2025
7433a00
feat: fix docker_images_unique command line
jonesho Jan 22, 2025
1eba9d5
feat: fix docker_images_unique command line
jonesho Jan 22, 2025
ab3e2c0
feat: add name for pull-and-cache-images
jonesho Jan 22, 2025
b118ff9
feat: update cache docker image list with those from traces-v1
jonesho Jan 22, 2025
4aaddbc
feat: move cache-docker-images to main workflow
jonesho Jan 22, 2025
ef72a53
feat: move cache-docker-images back to testing workflow
jonesho Jan 23, 2025
dd641da
feat: remove leftover outputs in reuse-images-tags-and-push-workflow
jonesho Jan 23, 2025
69928e5
feat: bump to exact version for actions/cache
jonesho Jan 23, 2025
96a7a26
feat: temp disable cache for docker images
jonesho Jan 23, 2025
2b10d35
feat: add more detailed comments
jonesho Jan 24, 2025
284d38f
feat:remove unnecessary exception import
jonesho Jan 24, 2025
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
35 changes: 35 additions & 0 deletions .github/actions/compute-docker-images-hash/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 'Compute Docker Images Hash'
description: 'Compute Docker Images Hash for Cache Key'

outputs:
docker_images_hash:
description: 'Docker Images Hash'
value: ${{ steps.compute-docker-images-hash.outputs.DOCKER_IMAGES_HASH }}
docker_images_trimmed:
description: 'Trimmed List of Docker Images'
value: ${{ steps.compute-docker-images-hash.outputs.DOCKER_IMAGES_TRIMMED }}

runs:
using: 'composite'
steps:
- name: Compute docker images hash
id: compute-docker-images-hash
shell: bash
run: |
docker_images_traces_v1=$(docker compose -f docker/compose.yml -f docker/compose-local-dev.overrides.yml --profile l1 --profile l2 config 2>/dev/null | grep "image:" | awk '{print $2}')
docker_images_traces_v2=$(docker compose -f docker/compose.yml -f docker/compose-local-dev-traces-v2.overrides.yml --profile l1 --profile l2 config 2>/dev/null | grep "image:" | awk '{print $2}')
docker_images=$(echo "$docker_images_traces_v1 $docker_images_traces_v2")
docker_images_unique=$(echo $docker_images | xargs -n1 | sort -u)
docker_images_trimmed=$(echo $docker_images_unique | xargs -n1 | grep -Ev "linea-postman|linea-coordinator|linea-transaction-exclusion-api|linea-traces-api-facade|linea-prover" | xargs)
echo DOCKER_IMAGES=$(echo $docker_images) >> $GITHUB_OUTPUT
echo DOCKER_IMAGES_UNIQUE=$(echo $docker_images_unique) >> $GITHUB_OUTPUT
echo DOCKER_IMAGES_TRIMMED=$(echo $docker_images_trimmed) >> $GITHUB_OUTPUT
echo DOCKER_IMAGES_HASH=$(echo -n $docker_images_trimmed | sha256sum | awk '{print $1}') >> $GITHUB_OUTPUT
- name: Show docker images hash
shell: bash
id: show-docker-images-hash
run: |
echo "DOCKER_IMAGES: ${{ steps.compute-docker-images-hash.outputs.DOCKER_IMAGES }}"
echo "DOCKER_IMAGES_UNIQUE: ${{ steps.compute-docker-images-hash.outputs.DOCKER_IMAGES_UNIQUE }}"
echo "DOCKER_IMAGES_TRIMMED: ${{ steps.compute-docker-images-hash.outputs.DOCKER_IMAGES_TRIMMED }}"
echo "DOCKER_IMAGES_HASH: ${{ steps.compute-docker-images-hash.outputs.DOCKER_IMAGES_HASH }}"
25 changes: 25 additions & 0 deletions .github/actions/restore-docker-images/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Restore Cached Docker Images'
description: 'Restore Cached Docker Images'

runs:
using: 'composite'
steps:
- name: Compute docker images hash
id: compute-docker-images-hash
uses: ./.github/actions/compute-docker-images-hash
- name: Create cached docker images folder
shell: bash
run: |
mkdir -p ~/docker-images-cached
- name: Cache common docker images
id: cache-common-docker-images
continue-on-error: true
uses: actions/cache/[email protected]
with:
path: ~/docker-images-cached
key: docker-images-cache-${{ steps.compute-docker-images-hash.outputs.docker_images_hash }}
- name: Load docker images
shell: bash
if: steps.cache-common-docker-images.outputs.cache-hit == 'true'
run: |
docker load -i ~/docker-images-cached/docker-images.tar
37 changes: 21 additions & 16 deletions .github/workflows/cache-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,35 @@ jobs:
needs: [ check-dockerhub-secrets-present, changes ]
if: ${{ always() && needs.check-dockerhub-secrets-present.outputs.secrets_present == 'true' && needs.changes.outputs.cache_images == 'true' }}
runs-on: gha-runner-scale-set-ubuntu-22.04-amd64-med
name: Pull and cache images
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Compute docker images hash
id: compute-docker-images-hash
uses: ./.github/actions/compute-docker-images-hash
- name: Create cached docker images folder
run: |
mkdir -p ~/docker-images-cached
- name: Cache common docker images
id: cache-common-docker-images
uses: actions/[email protected]
with:
path: ~/docker-images-cached
key: docker-images-cache-${{ steps.compute-docker-images-hash.outputs.docker_images_hash }}
lookup-only: true
- name: Login to Docker Hub
if: steps.cache-common-docker-images.outputs.cache-hit != 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Pull docker images from compose
continue-on-error: true
- name: Pull docker images
if: steps.cache-common-docker-images.outputs.cache-hit != 'true'
run: |
docker compose -f docker/compose.yml -f docker/compose-local-dev-traces-v2.overrides.yml --profile l1 --profile l2 pull
- name: Save Docker images
- name: Cache docker images
if: steps.cache-common-docker-images.outputs.cache-hit != 'true'
run: |
mkdir -p ~/docker-images
images=$(docker compose -f docker/compose.yml -f docker/compose-local-dev-traces-v2.overrides.yml --profile l1 --profile l2 config | grep "image:" | awk '{print $2}')
for image in $images; do
imageFileName=$(echo $image | sed -e 's|.*/||' -e 's|:|-|' -e 's/\./_/g')
echo $image - ${imageFileName}
docker save $image > ~/docker-images/${imageFileName}.tar
done
- name: Cache common docker images
continue-on-error: true
uses: actions/cache/[email protected]
with:
path: ~/docker-images
key: cached-images
docker save ${{ steps.compute-docker-images-hash.outputs.docker_images_trimmed }} -o ~/docker-images-cached/docker-images.tar
echo docker-images.tar=$(ls -lh ~/docker-images-cached/docker-images.tar)
17 changes: 6 additions & 11 deletions .github/workflows/coordinator-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
cache-docker-images:
uses: ./.github/workflows/cache-docker-images.yml
secrets: inherit
run-tests:
env:
COMMIT_TAG: ${{ inputs.commit_tag }}
Expand All @@ -40,14 +37,12 @@ jobs:
# Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 #v4.2.1
- name: Restore cached images
id: restore-cached-images
uses: actions/cache/[email protected]
with:
path: ~/docker-images
key: cached-images
restore-keys: |
cached-images
# Disable cache for pulling docker images as empirically found that this
# (retrieving cache and loading docker images) actually increased test time-to-completion
# - name: Restore cached images
# id: restore-cached-images
# uses: ./.github/actions/restore-docker-images
# continue-on-error: true
# Install pnpm to compile smart contracts
- name: Setup nodejs environment
uses: ./.github/actions/setup-nodejs
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/reuse-check-images-tags-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,10 @@ jobs:
name: Check image tags exist
outputs:
last_commit_tag_exists_coordinator: ${{ steps.check_image_tags_exist_coordinator.outputs.last_commit_tag_exists }}
common_ancestor_commit_tag_exists_coordinator: ${{ steps.check_image_tags_exist_coordinator.outputs.common_ancestor_commit_tag_exists }}
last_commit_tag_exists_postman: ${{ steps.check_image_tags_exist_postman.outputs.last_commit_tag_exists }}
common_ancestor_commit_tag_exists_postman: ${{ steps.check_image_tags_exist_postman.outputs.common_ancestor_commit_tag_exists }}
last_commit_tag_exists_prover: ${{ steps.check_image_tags_exist_prover.outputs.last_commit_tag_exists }}
common_ancestor_commit_tag_exists_prover: ${{ steps.check_image_tags_exist_prover.outputs.common_ancestor_commit_tag_exists }}
last_commit_tag_exists_traces_api_facade: ${{ steps.check_image_tags_exist_traces_api_facade.outputs.last_commit_tag_exists }}
common_ancestor_commit_tag_exists_traces_api_facade: ${{ steps.check_image_tags_exist_traces_api_facade.outputs.common_ancestor_commit_tag_exists }}
last_commit_tag_exists_transaction_exclusion_api: ${{ steps.check_image_tags_exist_transaction_exclusion_api.outputs.last_commit_tag_exists }}
common_ancestor_commit_tag_exists_transaction_exclusion_api: ${{ steps.check_image_tags_exist_transaction_exclusion_api.outputs.common_ancestor_commit_tag_exists }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/reuse-run-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,12 @@ jobs:
run: |
mkdir -p tmp/local/traces/v2/conflated
chmod -R a+w tmp/local/traces/v2/conflated
- name: Restore cached images
id: restore-cached-images
uses: actions/cache/[email protected]
with:
path: ~/docker-images
key: cached-images
restore-keys: |
cached-
# Disable cache for pulling docker images as empirically found that this
# (retrieving cache and loading docker images) actually increased test time-to-completion
# - name: Restore cached images
# id: restore-cached-images
# uses: ./.github/actions/restore-docker-images
# continue-on-error: true
- name: Pull all images with retry
uses: nick-fields/retry@v3
with:
Expand Down
20 changes: 7 additions & 13 deletions .github/workflows/staterecovery-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
cache-docker-images:
uses: ./.github/workflows/cache-docker-images.yml
secrets: inherit
run-tests:
env:
COMMIT_TAG: ${{ inputs.commit_tag }}
GITHUB_TOKEN: ${{ secrets._GITHUB_TOKEN_RELEASE_ACCESS }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# ~2.5 mins saved vs large
runs-on: gha-runner-scale-set-ubuntu-22.04-amd64-xl
name: Staterecovery tests
Expand All @@ -41,14 +37,12 @@ jobs:
# Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 #v4.2.1
- name: Restore cached images
id: restore-cached-images
uses: actions/cache/[email protected]
with:
path: ~/docker-images
key: cached-images
restore-keys: |
cached-images
# Disable cache for pulling docker images as empirically found that this
# (retrieving cache and loading docker images) actually increased test time-to-completion
# - name: Restore cached images
# id: restore-cached-images
# uses: ./.github/actions/restore-docker-images
# continue-on-error: true
- name: Staterecovery - Build and Unit tests
run: |
./gradlew state-recovery:besu-plugin:buildNeeded
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ on:
type: string

jobs:
# Disable cache for pulling docker images as empirically found that this
# (retrieving cache and loading docker images) actually increased test time-to-completion
# cache-docker-images:
# uses: ./.github/workflows/cache-docker-images.yml
# secrets: inherit

coordinator:
# needs: [ cache-docker-images ]
uses: ./.github/workflows/coordinator-testing.yml
if: ${{ inputs.coordinator_changed == 'true' }}
with:
Expand All @@ -50,8 +57,10 @@ jobs:
transaction-exclusion-api:
uses: ./.github/workflows/transaction-exclusion-api-testing.yml
if: ${{ inputs.transaction_exclusion_api_changed == 'true' }}
secrets: inherit

staterecovery:
# needs: [ cache-docker-images ]
uses: ./.github/workflows/staterecovery-testing.yml
if: ${{ inputs.staterecovery_changed == 'true' }}
with:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/transaction-exclusion-api-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: transaction-exclusion-api-testing

on:
workflow_call:
secrets:
DOCKERHUB_USERNAME:
required: false
DOCKERHUB_TOKEN:
required: false
workflow_dispatch:
inputs:
coverage:
Expand All @@ -16,6 +21,9 @@ concurrency:

jobs:
run-tests:
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
# ~1.5 mins saved vs small
runs-on: gha-runner-scale-set-ubuntu-22.04-amd64-med
name: Transaction exclusion api tests
Expand All @@ -36,6 +44,12 @@ jobs:
if: ${{ !inputs.coverage }}
run: |
./gradlew transaction-exclusion-api:app:buildNeeded
- name: Login to Docker Hub
if: ${{ env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != '' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run integration tests
run: |
./gradlew transaction-exclusion-api:app:integrationTestAllNeeded
2 changes: 1 addition & 1 deletion docker/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ networks:
config:
- subnet: 10.10.10.0/24

# To debug inside the network and volumes
# To debug inside the network and volumes:
# docker run --rm -it --network=docker_linea -v=linea-local-dev:/data -v=linea-logs:/logs weibeld/ubuntu-networking bash

services:
Expand Down
Loading