Skip to content

Commit

Permalink
ci(sync): only run the lightwalletd full sync on the main branch (#…
Browse files Browse the repository at this point in the history
…5393)

* ci(sync): only run the `lightwalletd` full sync on the `main` branch

Previous behavior:
In PR #5164, we made lightwalletd sync all the way to the tip in its full
sync test.

This increases that test's time from 1 hour to 4 hours, which makes the CI
we run on each PR change increase from 3 hours to 6 hours.

Expected behavior:
Run the lightwalletd full sync just on `main` or if a state disk for the
actual version is not found.

Solution:
Add the `github.event_name == 'push' && github.ref_name == 'main'` condition
to the `lightwalletd-full-sync` test.

Fixes #5316

* Allow lwd full syncs to be triggered manually (#5400)

* Limit checkpoint and lwd full sync concurrency

* Add a patch job for lightwalletd-full-sync

Co-authored-by: teor <[email protected]>
  • Loading branch information
gustavovalverde and teor2345 authored Oct 19, 2022
1 parent d81a5fc commit dae1d92
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 22 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/continous-integration-docker.patch-always.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# These jobs can be skipped based on cached Google Cloud state disks,
# so they always need to run on every PR.
#
# TODO: when we refactor checking disks into a re-usable workflow,
# call it here, and patch if the disks *are* available
# and some of them just run on the `main` branch,
# so the patch jobs always need to run on every PR.
name: CI Docker

on:
Expand All @@ -20,3 +18,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- run: 'echo "No build required"'

lightwalletd-full-sync:
name: lightwalletd tip / Run lightwalletd-full-sync test
runs-on: ubuntu-latest
steps:
- run: 'echo "No build required"'
59 changes: 41 additions & 18 deletions .github/workflows/continous-integration-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ on:
regenerate-disks:
type: boolean
default: false
description: 'Just update mandatory checkpoint disks'
description: 'Just run a Zebra checkpoint sync and update checkpoint disks'
required: true
run-full-sync:
type: boolean
default: false
description: 'Just run a full sync and update tip disks'
description: 'Just run a Zebra full sync and update tip disks'
required: true
run-lwd-sync:
type: boolean
default: false
description: 'Just run a lightwalletd full sync and update tip disks'
required: true


pull_request:
paths:
# code and tests
Expand Down Expand Up @@ -179,7 +185,7 @@ jobs:
name: Test all
runs-on: ubuntu-latest
needs: build
if: ${{ github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' }}
if: ${{ github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' && github.event.inputs.run-lwd-sync != 'true' }}
steps:
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
Expand All @@ -204,7 +210,7 @@ jobs:
name: Test with fake activation heights
runs-on: ubuntu-latest
needs: build
if: ${{ github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' }}
if: ${{ github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' && github.event.inputs.run-lwd-sync != 'true' }}
steps:
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
Expand All @@ -225,7 +231,7 @@ jobs:
name: Test checkpoint sync from empty state
runs-on: ubuntu-latest
needs: build
if: ${{ github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' }}
if: ${{ github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' && github.event.inputs.run-lwd-sync != 'true' }}
steps:
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
Expand All @@ -244,7 +250,7 @@ jobs:
name: Test integration with lightwalletd
runs-on: ubuntu-latest
needs: build
if: ${{ github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' }}
if: ${{ github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' && github.event.inputs.run-lwd-sync != 'true' }}
steps:
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
Expand Down Expand Up @@ -281,6 +287,14 @@ jobs:
saves_to_disk: true
disk_suffix: checkpoint
height_grep_text: 'flushing database to disk .*height.*=.*Height.*\('
# We want to prevent multiple checkpoint syncs running at the same time,
# but we don't want to cancel running syncs on `main` if a new PR gets merged,
# because we might never get a finished sync.
#
# See the concurrency comment on the zebrad test-full-sync job for details.
concurrency:
group: ${{ github.workflow }}−${{ github.ref }}-regenerate-stateful-disks
cancel-in-progress: false

# Test that Zebra syncs and fully validates a few thousand blocks from a cached mandatory checkpoint disk
#
Expand All @@ -290,7 +304,7 @@ jobs:
name: Zebra checkpoint update
needs: regenerate-stateful-disks
uses: ./.github/workflows/deploy-gcp-tests.yml
if: ${{ !cancelled() && !failure() && github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' }}
if: ${{ !cancelled() && !failure() && github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' && github.event.inputs.run-lwd-sync != 'true' }}
with:
app_name: zebrad
test_id: sync-past-checkpoint
Expand Down Expand Up @@ -328,17 +342,19 @@ jobs:
saves_to_disk: true
disk_suffix: tip
height_grep_text: 'current_height.*=.*Height.*\('
# We don't want to cancel running full syncs on `main` if a new PR gets merged,
# because we might never finish a full sync during busy weeks. Instead, we let the
# first sync complete, then queue the latest pending sync, cancelling any syncs in between.
# We want to prevent multiple full zebrad syncs running at the same time,
# but we don't want to cancel running syncs on `main` if a new PR gets merged,
# because we might never get a finished sync.
#
# Instead, we let the first sync complete, then queue the latest pending sync, cancelling any syncs in between.
# (As the general workflow concurrency group just gets matched in Pull Requests,
# it has no impact on this job.)
#
# TODO:
# - allow multiple manual syncs on a branch, and isolate manual syncs from automatic syncs, by adding '-${{ github.run_id }}' when github.event.inputs.run-full-sync is true
# - stop multiple automatic full syncs across different PRs by removing '−${{ github.ref }}' when needs.get-available-disks.outputs.zebra_tip_disk is true
concurrency:
group: ${{ github.workflow }}−${{ github.ref }}
group: ${{ github.workflow }}−${{ github.ref }}-test-full-sync
cancel-in-progress: false

# Test that Zebra can sync to the chain tip, using a cached Zebra tip state,
Expand All @@ -354,7 +370,7 @@ jobs:
name: Zebra tip update
needs: test-full-sync
uses: ./.github/workflows/deploy-gcp-tests.yml
if: ${{ !cancelled() && !failure() && github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' }}
if: ${{ !cancelled() && !failure() && github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' && github.event.inputs.run-lwd-sync != 'true' }}
with:
app_name: zebrad
test_id: update-to-tip
Expand All @@ -374,7 +390,6 @@ jobs:
#
# Runs:
# - after every PR is merged to `main`
# - on every PR update
#
# If the state version has changed, waits for the new cached state to be created.
# Otherwise, if the state rebuild was skipped, runs immediately after the build job.
Expand All @@ -385,7 +400,7 @@ jobs:
# to also run on Mergify head branches,
# add `|| (github.event_name == 'push' && startsWith(github.head_ref, 'mergify/merge-queue/'))`:
# 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: ${{ (!cancelled() && !failure() && github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true') || !fromJSON(needs.get-available-disks.outputs.lwd_tip_disk) }}
if: ${{ !cancelled() && !failure() && ((github.event_name == 'push' && github.ref_name == 'main') || !fromJSON(needs.get-available-disks.outputs.lwd_tip_disk) || github.event.inputs.run-lwd-sync == 'true' ) }}
with:
app_name: lightwalletd
test_id: lwd-full-sync
Expand All @@ -400,6 +415,14 @@ jobs:
zebra_state_dir: 'zebrad-cache'
lwd_state_dir: 'lwd-cache'
height_grep_text: '(current_height.*=.*Height.*\()|(Adding block to cache )'
# We want to prevent multiple lightwalletd full syncs running at the same time,
# but we don't want to cancel running syncs on `main` if a new PR gets merged,
# because we might never get a finished sync.
#
# See the concurrency comment on the zebrad test-full-sync job for details.
concurrency:
group: ${{ github.workflow }}−${{ github.ref }}-lightwalletd-full-sync
cancel-in-progress: false

# Test update sync of lightwalletd with a lightwalletd and Zebra tip state
# Runs:
Expand All @@ -412,7 +435,7 @@ jobs:
name: lightwalletd tip update
needs: lightwalletd-full-sync
uses: ./.github/workflows/deploy-gcp-tests.yml
if: ${{ !cancelled() && !failure() && github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' }}
if: ${{ !cancelled() && !failure() && github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' && github.event.inputs.run-lwd-sync != 'true' }}
with:
app_name: lightwalletd
test_id: lwd-update-sync
Expand Down Expand Up @@ -441,7 +464,7 @@ jobs:
name: Zebra tip JSON-RPC
needs: test-full-sync
uses: ./.github/workflows/deploy-gcp-tests.yml
if: ${{ !cancelled() && !failure() && github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' }}
if: ${{ !cancelled() && !failure() && github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' && github.event.inputs.run-lwd-sync != 'true' }}
with:
app_name: lightwalletd
test_id: fully-synced-rpc
Expand All @@ -466,7 +489,7 @@ jobs:
name: lightwalletd tip send
needs: lightwalletd-full-sync
uses: ./.github/workflows/deploy-gcp-tests.yml
if: ${{ !cancelled() && !failure() && github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' }}
if: ${{ !cancelled() && !failure() && github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' && github.event.inputs.run-lwd-sync != 'true' }}
with:
app_name: lightwalletd
test_id: lwd-send-transactions
Expand All @@ -492,7 +515,7 @@ jobs:
name: lightwalletd GRPC tests
needs: lightwalletd-full-sync
uses: ./.github/workflows/deploy-gcp-tests.yml
if: ${{ !cancelled() && !failure() && github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' }}
if: ${{ !cancelled() && !failure() && github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' && github.event.inputs.run-lwd-sync != 'true' }}
with:
app_name: lightwalletd
test_id: lwd-grpc-wallet
Expand Down

0 comments on commit dae1d92

Please sign in to comment.