feat(ci): run cached state rebuilds in main branch (#4107)
* feat(ci): run cached state rebuilds in main branch * fix(ci): allow the PR/branch name in the disk name Move the hight information to the disk description, to reduce the name length * fix(ci): add missing SHA * fix(ci): regenerate chekpoint cached state on main This will automatically regenerate the disk when a merge is completed on main * tmp(ci): do not duplicate sync test at/after merge This temporarily ensure the test just runs in the main branch, ensuring we can track it easier
This commit is contained in:
parent
970f06d332
commit
04d52bfa3b
|
@ -27,6 +27,22 @@ on:
|
|||
# workflow definitions
|
||||
- 'docker/**'
|
||||
- '.github/workflows/test-full-sync.yml'
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
# code and tests (including full sync acceptance test changes)
|
||||
# TODO: ignore changes in test code that isn't used in the full sync test
|
||||
- '**/*.rs'
|
||||
# hard-coded checkpoints
|
||||
# TODO: ignore changes to proptest seed .txt files
|
||||
- '**/*.txt'
|
||||
# dependencies
|
||||
- '**/Cargo.toml'
|
||||
- '**/Cargo.lock'
|
||||
# workflow definitions
|
||||
- 'docker/**'
|
||||
- '.github/workflows/test-full-sync.yml'
|
||||
|
||||
env:
|
||||
CARGO_INCREMENTAL: '1'
|
||||
|
@ -45,9 +61,10 @@ env:
|
|||
|
||||
jobs:
|
||||
build:
|
||||
# TODO add `startsWith(github.head_ref, 'mergify/merge-queue/')` to the condition to
|
||||
# only run on Mergify head branches, and on manual dispatch:
|
||||
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-workflow-based-on-the-head-or-base-branch-of-a-pull-request-1
|
||||
if: startsWith(github.head_ref, 'mergify/merge-queue/') || github.event_name == 'workflow_dispatch'
|
||||
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
|
||||
name: Build images
|
||||
timeout-minutes: 210
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -257,12 +274,12 @@ jobs:
|
|||
# Force the image creation as the disk is still attached, even though is not being used by the container
|
||||
- name: Create image from state disk
|
||||
run: |
|
||||
gcloud compute images create zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-v${{ env.STATE_VERSION }}-${{ env.NETWORK }}-${{ env.SYNC_HEIGHT }}-tip \
|
||||
gcloud compute images create zebrad-cache-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}-v${{ env.STATE_VERSION }}-${{ env.NETWORK }}-tip \
|
||||
--force \
|
||||
--source-disk=full-sync-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
|
||||
--source-disk-zone=${{ env.ZONE }} \
|
||||
--storage-location=us \
|
||||
--description="Created from head branch ${{ env.GITHUB_HEAD_REF_SLUG_URL }} targeting ${{ env.GITHUB_BASE_REF_SLUG }} from PR ${{ env.GITHUB_REF_SLUG_URL }} with commit ${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA }}"
|
||||
--description="Created from commit ${{ env.GITHUB_SHA_SHORT }} with height ${{ env.SYNC_HEIGHT }}"
|
||||
|
||||
- name: Delete test instance
|
||||
# Do not delete the instance if the sync timeouts in GitHub
|
||||
|
|
|
@ -33,6 +33,23 @@ on:
|
|||
- 'docker/**'
|
||||
- '.github/workflows/test.yml'
|
||||
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
# code and tests
|
||||
- '**/*.rs'
|
||||
# hard-coded checkpoints and proptest regressions
|
||||
- '**/*.txt'
|
||||
# test data snapshots
|
||||
- '**/*.snap'
|
||||
# dependencies
|
||||
- '**/Cargo.toml'
|
||||
- '**/Cargo.lock'
|
||||
# workflow definitions
|
||||
- 'docker/**'
|
||||
- '.github/workflows/test.yml'
|
||||
|
||||
env:
|
||||
CARGO_INCREMENTAL: '1'
|
||||
ZEBRA_SKIP_IPV6_TESTS: '1'
|
||||
|
@ -263,7 +280,7 @@ jobs:
|
|||
# Check if our destination compute instance exists and delete it
|
||||
- name: Delete existing instance with same SHA
|
||||
id: delete-old-instance
|
||||
if: ${{ steps.changed-files-specific.outputs.any_changed == 'true' || github.event.inputs.regenerate-disks == 'true' }}
|
||||
if: ${{ steps.changed-files-specific.outputs.any_changed == 'true' || github.event.inputs.regenerate-disks == 'true' || github.event_name == 'push'}}
|
||||
run: |
|
||||
INSTANCE=$(gcloud compute instances list --filter=regenerate-disk-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} --format='value(NAME)')
|
||||
if [ -z "${INSTANCE}" ]; then
|
||||
|
@ -274,7 +291,7 @@ jobs:
|
|||
|
||||
- name: Create GCP compute instance
|
||||
id: create-instance
|
||||
if: ${{ steps.changed-files-specific.outputs.any_changed == 'true' || github.event.inputs.regenerate-disks == 'true' }}
|
||||
if: ${{ steps.changed-files-specific.outputs.any_changed == 'true' || github.event.inputs.regenerate-disks == 'true' || github.event_name == 'push'}}
|
||||
run: |
|
||||
gcloud compute instances create-with-container "regenerate-disk-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
|
||||
--boot-disk-size 100GB \
|
||||
|
@ -372,12 +389,12 @@ jobs:
|
|||
# Only run if the earlier step succeeds
|
||||
if: ${{ steps.sync-to-checkpoint.outcome == 'success' }}
|
||||
run: |
|
||||
gcloud compute images create zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-v${{ env.STATE_VERSION }}-${{ env.NETWORK }}-${{ env.SYNC_HEIGHT }}-checkpoint \
|
||||
gcloud compute images create zebrad-cache-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}-v${{ env.STATE_VERSION }}-${{ env.NETWORK }}-checkpoint \
|
||||
--force \
|
||||
--source-disk=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${{ env.NETWORK }}-checkpoint \
|
||||
--source-disk-zone=${{ env.ZONE }} \
|
||||
--storage-location=us \
|
||||
--description="Created from head branch ${{ env.GITHUB_HEAD_REF_SLUG_URL }} targeting ${{ env.GITHUB_BASE_REF_SLUG }} from PR ${{ env.GITHUB_REF_SLUG_URL }} with commit ${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA }}"
|
||||
--description="Created from commit ${{ env.GITHUB_SHA_SHORT }} with height ${{ env.SYNC_HEIGHT }}"
|
||||
|
||||
- name: Delete test instance
|
||||
# Do not delete the instance if the sync timeouts in GitHub
|
||||
|
|
Loading…
Reference in New Issue