Skip to content

Commit

Permalink
load from cache on cheap instances
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch committed Jul 29, 2024
1 parent 01bcb57 commit 15716e6
Showing 1 changed file with 66 additions and 19 deletions.
85 changes: 66 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,39 @@ env:

jobs:

load-stellar-core-from-cache:
runs-on: ubuntu-latest
outputs:
cache-hit: ${{ steps.cache.outputs.cache-hit }}
steps:
- id: cache
uses: actions/cache@v3
with:
path: /tmp/image
key: image-stellar-core-${{ inputs.arch }}-${{ env.CORE_REPO_REF }}-${{ inputs.core_configure_flags }}
- name: Upload Stellar-Core Image
if: steps.cache.outputs.cache-hit == 'true' && inputs.arch == 'arm64'
uses: actions/upload-artifact@v4
with:
name: image-stellar-core-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/image

build-stellar-core:
needs: [load-stellar-core-from-cache]
if: ${{ needs.load-stellar-core-from-cache.outputs.cache-hit != 'true' }}
runs-on: ${{ inputs.arch == 'arm64' && 'ubuntu-jammy-4-cores-arm64' || 'ubuntu-latest' }}
steps:
- id: cache
uses: actions/cache@v3
with:
path: /tmp/image
key: image-stellar-core-${{ inputs.arch }}-${{ env.CORE_REPO_REF }}-${{ inputs.core_configure_flags }}
- if: steps.cache.outputs.cache-hit != 'true' && inputs.arch == 'arm64'
- if: inputs.arch == 'arm64'
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18
with:
platforms: arm64
- if: steps.cache.outputs.cache-hit != 'true'
uses: docker/setup-buildx-action@5146db6c4d81fbfd508899f851bbb3883a96ff9f
- if: steps.cache.outputs.cache-hit != 'true'
name: Build Stellar-Core Image
- uses: docker/setup-buildx-action@5146db6c4d81fbfd508899f851bbb3883a96ff9f
- name: Build Stellar-Core Image
run: >
docker buildx build --platform linux/${{ inputs.arch }}
-f docker/Dockerfile.testing -t stellar-core:${{ inputs.arch }}
Expand All @@ -99,8 +116,6 @@ jobs:
name: image-stellar-core-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/image

# don't use caches on horizon builds as the git ref for it can be a branch name that refers to
# different commits over time, cache key won't invalidate correctly.
build-stellar-horizon:
runs-on: ubuntu-latest
steps:
Expand All @@ -126,8 +141,6 @@ jobs:
name: image-stellar-horizon-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/image

# don't use caches on friendbot builds as the git ref for it can be a branch name that refers to
# different commits over time, cache key won't invalidate correctly.
build-stellar-friendbot:
runs-on: ubuntu-latest
steps:
Expand All @@ -150,22 +163,39 @@ jobs:
name: image-stellar-friendbot-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/image

load-stellar-soroban-rpc-from-cache:
runs-on: ubuntu-latest
outputs:
cache-hit: ${{ steps.cache.outputs.cache-hit }}
steps:
- id: cache
uses: actions/cache@v3
with:
path: /tmp/image
key: image-stellar-soroban-rpc-${{ inputs.arch }}-${{ env.SOROBAN_RPC_REPO_BRANCH }}
- name: Upload Stellar-Core Image
if: steps.cache.outputs.cache-hit == 'true' && inputs.arch == 'arm64'
uses: actions/upload-artifact@v4
with:
name: image-stellar-soroban-rpc-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/image

build-stellar-soroban-rpc:
needs: [load-stellar-soroban-rpc-from-cache]
if: ${{ needs.load-stellar-soroban-rpc-from-cache.outputs.cache-hit != 'true' }}
runs-on: ${{ inputs.arch == 'arm64' && 'ubuntu-jammy-4-cores-arm64' || 'ubuntu-latest' }}
steps:
- id: cache
uses: actions/cache@v3
with:
path: /tmp/image
key: image-stellar-soroban-rpc-${{ inputs.arch }}-${{ env.SOROBAN_RPC_REPO_BRANCH }}
- if: steps.cache.outputs.cache-hit != 'true' && inputs.arch == 'arm64'
- if: inputs.arch == 'arm64'
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18
with:
platforms: arm64
- if: steps.cache.outputs.cache-hit != 'true'
uses: docker/setup-buildx-action@5146db6c4d81fbfd508899f851bbb3883a96ff9f
- if: steps.cache.outputs.cache-hit != 'true'
name: Build Stellar-Soroban-Rpc Image
- uses: docker/setup-buildx-action@5146db6c4d81fbfd508899f851bbb3883a96ff9f
- name: Build Stellar-Soroban-Rpc Image
run: >
docker buildx build --platform linux/${{ inputs.arch }}
-f cmd/soroban-rpc/docker/Dockerfile --target build
Expand All @@ -179,7 +209,26 @@ jobs:
name: image-stellar-soroban-rpc-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/image

load-rs-stellar-xdr-from-cache:
runs-on: ubuntu-latest
outputs:
cache-hit: ${{ steps.cache.outputs.cache-hit }}
steps:
- id: cache
uses: actions/cache@v3
with:
path: /tmp/image
key: image-rs-stellar-xdr-${{ inputs.arch }}-${{ env.XDR_REPO_REF }}
- name: Upload Stellar-Core Image
if: steps.cache.outputs.cache-hit == 'true' && inputs.arch == 'arm64'
uses: actions/upload-artifact@v4
with:
name: image-rs-stellar-xdr-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/image

build-rs-stellar-xdr:
needs: [load-rs-stellar-xdr-from-cache]
if: ${{ needs.load-rs-stellar-xdr-from-cache.outputs.cache-hit != 'true' }}
runs-on: ${{ inputs.arch == 'arm64' && 'ubuntu-jammy-4-cores-arm64' || 'ubuntu-latest' }}
steps:
- name: Checkout Quickstart for Horizon docker file
Expand All @@ -191,14 +240,12 @@ jobs:
with:
path: /tmp/image
key: image-rs-stellar-xdr-${{ inputs.arch }}-${{ env.XDR_REPO_REF }}
- if: steps.cache.outputs.cache-hit != 'true' && inputs.arch == 'arm64'
- if: inputs.arch == 'arm64'
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18
with:
platforms: arm64
- if: steps.cache.outputs.cache-hit != 'true'
uses: docker/setup-buildx-action@5146db6c4d81fbfd508899f851bbb3883a96ff9f
- if: steps.cache.outputs.cache-hit != 'true'
name: Build Stellar-Rs-Xdr Image
- uses: docker/setup-buildx-action@5146db6c4d81fbfd508899f851bbb3883a96ff9f
- name: Build Stellar-Rs-Xdr Image
run: >
docker buildx build --platform linux/${{ inputs.arch }}
-f Dockerfile.xdr --target builder
Expand Down

0 comments on commit 15716e6

Please sign in to comment.