zebra/.github/workflows/test.yml

74 lines
2.5 KiB
YAML
Raw Normal View History

name: Test
on:
workflow_dispatch:
push:
branches:
- main
env:
PROJECT_ID: zealous-zebra
ZONE: europe-west1-b
jobs:
test:
name: Run all tests
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- 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
# Setup gcloud CLI
- name: Set up gcloud
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
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 "zebrad-tests-$BRANCH_NAME-$SHORT_SHA" \
--boot-disk-size 100GB \
--boot-disk-type pd-ssd \
--image-family cos-stable \
--image-project cos-cloud \
--machine-type n2-standard-4 \
--service-account cos-vm@zealous-zebra.iam.gserviceaccount.com \
--scopes cloud-platform \
--tags zebrad \
--zone "$ZONE"
# Build and run test container
- name: Run all tests
run: |
gcloud compute ssh "zebrad-tests-$BRANCH_NAME-$SHORT_SHA" --zone "$ZONE" \
--command "git clone -b $BRANCH_NAME https://github.com/ZcashFoundation/zebra.git; cd zebra/; docker build -f docker/Dockerfile.test -t zebrad-test .; docker run -i zebrad-test cargo test --workspace --no-fail-fast -- -Zunstable-options --include-ignored"
# Clean up
- name: Delete test instance
# Always run even if the earlier step fails
if: ${{ always() }}
run: |
gcloud compute instances delete "zebrad-tests-$BRANCH_NAME-$SHORT_SHA" --delete-disks all --zone "$ZONE"