-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ci): convert the
get-disk-name
to a job
- Loading branch information
1 parent
40fdc5c
commit 6fb9f10
Showing
3 changed files
with
41 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,17 +97,42 @@ env: | |
CACHED_STATE_UPDATE_LIMIT: 576 | ||
|
||
jobs: | ||
# Find a cached state disk for ${{ inputs.test_id }}, matching all of: | ||
# - disk cached state prefix -> zebrad-cache or lwd-cache | ||
# - state version (from the source code) - v{N} | ||
# - network (network) - mainnet or testnet | ||
# - disk target height kind (disk_suffix) - checkpoint or tip | ||
# | ||
# If the test needs a lightwalletd state (needs_lwd_state) set the input disk_prefix accordingly | ||
# - To lwd-cache if needed | ||
# - To zebrad-cache if not | ||
# | ||
# Passes the disk name to subsequent steps using `cached_disk_name` output | ||
# Passes the state version to subsequent steps using `state_version` output | ||
# | ||
get-test-disk: | ||
name: Get ${{ inputs.test_id }} disk name | ||
if: ${{ inputs.needs_zebra_state || inputs.needs_lwd_state }} | ||
uses: ./.github/workflows/sub-find-cached-disks.yml | ||
with: | ||
network: ${{ inputs.network || vars.ZCASH_NETWORK }} | ||
disk_prefix: ${{ inputs.needs_lwd_state && 'lwd-cache' || inputs.needs_zebra_state && 'zebrad-cache' }} | ||
disk_suffix: ${{ inputs.disk_suffix }} | ||
prefer_main_cached_state: ${{ inputs.prefer_main_cached_state }}} | ||
|
||
# Show all the test logs, then follow the logs of the test we just launched, until it finishes. | ||
# Then check the result of the test. | ||
# | ||
# If `inputs.is_long_test` is `true`, the timeout is 5 days, otherwise it's 3 hours. | ||
test-result: | ||
name: Run ${{ inputs.test_id }} test | ||
runs-on: zfnd-runners | ||
needs: [ get-test-disk ] | ||
if: ${{ !cancelled() && !failure() }} | ||
timeout-minutes: ${{ inputs.is_long_test && 7200 || 180 }} | ||
outputs: | ||
cached_disk_name: ${{ steps.get-disk-name.outputs.cached_disk_name }} | ||
state_version: ${{ steps.get-disk-name.outputs.state_version }} | ||
cached_disk_name: ${{ needs.get-test-disk.outputs.cached_disk_name }} | ||
state_version: ${{ needs.get-test-disk.outputs.state_version }} | ||
permissions: | ||
contents: 'read' | ||
id-token: 'write' | ||
|
@@ -152,47 +177,17 @@ jobs: | |
- name: Set up Cloud SDK | ||
uses: google-github-actions/[email protected] | ||
|
||
# Find a cached state disk for this job, matching all of: | ||
# - disk cached state prefix -> zebrad-cache or lwd-cache | ||
# - state version (from the source code) - v{N} | ||
# - network (network) - mainnet or testnet | ||
# - disk target height kind (disk_suffix) - checkpoint or tip | ||
# | ||
# If the test needs a lightwalletd state (needs_lwd_state) set the variable CACHE_PREFIX accordingly | ||
# - To lwd-cache if needed | ||
# - To zebrad-cache if not | ||
# | ||
# If there are multiple disks: | ||
# - prefer images generated from the same commit, then | ||
# - if prefer_main_cached_state is true, prefer images from the `main` branch, then | ||
# - use any images from any other branch or commit. | ||
# Within each of these categories: | ||
# - prefer newer images to older images | ||
# | ||
# Passes the disk name to subsequent steps using $CACHED_DISK_NAME env variable | ||
# Passes the state version to subsequent steps using $STATE_VERSION env variable | ||
# | ||
- name: Find ${{ inputs.test_id }} cached state disk | ||
id: get-disk-name | ||
if: ${{ inputs.needs_zebra_state || inputs.needs_lwd_state }} | ||
uses: ./.github/workflows/sub-find-cached-disks.yml | ||
with: | ||
network: ${{ inputs.network || vars.ZCASH_NETWORK }} | ||
disk_prefix: ${{ inputs.needs_lwd_state && 'lwd-cache' || inputs.needs_zebra_state && 'zebrad-cache' }} | ||
disk_suffix: ${{ inputs.disk_suffix }} | ||
prefer_main_cached_state: ${{ inputs.prefer_main_cached_state }} | ||
|
||
# Create a Compute Engine virtual machine and attach a cached state disk using the | ||
# $CACHED_DISK_NAME variable as the source image to populate the disk cached state | ||
# cached_disk_name output as the source image to populate the disk cached state | ||
# if the test needs it. | ||
- name: Create ${{ inputs.test_id }} GCP compute instance | ||
id: create-instance | ||
shell: /usr/bin/bash -x {0} | ||
run: | | ||
NAME="${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }}" | ||
DISK_PARAMS="size=400GB,type=pd-ssd,name=${NAME},device-name=${NAME}" | ||
if [ -n "${{ steps.get-disk-name.outputs.cached_disk_name }}" ]; then | ||
DISK_PARAMS+=",image=${{ steps.get-disk-name.outputs.cached_disk_name }}" | ||
if [ -n "${{ needs.get-test-disk.outputs.cached_disk_name }}" ]; then | ||
DISK_PARAMS+=",image=${{ needs.get-test-disk.outputs.cached_disk_name }}" | ||
fi | ||
gcloud compute instances create-with-container "${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \ | ||
--boot-disk-size 50GB \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters