2021-06-06 20:14:30 -07:00
|
|
|
name: Regenerate test state
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
2021-08-11 09:15:22 -07:00
|
|
|
inputs:
|
|
|
|
network:
|
|
|
|
default: 'mainnet'
|
2021-06-06 20:14:30 -07:00
|
|
|
|
|
|
|
env:
|
|
|
|
PROJECT_ID: zealous-zebra
|
|
|
|
ZONE: europe-west1-b
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
|
|
|
regenerate:
|
|
|
|
name: Regenerate test state
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2.3.4
|
|
|
|
with:
|
|
|
|
persist-credentials: false
|
2021-06-27 23:35:52 -07:00
|
|
|
|
2021-06-06 20:14:30 -07:00
|
|
|
- name: Set project and image names
|
|
|
|
run: |
|
|
|
|
BRANCH_NAME=$(expr $GITHUB_REF : '.*/\(.*\)') && \
|
|
|
|
BRANCH_NAME=${BRANCH_NAME,,} && \
|
|
|
|
REPOSITORY=${GITHUB_REPOSITORY,,} && \
|
|
|
|
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV && \
|
|
|
|
echo "SHORT_SHA=$(git rev-parse --short=7 $GITHUB_SHA)" >> $GITHUB_ENV && \
|
|
|
|
echo "REPOSITORY=$REPOSITORY" >> $GITHUB_ENV
|
|
|
|
- name: Set up gcloud
|
2021-07-27 09:13:04 -07:00
|
|
|
uses: google-github-actions/setup-gcloud@master
|
2021-06-06 20:14:30 -07:00
|
|
|
with:
|
|
|
|
version: '295.0.0'
|
|
|
|
project_id: ${{ env.PROJECT_ID }}
|
|
|
|
service_account_key: ${{ secrets.GCLOUD_AUTH }}
|
|
|
|
|
|
|
|
# Run once: create firewall rule to allow incoming traffic to the nodes
|
|
|
|
# - name: Create Zcash incoming traffic firewall rule
|
|
|
|
# run: |
|
|
|
|
# gcloud compute firewall-rules create "allow-zcash" \
|
|
|
|
# --target-tags zebrad \
|
|
|
|
# --allow tcp:8233,tcp:18233 \
|
|
|
|
# --source-ranges 0.0.0.0/0 \
|
|
|
|
# --description="Allow incoming Zcash traffic from anywhere" \
|
|
|
|
|
|
|
|
# Creates Compute Engine virtual machine instance w/ disks
|
|
|
|
- name: Create instance
|
|
|
|
run: |
|
|
|
|
gcloud compute instances create-with-container "zebrad-tests-$BRANCH_NAME-$SHORT_SHA" \
|
|
|
|
--boot-disk-size 100GB \
|
|
|
|
--boot-disk-type pd-ssd \
|
|
|
|
--container-image rust:buster \
|
2021-08-11 09:15:22 -07:00
|
|
|
--container-mount-disk mount-path='/${{ github.event.inputs.network }}',name="zebrad-cache-$SHORT_SHA-${{ github.event.inputs.network }}-canopy" \
|
2021-06-06 20:14:30 -07:00
|
|
|
--container-restart-policy never \
|
2021-08-11 09:15:22 -07:00
|
|
|
--create-disk name="zebrad-cache-$SHORT_SHA-${{ github.event.inputs.network }}-canopy",size=100GB,type=pd-balanced \
|
2021-06-06 20:14:30 -07:00
|
|
|
--machine-type n2-standard-4 \
|
|
|
|
--service-account cos-vm@zealous-zebra.iam.gserviceaccount.com \
|
|
|
|
--scopes cloud-platform \
|
|
|
|
--tags zebrad \
|
|
|
|
--zone "$ZONE"
|
2021-08-11 09:15:22 -07:00
|
|
|
# Build and run test container to sync up to activation and no further
|
|
|
|
- name: Regenerate state for tests
|
|
|
|
id: regenerate-state
|
2021-06-06 20:14:30 -07:00
|
|
|
run: |
|
|
|
|
gcloud compute ssh "zebrad-tests-$BRANCH_NAME-$SHORT_SHA" --zone "$ZONE" --command \
|
2021-06-27 23:35:52 -07:00
|
|
|
"git clone -b $BRANCH_NAME https://github.com/ZcashFoundation/zebra.git &&
|
|
|
|
cd zebra/ &&
|
|
|
|
docker build --build-arg SHORT_SHA=$SHORT_SHA -f docker/Dockerfile.test -t zebrad-test . &&
|
2021-08-11 09:15:22 -07:00
|
|
|
docker run -i -e "ZEBRA_SKIP_IPV6_TESTS=1" --mount type=bind,source=/mnt/disks/gce-containers-mounts/gce-persistent-disks/zebrad-cache-$SHORT_SHA-${{ github.event.inputs.network }}-canopy,target=/zebrad-cache zebrad-test:latest cargo test --verbose --features test_sync_to_mandatory_checkpoint_${{ github.event.inputs.network }} --manifest-path zebrad/Cargo.toml sync_to_mandatory_checkpoint_${{ github.event.inputs.network }};
|
2021-06-06 20:14:30 -07:00
|
|
|
"
|
2021-08-11 09:15:22 -07:00
|
|
|
# Create image from disk that will be used in test.yml workflow
|
|
|
|
- name: Create image from state disk
|
|
|
|
# Only run if the earlier step succeeds
|
|
|
|
if: steps.regenerate-state.outcome == 'success'
|
|
|
|
run: |
|
|
|
|
gcloud compute images create "zebrad-cache-$SHORT_SHA-${{ github.event.inputs.network }}-canopy" --source-disk="zebrad-cache-$SHORT_SHA-${{ github.event.inputs.network }}-canopy" --source-disk-zone="$ZONE"
|
2021-06-06 20:14:30 -07:00
|
|
|
# Clean up
|
|
|
|
- name: Delete test instance
|
|
|
|
# Always run even if the earlier step fails
|
|
|
|
if: ${{ always() }}
|
|
|
|
run: |
|
2021-08-11 09:15:22 -07:00
|
|
|
gcloud compute instances delete "zebrad-tests-$BRANCH_NAME-$SHORT_SHA" --delete-disks all --zone "$ZONE"
|