fix(ci): Fix network parameter in continous-delivery.yml, and add network labels to GCP jobs (#5710)
* chore: add Network as a label * Fix network parameter in continous-delivery.yml * Standardise network usage in zcashd-manual-deploy * Use lowercase network labels * Fix some shellcheck errors * Hard-code a Mainnet default to support contexts where env is not available * Fix string syntax * Fix more shellcheck errors * Update .github/workflows/zcashd-manual-deploy.yml Co-authored-by: Gustavo Valverde <gustavo@iterativo.do> Co-authored-by: Arya <aryasolhi@gmail.com>
This commit is contained in:
parent
0af82764ac
commit
a763eec9f3
|
@ -26,7 +26,6 @@ on:
|
||||||
- published
|
- published
|
||||||
|
|
||||||
env:
|
env:
|
||||||
NETWORK: Mainnet
|
|
||||||
GAR_BASE: us-docker.pkg.dev/zealous-zebra/zebra
|
GAR_BASE: us-docker.pkg.dev/zealous-zebra/zebra
|
||||||
REGION: us-central1
|
REGION: us-central1
|
||||||
ZONE: us-central1-a
|
ZONE: us-central1-a
|
||||||
|
@ -40,7 +39,7 @@ jobs:
|
||||||
# - If our semver is `v1.3.0` the resulting output from this job would be `v1`
|
# - If our semver is `v1.3.0` the resulting output from this job would be `v1`
|
||||||
#
|
#
|
||||||
# Note: We just use the first part of the version to replace old instances, and change
|
# Note: We just use the first part of the version to replace old instances, and change
|
||||||
# it when a major version is released, to keep a segregation between new and old
|
# it when a major version is released, to keep a segregation between new and old
|
||||||
# versions.
|
# versions.
|
||||||
versioning:
|
versioning:
|
||||||
name: Versioning
|
name: Versioning
|
||||||
|
@ -71,7 +70,8 @@ jobs:
|
||||||
dockerfile_path: ./docker/Dockerfile
|
dockerfile_path: ./docker/Dockerfile
|
||||||
dockerfile_target: runtime
|
dockerfile_target: runtime
|
||||||
image_name: zebrad
|
image_name: zebrad
|
||||||
network: Mainnet
|
# We need to hard-code Mainnet here, because env is not allowed in this context
|
||||||
|
network: ${{ inputs.network || 'Mainnet' }}
|
||||||
checkpoint_sync: true
|
checkpoint_sync: true
|
||||||
rust_backtrace: '1'
|
rust_backtrace: '1'
|
||||||
zebra_skip_ipv6_tests: '1'
|
zebra_skip_ipv6_tests: '1'
|
||||||
|
@ -89,7 +89,7 @@ jobs:
|
||||||
# - on every push/merge to the `main` branch
|
# - on every push/merge to the `main` branch
|
||||||
# - on every release, when it's published
|
# - on every release, when it's published
|
||||||
deploy-nodes:
|
deploy-nodes:
|
||||||
name: Deploy Mainnet nodes
|
name: Deploy ${{ inputs.network || 'Mainnet' }} nodes
|
||||||
needs: [ build, versioning ]
|
needs: [ build, versioning ]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
|
@ -104,6 +104,17 @@ jobs:
|
||||||
with:
|
with:
|
||||||
short-length: 7
|
short-length: 7
|
||||||
|
|
||||||
|
# Makes the Zcash network name lowercase.
|
||||||
|
#
|
||||||
|
# Labels in GCP are required to be in lowercase, but the blockchain network
|
||||||
|
# uses sentence case, so we need to downcase ${{ inputs.network || 'Mainnet' }}.
|
||||||
|
#
|
||||||
|
# Passes the lowercase network to subsequent steps using $NETWORK env variable.
|
||||||
|
- name: Downcase network name for labels
|
||||||
|
run: |
|
||||||
|
NETWORK_CAPS="${{ inputs.network || 'Mainnet' }}"
|
||||||
|
echo "NETWORK=${NETWORK_CAPS,,}" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
# Setup gcloud CLI
|
# Setup gcloud CLI
|
||||||
- name: Authenticate to Google Cloud
|
- name: Authenticate to Google Cloud
|
||||||
id: auth
|
id: auth
|
||||||
|
@ -129,7 +140,7 @@ jobs:
|
||||||
--container-mount-disk=mount-path="/zebrad-cache",name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }} \
|
--container-mount-disk=mount-path="/zebrad-cache",name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }} \
|
||||||
--machine-type ${{ env.MACHINE_TYPE }} \
|
--machine-type ${{ env.MACHINE_TYPE }} \
|
||||||
--scopes cloud-platform \
|
--scopes cloud-platform \
|
||||||
--labels=app=zebrad,environment=prod,github_ref=${{ env.GITHUB_REF_SLUG_URL }} \
|
--labels=app=zebrad,environment=prod,network=${NETWORK},github_ref=${{ env.GITHUB_REF_SLUG_URL }} \
|
||||||
--tags zebrad
|
--tags zebrad
|
||||||
|
|
||||||
# Check if our destination instance group exists already
|
# Check if our destination instance group exists already
|
||||||
|
@ -210,5 +221,5 @@ jobs:
|
||||||
--container-mount-disk=mount-path='/zebrad-cache' \
|
--container-mount-disk=mount-path='/zebrad-cache' \
|
||||||
--machine-type ${{ env.MACHINE_TYPE }} \
|
--machine-type ${{ env.MACHINE_TYPE }} \
|
||||||
--zone ${{ env.ZONE }} \
|
--zone ${{ env.ZONE }} \
|
||||||
--labels=app=zebrad,environment=qa,github_ref=${{ env.GITHUB_REF_SLUG_URL }} \
|
--labels=app=zebrad,environment=qa,network=${NETWORK},github_ref=${{ env.GITHUB_REF_SLUG_URL }} \
|
||||||
--tags zebrad
|
--tags zebrad
|
||||||
|
|
|
@ -125,6 +125,17 @@ jobs:
|
||||||
with:
|
with:
|
||||||
short-length: 7
|
short-length: 7
|
||||||
|
|
||||||
|
# Makes the Zcash network name lowercase.
|
||||||
|
#
|
||||||
|
# Labels in GCP are required to be in lowercase, but the blockchain network
|
||||||
|
# uses sentence case, so we need to downcase ${{ inputs.network }}.
|
||||||
|
#
|
||||||
|
# Passes ${{ inputs.network }} to subsequent steps using $NETWORK env variable.
|
||||||
|
- name: Downcase network name for labels
|
||||||
|
run: |
|
||||||
|
NETWORK_CAPS="${{ inputs.network }}"
|
||||||
|
echo "NETWORK=${NETWORK_CAPS,,}" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
# Install our SSH secret
|
# Install our SSH secret
|
||||||
- name: Install private SSH key
|
- name: Install private SSH key
|
||||||
uses: shimataro/ssh-key-action@v2.4.0
|
uses: shimataro/ssh-key-action@v2.4.0
|
||||||
|
@ -163,7 +174,7 @@ jobs:
|
||||||
--scopes cloud-platform \
|
--scopes cloud-platform \
|
||||||
--metadata=google-monitoring-enabled=TRUE,google-logging-enabled=TRUE \
|
--metadata=google-monitoring-enabled=TRUE,google-logging-enabled=TRUE \
|
||||||
--metadata-from-file=startup-script=.github/workflows/scripts/gcp-vm-startup-script.sh \
|
--metadata-from-file=startup-script=.github/workflows/scripts/gcp-vm-startup-script.sh \
|
||||||
--labels=app=${{ inputs.app_name }},environment=test,github_ref=${{ env.GITHUB_REF_SLUG_URL }},test=${{ inputs.test_id }} \
|
--labels=app=${{ inputs.app_name }},environment=test,network=${NETWORK},github_ref=${{ env.GITHUB_REF_SLUG_URL }},test=${{ inputs.test_id }} \
|
||||||
--tags ${{ inputs.app_name }} \
|
--tags ${{ inputs.app_name }} \
|
||||||
--zone ${{ env.ZONE }}
|
--zone ${{ env.ZONE }}
|
||||||
sleep 60
|
sleep 60
|
||||||
|
@ -272,10 +283,10 @@ jobs:
|
||||||
with:
|
with:
|
||||||
short-length: 7
|
short-length: 7
|
||||||
|
|
||||||
- name: Downcase network name for disks
|
- name: Downcase network name for disks and labels
|
||||||
run: |
|
run: |
|
||||||
NETWORK_CAPS=${{ inputs.network }}
|
NETWORK_CAPS="${{ inputs.network }}"
|
||||||
echo "NETWORK=${NETWORK_CAPS,,}" >> $GITHUB_ENV
|
echo "NETWORK=${NETWORK_CAPS,,}" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
# Install our SSH secret
|
# Install our SSH secret
|
||||||
- name: Install private SSH key
|
- name: Install private SSH key
|
||||||
|
@ -385,8 +396,8 @@ jobs:
|
||||||
echo "Selected Disk: $CACHED_DISK_NAME"
|
echo "Selected Disk: $CACHED_DISK_NAME"
|
||||||
echo "::set-output name=cached_disk_name::$CACHED_DISK_NAME"
|
echo "::set-output name=cached_disk_name::$CACHED_DISK_NAME"
|
||||||
|
|
||||||
echo "STATE_VERSION=$LOCAL_STATE_VERSION" >> $GITHUB_ENV
|
echo "STATE_VERSION=$LOCAL_STATE_VERSION" >> "$GITHUB_ENV"
|
||||||
echo "CACHED_DISK_NAME=$CACHED_DISK_NAME" >> $GITHUB_ENV
|
echo "CACHED_DISK_NAME=$CACHED_DISK_NAME" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
# Create a Compute Engine virtual machine and attach a cached state disk using the
|
# 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 variable as the source image to populate the disk cached state
|
||||||
|
@ -404,7 +415,7 @@ jobs:
|
||||||
--scopes cloud-platform \
|
--scopes cloud-platform \
|
||||||
--metadata=google-monitoring-enabled=TRUE,google-logging-enabled=TRUE \
|
--metadata=google-monitoring-enabled=TRUE,google-logging-enabled=TRUE \
|
||||||
--metadata-from-file=startup-script=.github/workflows/scripts/gcp-vm-startup-script.sh \
|
--metadata-from-file=startup-script=.github/workflows/scripts/gcp-vm-startup-script.sh \
|
||||||
--labels=app=${{ inputs.app_name }},environment=test,github_ref=${{ env.GITHUB_REF_SLUG_URL }},test=${{ inputs.test_id }} \
|
--labels=app=${{ inputs.app_name }},environment=test,network=${NETWORK},github_ref=${{ env.GITHUB_REF_SLUG_URL }},test=${{ inputs.test_id }} \
|
||||||
--tags ${{ inputs.app_name }} \
|
--tags ${{ inputs.app_name }} \
|
||||||
--zone ${{ env.ZONE }}
|
--zone ${{ env.ZONE }}
|
||||||
sleep 60
|
sleep 60
|
||||||
|
@ -1300,10 +1311,10 @@ jobs:
|
||||||
# Passes ${{ env.GITHUB_REF_SLUG_URL }} to subsequent steps using $SHORT_GITHUB_REF env variable.
|
# Passes ${{ env.GITHUB_REF_SLUG_URL }} to subsequent steps using $SHORT_GITHUB_REF env variable.
|
||||||
- name: Format network name and branch name for disks
|
- name: Format network name and branch name for disks
|
||||||
run: |
|
run: |
|
||||||
NETWORK_CAPS=${{ inputs.network }}
|
NETWORK_CAPS="${{ inputs.network }}"
|
||||||
echo "NETWORK=${NETWORK_CAPS,,}" >> $GITHUB_ENV
|
echo "NETWORK=${NETWORK_CAPS,,}" >> "$GITHUB_ENV"
|
||||||
LONG_GITHUB_REF=${{ env.GITHUB_REF_SLUG_URL }}
|
LONG_GITHUB_REF="${{ env.GITHUB_REF_SLUG_URL }}"
|
||||||
echo "SHORT_GITHUB_REF=${LONG_GITHUB_REF:0:12}" >> $GITHUB_ENV
|
echo "SHORT_GITHUB_REF=${LONG_GITHUB_REF:0:12}" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
# Install our SSH secret
|
# Install our SSH secret
|
||||||
- name: Install private SSH key
|
- name: Install private SSH key
|
||||||
|
@ -1336,7 +1347,7 @@ jobs:
|
||||||
LOCAL_STATE_VERSION=$(grep -oE "DATABASE_FORMAT_VERSION: .* [0-9]+" $GITHUB_WORKSPACE/zebra-state/src/constants.rs | grep -oE "[0-9]+" | tail -n1)
|
LOCAL_STATE_VERSION=$(grep -oE "DATABASE_FORMAT_VERSION: .* [0-9]+" $GITHUB_WORKSPACE/zebra-state/src/constants.rs | grep -oE "[0-9]+" | tail -n1)
|
||||||
echo "STATE_VERSION: $LOCAL_STATE_VERSION"
|
echo "STATE_VERSION: $LOCAL_STATE_VERSION"
|
||||||
|
|
||||||
echo "STATE_VERSION=$LOCAL_STATE_VERSION" >> $GITHUB_ENV
|
echo "STATE_VERSION=$LOCAL_STATE_VERSION" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
# Sets the $UPDATE_SUFFIX env var to "-u" if updating a previous cached state,
|
# Sets the $UPDATE_SUFFIX env var to "-u" if updating a previous cached state,
|
||||||
# and the empty string otherwise.
|
# and the empty string otherwise.
|
||||||
|
@ -1358,8 +1369,8 @@ jobs:
|
||||||
# We're going to delete old images after a few days, so we only need the time here
|
# We're going to delete old images after a few days, so we only need the time here
|
||||||
TIME_SUFFIX=$(date '+%H%M%S' --utc)
|
TIME_SUFFIX=$(date '+%H%M%S' --utc)
|
||||||
|
|
||||||
echo "UPDATE_SUFFIX=$UPDATE_SUFFIX" >> $GITHUB_ENV
|
echo "UPDATE_SUFFIX=$UPDATE_SUFFIX" >> "$GITHUB_ENV"
|
||||||
echo "TIME_SUFFIX=$TIME_SUFFIX" >> $GITHUB_ENV
|
echo "TIME_SUFFIX=$TIME_SUFFIX" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
# Get the sync height from the test logs, which is later used as part of the
|
# Get the sync height from the test logs, which is later used as part of the
|
||||||
# disk description and labels.
|
# disk description and labels.
|
||||||
|
@ -1401,7 +1412,7 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Found sync height in logs: $SYNC_HEIGHT"
|
echo "Found sync height in logs: $SYNC_HEIGHT"
|
||||||
echo "SYNC_HEIGHT=$SYNC_HEIGHT" >> $GITHUB_ENV
|
echo "SYNC_HEIGHT=$SYNC_HEIGHT" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
# Get the original cached state height from google cloud.
|
# Get the original cached state height from google cloud.
|
||||||
#
|
#
|
||||||
|
@ -1422,7 +1433,7 @@ jobs:
|
||||||
echo "$CACHED_DISK_NAME height: $ORIGINAL_HEIGHT"
|
echo "$CACHED_DISK_NAME height: $ORIGINAL_HEIGHT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "ORIGINAL_HEIGHT=$ORIGINAL_HEIGHT" >> $GITHUB_ENV
|
echo "ORIGINAL_HEIGHT=$ORIGINAL_HEIGHT" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
# Create an image from the state disk, which will be used for any tests that start
|
# Create an image from the state disk, which will be used for any tests that start
|
||||||
# after it is created. These tests can be in the same workflow, or in a different PR.
|
# after it is created. These tests can be in the same workflow, or in a different PR.
|
||||||
|
|
|
@ -37,6 +37,17 @@ jobs:
|
||||||
with:
|
with:
|
||||||
short-length: 7
|
short-length: 7
|
||||||
|
|
||||||
|
# Makes the Zcash network name lowercase.
|
||||||
|
#
|
||||||
|
# Labels in GCP are required to be in lowercase, but the blockchain network
|
||||||
|
# uses sentence case, so we need to downcase ${{ inputs.network }}.
|
||||||
|
#
|
||||||
|
# Passes ${{ inputs.network }} to subsequent steps using $NETWORK env variable.
|
||||||
|
- name: Downcase network name for labels
|
||||||
|
run: |
|
||||||
|
NETWORK_CAPS="${{ inputs.network }}"
|
||||||
|
echo "NETWORK=${NETWORK_CAPS,,}" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
# Setup gcloud CLI
|
# Setup gcloud CLI
|
||||||
- name: Authenticate to Google Cloud
|
- name: Authenticate to Google Cloud
|
||||||
id: auth
|
id: auth
|
||||||
|
@ -60,11 +71,11 @@ jobs:
|
||||||
--container-stdin \
|
--container-stdin \
|
||||||
--container-tty \
|
--container-tty \
|
||||||
--container-image electriccoinco/zcashd \
|
--container-image electriccoinco/zcashd \
|
||||||
--container-env ZCASHD_NETWORK="${{ github.event.inputs.network }}" \
|
--container-env ZCASHD_NETWORK="${{ inputs.network }}" \
|
||||||
--machine-type ${{ env.MACHINE_TYPE }} \
|
--machine-type ${{ env.MACHINE_TYPE }} \
|
||||||
--service-account ${{ env.DEPLOY_SA }} \
|
--service-account ${{ env.DEPLOY_SA }} \
|
||||||
--scopes cloud-platform \
|
--scopes cloud-platform \
|
||||||
--labels=app=zcashd,environment=prod,github_ref=${{ env.GITHUB_REF_SLUG_URL }} \
|
--labels=app=zcashd,environment=prod,network=${NETWORK},github_ref=${{ env.GITHUB_REF_SLUG_URL }} \
|
||||||
--tags zcashd
|
--tags zcashd
|
||||||
|
|
||||||
# Check if our destination instance group exists already
|
# Check if our destination instance group exists already
|
||||||
|
@ -72,14 +83,14 @@ jobs:
|
||||||
id: does-group-exist
|
id: does-group-exist
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
gcloud compute instance-groups list | grep "zcashd-${{ env.GITHUB_REF_SLUG_URL }}-${{ github.event.inputs.network }}" | grep "${{ env.REGION }}"
|
gcloud compute instance-groups list | grep "zcashd-${{ env.GITHUB_REF_SLUG_URL }}-${{ inputs.network }}" | grep "${{ env.REGION }}"
|
||||||
|
|
||||||
# Deploy new managed instance group using the new instance template
|
# Deploy new managed instance group using the new instance template
|
||||||
- name: Create managed instance group
|
- name: Create managed instance group
|
||||||
if: steps.does-group-exist.outcome == 'failure'
|
if: steps.does-group-exist.outcome == 'failure'
|
||||||
run: |
|
run: |
|
||||||
gcloud compute instance-groups managed create \
|
gcloud compute instance-groups managed create \
|
||||||
"zcashd-${{ env.GITHUB_REF_SLUG_URL }}-${{ github.event.inputs.network }}" \
|
"zcashd-${{ env.GITHUB_REF_SLUG_URL }}-${{ inputs.network }}" \
|
||||||
--template "zcashd-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
|
--template "zcashd-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
|
||||||
--region "${{ env.REGION }}" \
|
--region "${{ env.REGION }}" \
|
||||||
--size "${{ github.event.inputs.size }}"
|
--size "${{ github.event.inputs.size }}"
|
||||||
|
@ -89,6 +100,6 @@ jobs:
|
||||||
if: steps.does-group-exist.outcome == 'success'
|
if: steps.does-group-exist.outcome == 'success'
|
||||||
run: |
|
run: |
|
||||||
gcloud compute instance-groups managed rolling-action start-update \
|
gcloud compute instance-groups managed rolling-action start-update \
|
||||||
"zcashd-${{ env.GITHUB_REF_SLUG_URL }}-${{ github.event.inputs.network }}" \
|
"zcashd-${{ env.GITHUB_REF_SLUG_URL }}-${{ inputs.network }}" \
|
||||||
--version template="zcashd-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
|
--version template="zcashd-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
|
||||||
--region "${{ env.REGION }}"
|
--region "${{ env.REGION }}"
|
||||||
|
|
Loading…
Reference in New Issue