71 lines
3.5 KiB
YAML
71 lines
3.5 KiB
YAML
name: Regenerate test state
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
network:
|
|
default: 'mainnet'
|
|
|
|
env:
|
|
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
|
|
ZONE: europe-west1-b
|
|
MACHINE_TYPE: n2-standard-4
|
|
DEPLOY_SA: cos-vm@${{ secrets.GCP_PROJECT_ID }}.iam.gserviceaccount.com
|
|
|
|
jobs:
|
|
|
|
regenerate:
|
|
name: Regenerate test state
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2.4.0
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Inject slug/short variables
|
|
uses: rlespinasse/github-slug-action@v4
|
|
|
|
- name: Set up gcloud
|
|
uses: google-github-actions/setup-gcloud@v0.4.0
|
|
with:
|
|
project_id: ${{ env.PROJECT_ID }}
|
|
service_account_key: ${{ secrets.GCLOUD_AUTH }}
|
|
|
|
# Creates Compute Engine virtual machine instance w/ disks
|
|
- name: Create instance
|
|
run: |
|
|
gcloud compute instances create-with-container "zebrad-tests-${{ env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}-${{ env.GITHUB_SHA_SHORT }}" \
|
|
--boot-disk-size 100GB \
|
|
--boot-disk-type pd-ssd \
|
|
--container-image rust:buster \
|
|
--container-mount-disk mount-path='/${{ github.event.inputs.network }}',name="zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${{ github.event.inputs.network }}-canopy" \
|
|
--container-restart-policy never \
|
|
--create-disk name="zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${{ github.event.inputs.network }}-canopy",size=100GB,type=pd-balanced \
|
|
--machine-type ${{ env.MACHINE_TYPE }} \
|
|
--service-account ${{ env.DEPLOY_SA }} \
|
|
--scopes cloud-platform \
|
|
--tags zebrad \
|
|
--zone "${{ env.ZONE }}"
|
|
# Build and run test container to sync up to activation and no further
|
|
- name: Regenerate state for tests
|
|
id: regenerate-state
|
|
run: |
|
|
gcloud compute ssh "zebrad-tests-${{ env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}-${{ env.GITHUB_SHA_SHORT }}" --zone "${{ env.ZONE }}" --command \
|
|
"git clone -b ${{ env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }} https://github.com/ZcashFoundation/zebra.git &&
|
|
cd zebra/ &&
|
|
docker build --build-arg SHORT_SHA=${{ env.GITHUB_SHA_SHORT }} -f docker/Dockerfile.test -t zebrad-test . &&
|
|
docker run -i -e "ZEBRA_SKIP_IPV6_TESTS=1" --mount type=bind,source=/mnt/disks/gce-containers-mounts/gce-persistent-disks/zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${{ 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 }};
|
|
"
|
|
# 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-${{ env.GITHUB_SHA_SHORT }}-${{ github.event.inputs.network }}-canopy" --source-disk="zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${{ github.event.inputs.network }}-canopy" --source-disk-zone="${{ env.ZONE }}"
|
|
# Clean up
|
|
- name: Delete test instance
|
|
# Always run even if the earlier step fails
|
|
if: ${{ always() }}
|
|
run: |
|
|
gcloud compute instances delete "zebrad-tests-${{ env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}-${{ env.GITHUB_SHA_SHORT }}" --delete-disks all --zone "${{ env.ZONE }}"
|