Skip to content

Commit

Permalink
ci: Shift (Docker) cache priming to request workflow (#37028)
Browse files Browse the repository at this point in the history
Currently all triggered CI jobs check for required caches (and prime
where required)

This reduces the number of vms that get booted by checking once at the
beginning of a run in the request phase

Signed-off-by: Ryan Northey <[email protected]>
  • Loading branch information
phlax authored Nov 8, 2024
1 parent 232c19e commit 46b954c
Show file tree
Hide file tree
Showing 23 changed files with 109 additions and 86 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/_load.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,11 @@ on:
required: true
app-key:
required: true
lock-app-id:
required: true
lock-app-key:
required: true

inputs:
agent-ubuntu:
type: string
default: ubuntu-22.04
cache-docker:
type: boolean
default: true
check-name:
type: string
required: true
Expand Down Expand Up @@ -168,30 +161,3 @@ jobs:
| .summary = {title: .summary_title}
| del(.request.message, .summary_title)
print-result: ${{ fromJSON(env.CI_DEBUG || 'false') && true || false }}

cache:
secrets:
app-id: ${{ secrets.lock-app-id }}
app-key: ${{ secrets.lock-app-key }}
name: ${{ matrix.name || matrix.target }}
needs: request
uses: ./.github/workflows/_cache.yml
if: ${{ inputs.cache-docker && ! fromJSON(needs.request.outputs.skip) }}
with:
arch: ${{ matrix.arch }}
cache-suffix: ${{ matrix.cache-suffix }}
image-tag: ${{ fromJSON(needs.request.outputs.build-image).default }}
request: ${{ toJSON(needs.request.outputs) }}
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
include:
- target: docker-x64
name: Docker (x64)
arch: x64
- target: docker-arm64
name: Docker (arm64)
arch: arm64
cache-suffix: -arm64
runs-on: envoy-arm64-small
2 changes: 1 addition & 1 deletion .github/workflows/_load_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
secrets:
app-id: ${{ secrets.lock-app-id }}
app-key: ${{ secrets.lock-app-key }}
uses: ./.github/workflows/_cache.yml
uses: ./.github/workflows/_request_cache_docker.yml
needs: request
if: ${{ inputs.cache-docker }}
with:
Expand Down
44 changes: 43 additions & 1 deletion .github/workflows/_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
required: true
app-key:
required: true
lock-app-id:
required: true
lock-app-key:
required: true

# Defaults are set .github/config.yml on the `main` branch.
inputs:
Expand Down Expand Up @@ -38,6 +42,7 @@ jobs:
pull-requests: read
outputs:
env: ${{ steps.data.outputs.value }}
caches: ${{ steps.caches.outputs.value }}
config: ${{ steps.config.outputs.config }}
steps:
- uses: envoyproxy/toolshed/gh-actions/[email protected]
Expand Down Expand Up @@ -69,6 +74,7 @@ jobs:
started: ${{ steps.started.outputs.value }}
token: ${{ secrets.GITHUB_TOKEN }}
vars: ${{ toJSON(vars) }}

- name: Request summary
id: summary
uses: envoyproxy/toolshed/gh-actions/github/env/[email protected]
Expand Down Expand Up @@ -101,7 +107,7 @@ jobs:
| .env.config.envoy.icon as $icon
| .link as $link
| "\($icon) Request ([\($title)](\($link)))" as $linkedTitle
| .summary as $summary
| .summary as $summary
| .env
| .summary = {
$summary,
Expand All @@ -110,6 +116,42 @@ jobs:
"linked-title": $linkedTitle}
| del(.config.tables)
- name: Check Docker cache (x64)
id: cache-exists-docker-x64
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
lookup-only: true
path: /tmp/cache
key: ${{ fromJSON(steps.data.outputs.value).request.build-image.default }}
- name: Check Docker cache (arm64)
id: cache-exists-docker-arm64
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
lookup-only: true
path: /tmp/cache
key: ${{ fromJSON(steps.data.outputs.value).request.build-image.default }}-arm64

- name: Caches
uses: envoyproxy/toolshed/gh-actions/[email protected]
id: caches
with:
input-format: yaml
input: |
docker:
x64: ${{ steps.cache-exists-docker-x64.outputs.cache-hit || 'false' }}
arm64: ${{ steps.cache-exists-docker-arm64.outputs.cache-hit || 'false' }}
cache:
if: ${{ github.repository == 'envoyproxy/envoy' || vars.ENVOY_CI }}
needs: incoming
uses: ./.github/workflows/_request_cache.yml
secrets:
app-id: ${{ secrets.lock-app-id }}
app-key: ${{ secrets.lock-app-key }}
with:
caches: ${{ needs.incoming.outputs.caches }}
env: ${{ needs.incoming.outputs.env }}

checks:
if: ${{ github.repository == 'envoyproxy/envoy' || vars.ENVOY_CI }}
needs: incoming
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/_request_cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Request/cache

permissions:
contents: read

on:
workflow_call:
secrets:
app-id:
required: true
app-key:
required: true

inputs:
env:
type: string
required: true
caches:
type: string
required: true


jobs:
docker:
secrets:
app-id: ${{ secrets.app-id }}
app-key: ${{ secrets.app-key }}
name: Docker/${{ matrix.arch }}
uses: ./.github/workflows/_request_cache_docker.yml
with:
arch: ${{ matrix.arch }}
cache-suffix: ${{ matrix.cache-suffix }}
caches: ${{ inputs.caches }}
image-tag: ${{ fromJSON(inputs.env).request.build-image.default }}
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
include:
- target: docker-x64
arch: x64
- target: docker-arm64
arch: arm64
cache-suffix: -arm64
runs-on: envoy-arm64-small
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Cache prime (docker)
name: Request/cache (prime Docker)

permissions:
contents: read
Expand All @@ -11,18 +11,19 @@ on:
app-key:
required: true
inputs:
caches:
type: string
required: true
image-tag:
type: string
required: true

arch:
type: string
default: x64
cache-suffix:
type: string
default:
image-tag:
type: string
required: true
request:
type: string
required: true
runs-on:
type: string
default: ubuntu-24.04
Expand All @@ -47,6 +48,8 @@ on:
jobs:
docker:
runs-on: ${{ inputs.runs-on || 'ubuntu-24.04' }}
name: "[${{ inputs.arch }}] Prime Docker cache"
if: ${{ ! fromJSON(inputs.caches).docker[inputs.arch] }}
steps:
- uses: envoyproxy/toolshed/gh-actions/[email protected]
id: appauth
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ jobs:
"runs-on": $runsOn,
"job-started": ${{ steps.started.outputs.value }}}
| . * {$config, $check}
- if: ${{ inputs.cache-build-image }}
name: Restore Docker cache ${{ inputs.cache-build-image && format('({0})', inputs.cache-build-image) || '' }}
uses: envoyproxy/toolshed/gh-actions/docker/cache/[email protected]
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/envoy-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ jobs:
secrets:
app-key: ${{ secrets.ENVOY_CI_APP_KEY }}
app-id: ${{ secrets.ENVOY_CI_APP_ID }}
lock-app-key: ${{ secrets.ENVOY_CI_MUTEX_APP_KEY }}
lock-app-id: ${{ secrets.ENVOY_CI_MUTEX_APP_ID }}
permissions:
actions: read
contents: read
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/envoy-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
secrets:
app-key: ${{ secrets.ENVOY_CI_APP_KEY }}
app-id: ${{ secrets.ENVOY_CI_APP_ID }}
lock-app-key: ${{ secrets.ENVOY_CI_MUTEX_APP_KEY }}
lock-app-id: ${{ secrets.ENVOY_CI_MUTEX_APP_ID }}
permissions:
actions: read
contents: read
Expand All @@ -35,7 +33,6 @@ jobs:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: ./.github/workflows/_load.yml
with:
cache-docker: false
check-name: macos

macos:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/envoy-prechecks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ jobs:
secrets:
app-key: ${{ secrets.ENVOY_CI_APP_KEY }}
app-id: ${{ secrets.ENVOY_CI_APP_ID }}
lock-app-key: ${{ secrets.ENVOY_CI_MUTEX_APP_KEY }}
lock-app-id: ${{ secrets.ENVOY_CI_MUTEX_APP_ID }}
permissions:
actions: read
contents: read
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/envoy-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ jobs:
secrets:
app-key: ${{ secrets.ENVOY_CI_APP_KEY }}
app-id: ${{ secrets.ENVOY_CI_APP_ID }}
lock-app-key: ${{ secrets.ENVOY_CI_MUTEX_APP_KEY }}
lock-app-id: ${{ secrets.ENVOY_CI_MUTEX_APP_ID }}
permissions:
actions: read
contents: read
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/mobile-android_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
secrets:
app-key: ${{ secrets.ENVOY_CI_APP_KEY }}
app-id: ${{ secrets.ENVOY_CI_APP_ID }}
lock-app-key: ${{ secrets.ENVOY_CI_MUTEX_APP_KEY }}
lock-app-id: ${{ secrets.ENVOY_CI_MUTEX_APP_ID }}
permissions:
actions: read
contents: read
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/mobile-android_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
secrets:
app-key: ${{ secrets.ENVOY_CI_APP_KEY }}
app-id: ${{ secrets.ENVOY_CI_APP_ID }}
lock-app-key: ${{ secrets.ENVOY_CI_MUTEX_APP_KEY }}
lock-app-id: ${{ secrets.ENVOY_CI_MUTEX_APP_ID }}
permissions:
actions: read
contents: read
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/mobile-asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
secrets:
app-key: ${{ secrets.ENVOY_CI_APP_KEY }}
app-id: ${{ secrets.ENVOY_CI_APP_ID }}
lock-app-key: ${{ secrets.ENVOY_CI_MUTEX_APP_KEY }}
lock-app-id: ${{ secrets.ENVOY_CI_MUTEX_APP_ID }}
permissions:
actions: read
contents: read
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/mobile-cc_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
secrets:
app-key: ${{ secrets.ENVOY_CI_APP_KEY }}
app-id: ${{ secrets.ENVOY_CI_APP_ID }}
lock-app-key: ${{ secrets.ENVOY_CI_MUTEX_APP_KEY }}
lock-app-id: ${{ secrets.ENVOY_CI_MUTEX_APP_ID }}
permissions:
actions: read
contents: read
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/mobile-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
secrets:
app-key: ${{ secrets.ENVOY_CI_APP_KEY }}
app-id: ${{ secrets.ENVOY_CI_APP_ID }}
lock-app-key: ${{ secrets.ENVOY_CI_MUTEX_APP_KEY }}
lock-app-id: ${{ secrets.ENVOY_CI_MUTEX_APP_ID }}
permissions:
actions: read
contents: read
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/mobile-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
secrets:
app-key: ${{ secrets.ENVOY_CI_APP_KEY }}
app-id: ${{ secrets.ENVOY_CI_APP_ID }}
lock-app-key: ${{ secrets.ENVOY_CI_MUTEX_APP_KEY }}
lock-app-id: ${{ secrets.ENVOY_CI_MUTEX_APP_ID }}
permissions:
actions: read
contents: read
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/mobile-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
secrets:
app-key: ${{ secrets.ENVOY_CI_APP_KEY }}
app-id: ${{ secrets.ENVOY_CI_APP_ID }}
lock-app-key: ${{ secrets.ENVOY_CI_MUTEX_APP_KEY }}
lock-app-id: ${{ secrets.ENVOY_CI_MUTEX_APP_ID }}
permissions:
actions: read
contents: read
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/mobile-ios_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
secrets:
app-key: ${{ secrets.ENVOY_CI_APP_KEY }}
app-id: ${{ secrets.ENVOY_CI_APP_ID }}
lock-app-key: ${{ secrets.ENVOY_CI_MUTEX_APP_KEY }}
lock-app-id: ${{ secrets.ENVOY_CI_MUTEX_APP_ID }}
permissions:
actions: read
contents: read
Expand All @@ -35,7 +33,6 @@ jobs:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: ./.github/workflows/_load.yml
with:
cache-docker: false
check-name: mobile-ios

build:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/mobile-ios_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
secrets:
app-key: ${{ secrets.ENVOY_CI_APP_KEY }}
app-id: ${{ secrets.ENVOY_CI_APP_ID }}
lock-app-key: ${{ secrets.ENVOY_CI_MUTEX_APP_KEY }}
lock-app-id: ${{ secrets.ENVOY_CI_MUTEX_APP_ID }}
permissions:
actions: read
contents: read
Expand All @@ -35,7 +33,6 @@ jobs:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: ./.github/workflows/_load.yml
with:
cache-docker: false
check-name: mobile-ios-tests

tests:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/mobile-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
secrets:
app-key: ${{ secrets.ENVOY_CI_APP_KEY }}
app-id: ${{ secrets.ENVOY_CI_APP_ID }}
lock-app-key: ${{ secrets.ENVOY_CI_MUTEX_APP_KEY }}
lock-app-id: ${{ secrets.ENVOY_CI_MUTEX_APP_ID }}
permissions:
actions: read
contents: read
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/mobile-release_validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
secrets:
app-key: ${{ secrets.ENVOY_CI_APP_KEY }}
app-id: ${{ secrets.ENVOY_CI_APP_ID }}
lock-app-key: ${{ secrets.ENVOY_CI_MUTEX_APP_KEY }}
lock-app-id: ${{ secrets.ENVOY_CI_MUTEX_APP_ID }}
permissions:
actions: read
contents: read
Expand All @@ -35,7 +33,6 @@ jobs:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: ./.github/workflows/_load.yml
with:
cache-docker: false
check-name: mobile-release-validation

validate-swiftpm-example:
Expand Down
Loading

0 comments on commit 46b954c

Please sign in to comment.