ref(workflows): use a single job to run GCP tests (#7682)
* ref(workflows): consolidate workflows based on their purpose This also renames the workflows to make their naming more consistent and adding a naming convention Fixes: #6166 Fixes: #6167 * fix(workflows): use correct name for patch * fix(workflow): docker unit tests * fix(release): validation error Error: ``` Validation Failed: {"resource":"Release","code":"invalid","field":"target_commitish"} ``` Fixes: https://github.com/release-drafter/release-drafter/issues/1125 * fix(workflows): reference correct name * fix: remove extra workflow * fix(workflows): use larger runners * fix(workflow): remove code already in docker unit-test * fix(unit-tests): start zebra the right way * fix: typo in patch name * chore: move job to logical order * imp(workflows): use better name for gcp tests * ref(workflow): use a single job to run GCP tests * fix(ci): do not format existing cached states if required * test: wait for the instance to be fully ready * fix(ci): use correct logic before formating * fix: use correct condition * fix: get more information * fix(ci): use better shell handling and upgrade OS * fix(ci): use better approach * fix: `$DISK_OPTION` is not being correctly passed * fix typo * fix: more typos * fix: use busybox * fix: mount Docker volume at run and not before * fix: use correct condition and simpler while * add: missing merge changes * chore: use better name for find-disks * fix(ci): use the `entrypoint.sh` to change the Network * fix(ci): add missing `ZEBRA_CONF_PATH` variable * fix(ci): considerate new updates to jobs * fix(ci): allow to build the entrypoint file with testnet * fix(entrypoint): allow to create a dir and file with a single variable * fix(ci): add missing jobs to `failure-issue` * Apply suggestions from code review Co-authored-by: teor <teor@riseup.net> * fix(ci): use better comment * refactor: test config file in CI and CD with a reusable workflow * fix(ci): wrong name used * fix(ci): use checkout * fix(ci): improve docker config tests * fix(ci): use better name for protection rules * chore: missing merge conflicts --------- Co-authored-by: teor <teor@riseup.net>
This commit is contained in:
parent
290ccf2d94
commit
d6f4d31706
|
|
@ -104,146 +104,14 @@ env:
|
||||||
CACHED_STATE_UPDATE_LIMIT: 576
|
CACHED_STATE_UPDATE_LIMIT: 576
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# set up and launch the test, if it doesn't use any cached state
|
# Show all the test logs, then follow the logs of the test we just launched, until it finishes.
|
||||||
# each test runs one of the *-with/without-cached-state job series, and skips the other
|
# Then check the result of the test.
|
||||||
launch-without-cached-state:
|
#
|
||||||
name: Launch ${{ inputs.test_id }} test
|
# If `inputs.is_long_test` is `true`, the timeout is 5 days, otherwise it's 3 hours.
|
||||||
if: ${{ !inputs.needs_zebra_state }}
|
test-result:
|
||||||
runs-on: zfnd-runners
|
name: Run ${{ inputs.test_id }} test
|
||||||
permissions:
|
|
||||||
contents: 'read'
|
|
||||||
id-token: 'write'
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4.1.0
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
fetch-depth: '2'
|
|
||||||
- uses: r7kamura/rust-problem-matchers@v1.4.0
|
|
||||||
|
|
||||||
- name: Inject slug/short variables
|
|
||||||
uses: rlespinasse/github-slug-action@v4
|
|
||||||
with:
|
|
||||||
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
|
|
||||||
- name: Install private SSH key
|
|
||||||
uses: shimataro/ssh-key-action@v2.5.1
|
|
||||||
with:
|
|
||||||
key: ${{ secrets.GCP_SSH_PRIVATE_KEY }}
|
|
||||||
name: google_compute_engine
|
|
||||||
known_hosts: unnecessary
|
|
||||||
|
|
||||||
- name: Generate public SSH key
|
|
||||||
run: |
|
|
||||||
sudo apt-get update && sudo apt-get -qq install -y --no-install-recommends openssh-client
|
|
||||||
ssh-keygen -y -f ~/.ssh/google_compute_engine > ~/.ssh/google_compute_engine.pub
|
|
||||||
|
|
||||||
# Setup gcloud CLI
|
|
||||||
- name: Authenticate to Google Cloud
|
|
||||||
id: auth
|
|
||||||
uses: google-github-actions/auth@v1.1.1
|
|
||||||
with:
|
|
||||||
retries: '3'
|
|
||||||
workload_identity_provider: '${{ vars.GCP_WIF }}'
|
|
||||||
service_account: '${{ vars.GCP_DEPLOYMENTS_SA }}'
|
|
||||||
|
|
||||||
- name: Set up Cloud SDK
|
|
||||||
uses: google-github-actions/setup-gcloud@v1.1.1
|
|
||||||
|
|
||||||
# Create a Compute Engine virtual machine
|
|
||||||
- name: Create ${{ inputs.test_id }} GCP compute instance
|
|
||||||
id: create-instance
|
|
||||||
run: |
|
|
||||||
gcloud compute instances create-with-container "${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
|
|
||||||
--boot-disk-size 50GB \
|
|
||||||
--boot-disk-type pd-ssd \
|
|
||||||
--image-project=cos-cloud \
|
|
||||||
--image-family=cos-stable \
|
|
||||||
--create-disk=name="${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }}",device-name="${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }}",size=400GB,type=pd-ssd \
|
|
||||||
--container-image=gcr.io/google-containers/busybox \
|
|
||||||
--machine-type ${{ vars.GCP_LARGE_MACHINE }} \
|
|
||||||
--network-interface=subnet=${{ vars.GCP_SUBNETWORK }} \
|
|
||||||
--scopes cloud-platform \
|
|
||||||
--metadata=google-monitoring-enabled=TRUE,google-logging-enabled=TRUE \
|
|
||||||
--metadata-from-file=startup-script=.github/workflows/scripts/gcp-vm-startup-script.sh \
|
|
||||||
--labels=app=${{ inputs.app_name }},environment=test,network=${NETWORK},github_ref=${{ env.GITHUB_REF_SLUG_URL }},test=${{ inputs.test_id }} \
|
|
||||||
--tags ${{ inputs.app_name }} \
|
|
||||||
--zone ${{ vars.GCP_ZONE }}
|
|
||||||
|
|
||||||
# Format the mounted disk if the test doesn't use a cached state.
|
|
||||||
- name: Format ${{ inputs.test_id }} volume
|
|
||||||
shell: /usr/bin/bash -exo pipefail {0}
|
|
||||||
run: |
|
|
||||||
gcloud compute ssh ${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
|
|
||||||
--zone ${{ vars.GCP_ZONE }} \
|
|
||||||
--ssh-flag="-o ServerAliveInterval=5" \
|
|
||||||
--ssh-flag="-o ConnectionAttempts=20" \
|
|
||||||
--ssh-flag="-o ConnectTimeout=5" \
|
|
||||||
--command=' \
|
|
||||||
set -ex;
|
|
||||||
# Extract the correct disk name based on the device-name
|
|
||||||
DISK_NAME=$(ls -l /dev/disk/by-id | grep -oE "google-${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }} -> ../../[^ ]+" | grep -oE "/[^/]+$" | cut -c 2-);
|
|
||||||
sudo mkfs.ext4 -v /dev/$DISK_NAME \
|
|
||||||
'
|
|
||||||
|
|
||||||
# Launch the test without any cached state
|
|
||||||
- name: Launch ${{ inputs.test_id }} test
|
|
||||||
id: launch-test
|
|
||||||
shell: /usr/bin/bash -exo pipefail {0}
|
|
||||||
run: |
|
|
||||||
gcloud compute ssh ${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
|
|
||||||
--zone ${{ vars.GCP_ZONE }} \
|
|
||||||
--ssh-flag="-o ServerAliveInterval=5" \
|
|
||||||
--ssh-flag="-o ConnectionAttempts=20" \
|
|
||||||
--ssh-flag="-o ConnectTimeout=5" \
|
|
||||||
--command=' \
|
|
||||||
set -ex;
|
|
||||||
# Extract the correct disk name based on the device-name
|
|
||||||
export DISK_NAME=$(ls -l /dev/disk/by-id | grep -oE "google-${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }} -> ../../[^ ]+" | grep -oE "/[^/]+$" | cut -c 2-); \
|
|
||||||
|
|
||||||
sudo docker run \
|
|
||||||
--name ${{ inputs.test_id }} \
|
|
||||||
--tty \
|
|
||||||
--detach \
|
|
||||||
${{ inputs.test_variables }} \
|
|
||||||
--mount type=volume,volume-driver=local,volume-opt=device=/dev/$DISK_NAME,volume-opt=type=ext4,dst=${{ inputs.root_state_path }}/${{ inputs.zebra_state_dir }} \
|
|
||||||
${{ vars.GAR_BASE }}/${{ vars.CI_IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} \
|
|
||||||
'
|
|
||||||
|
|
||||||
# Show debug logs if previous job failed
|
|
||||||
- name: Show debug logs if previous job failed
|
|
||||||
if: ${{ failure() }}
|
|
||||||
shell: /usr/bin/bash -exo pipefail {0}
|
|
||||||
run: |
|
|
||||||
gcloud compute ssh ${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
|
|
||||||
--zone ${{ vars.GCP_ZONE }} \
|
|
||||||
--ssh-flag="-o ServerAliveInterval=5" \
|
|
||||||
--ssh-flag="-o ConnectionAttempts=20" \
|
|
||||||
--ssh-flag="-o ConnectTimeout=5" \
|
|
||||||
--command=' \
|
|
||||||
lsblk;
|
|
||||||
sudo lsof /dev/$DISK_NAME;
|
|
||||||
sudo dmesg;
|
|
||||||
sudo journalctl -b \
|
|
||||||
'
|
|
||||||
|
|
||||||
# set up and launch the test, if it uses cached state
|
|
||||||
# each test runs one of the *-with/without-cached-state job series, and skips the other
|
|
||||||
launch-with-cached-state:
|
|
||||||
name: Launch ${{ inputs.test_id }} test
|
|
||||||
if: ${{ inputs.needs_zebra_state }}
|
|
||||||
runs-on: zfnd-runners
|
runs-on: zfnd-runners
|
||||||
|
timeout-minutes: ${{ inputs.is_long_test && 7200 || 180 }}
|
||||||
outputs:
|
outputs:
|
||||||
cached_disk_name: ${{ steps.get-disk-name.outputs.cached_disk_name }}
|
cached_disk_name: ${{ steps.get-disk-name.outputs.cached_disk_name }}
|
||||||
permissions:
|
permissions:
|
||||||
|
|
@ -314,6 +182,7 @@ jobs:
|
||||||
# TODO: move this script into a file, and call it from sub-find-cached-disks.yml as well.
|
# TODO: move this script into a file, and call it from sub-find-cached-disks.yml as well.
|
||||||
- name: Find ${{ inputs.test_id }} cached state disk
|
- name: Find ${{ inputs.test_id }} cached state disk
|
||||||
id: get-disk-name
|
id: get-disk-name
|
||||||
|
if: ${{ inputs.needs_zebra_state || inputs.needs_lwd_state }}
|
||||||
run: |
|
run: |
|
||||||
set -x
|
set -x
|
||||||
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)
|
||||||
|
|
@ -381,18 +250,21 @@ jobs:
|
||||||
|
|
||||||
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"
|
||||||
|
echo "DISK_OPTION=image=$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
|
||||||
|
# if the test needs it.
|
||||||
- name: Create ${{ inputs.test_id }} GCP compute instance
|
- name: Create ${{ inputs.test_id }} GCP compute instance
|
||||||
id: create-instance
|
id: create-instance
|
||||||
|
shell: /usr/bin/bash -x {0}
|
||||||
run: |
|
run: |
|
||||||
gcloud compute instances create-with-container "${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
|
gcloud compute instances create-with-container "${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}" \
|
||||||
--boot-disk-size 50GB \
|
--boot-disk-size 50GB \
|
||||||
--boot-disk-type pd-ssd \
|
--boot-disk-type pd-ssd \
|
||||||
--image-project=cos-cloud \
|
--image-project=cos-cloud \
|
||||||
--image-family=cos-stable \
|
--image-family=cos-stable \
|
||||||
--create-disk=image=${{ env.CACHED_DISK_NAME }},name="${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }}",device-name="${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }}",size=400GB,type=pd-ssd \
|
--create-disk=${DISK_OPTION}name="${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }}",device-name="${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }}",size=400GB,type=pd-ssd \
|
||||||
--container-image=gcr.io/google-containers/busybox \
|
--container-image=gcr.io/google-containers/busybox \
|
||||||
--machine-type ${{ vars.GCP_LARGE_MACHINE }} \
|
--machine-type ${{ vars.GCP_LARGE_MACHINE }} \
|
||||||
--network-interface=subnet=${{ vars.GCP_SUBNETWORK }} \
|
--network-interface=subnet=${{ vars.GCP_SUBNETWORK }} \
|
||||||
|
|
@ -403,29 +275,10 @@ jobs:
|
||||||
--tags ${{ inputs.app_name }} \
|
--tags ${{ inputs.app_name }} \
|
||||||
--zone ${{ vars.GCP_ZONE }}
|
--zone ${{ vars.GCP_ZONE }}
|
||||||
|
|
||||||
# Launch the test with the previously created Zebra-only cached state.
|
# Format the mounted disk if the test doesn't use a cached state.
|
||||||
# Each test runs one of the "Launch test" steps, and skips the other.
|
- name: Format ${{ inputs.test_id }} volume
|
||||||
#
|
if: ${{ !inputs.needs_zebra_state && !inputs.needs_lwd_state }}
|
||||||
# SSH into the just created VM, and create a Docker container to run the incoming test
|
shell: /usr/bin/bash -ex {0}
|
||||||
# from ${{ inputs.test_id }}, then mount the sudo docker volume created in the previous job.
|
|
||||||
#
|
|
||||||
# The disk mounted in the VM is located at /dev/$DISK_NAME, we mount the root `/` of this disk to the docker
|
|
||||||
# container in one path:
|
|
||||||
# - /var/cache/zebrad-cache -> ${{ inputs.root_state_path }}/${{ inputs.zebra_state_dir }} -> $ZEBRA_CACHED_STATE_DIR
|
|
||||||
#
|
|
||||||
# This path must match the variable used by the tests in Rust, which are also set in
|
|
||||||
# `ci-unit-tests-docker.yml` to be able to run this tests.
|
|
||||||
#
|
|
||||||
# Although we're mounting the disk root, Zebra will only respect the values from
|
|
||||||
# $ZEBRA_CACHED_STATE_DIR. The inputs like ${{ inputs.zebra_state_dir }} are only used
|
|
||||||
# to match that variable paths.
|
|
||||||
- name: Launch ${{ inputs.test_id }} test
|
|
||||||
# This step only runs for tests that just read or write a Zebra state.
|
|
||||||
#
|
|
||||||
# lightwalletd-full-sync reads Zebra and writes lwd, so it is handled specially.
|
|
||||||
# TODO: we should find a better logic for this use cases
|
|
||||||
if: ${{ (inputs.needs_zebra_state && !inputs.needs_lwd_state) && inputs.test_id != 'lwd-full-sync' }}
|
|
||||||
shell: /usr/bin/bash -exo pipefail {0}
|
|
||||||
run: |
|
run: |
|
||||||
gcloud compute ssh ${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
|
gcloud compute ssh ${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
|
||||||
--zone ${{ vars.GCP_ZONE }} \
|
--zone ${{ vars.GCP_ZONE }} \
|
||||||
|
|
@ -435,36 +288,14 @@ jobs:
|
||||||
--command=' \
|
--command=' \
|
||||||
set -ex;
|
set -ex;
|
||||||
# Extract the correct disk name based on the device-name
|
# Extract the correct disk name based on the device-name
|
||||||
export DISK_NAME=$(ls -l /dev/disk/by-id | grep -oE "google-${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }} -> ../../[^ ]+" | grep -oE "/[^/]+$" | cut -c 2-); \
|
DISK_NAME=$(ls -l /dev/disk/by-id | grep -oE "google-${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }} -> ../../[^ ]+" | grep -oE "/[^/]+$" | cut -c 2-);
|
||||||
|
sudo mkfs.ext4 -v /dev/$DISK_NAME \
|
||||||
sudo docker run \
|
|
||||||
--name ${{ inputs.test_id }} \
|
|
||||||
--tty \
|
|
||||||
--detach \
|
|
||||||
${{ inputs.test_variables }} \
|
|
||||||
--mount type=volume,volume-driver=local,volume-opt=device=/dev/$DISK_NAME,volume-opt=type=ext4,dst=${{ inputs.root_state_path }}/${{ inputs.zebra_state_dir }} \
|
|
||||||
${{ vars.GAR_BASE }}/${{ vars.CI_IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} \
|
|
||||||
'
|
'
|
||||||
|
|
||||||
# Show debug logs if previous job failed
|
# Launch the test with the previously created disk or cached state.
|
||||||
- name: Show debug logs if previous job failed
|
#
|
||||||
if: ${{ failure() && (inputs.needs_zebra_state && !inputs.needs_lwd_state) && inputs.test_id != 'lwd-full-sync' }}
|
# This step uses a $MOUNT_FLAGS variable to mount the disk to the docker container.
|
||||||
shell: /usr/bin/bash -exo pipefail {0}
|
# If the test needs Lightwalletd state, we add the Lightwalletd state mount to the $MOUNT_FLAGS variable.
|
||||||
run: |
|
|
||||||
gcloud compute ssh ${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
|
|
||||||
--zone ${{ vars.GCP_ZONE }} \
|
|
||||||
--ssh-flag="-o ServerAliveInterval=5" \
|
|
||||||
--ssh-flag="-o ConnectionAttempts=20" \
|
|
||||||
--ssh-flag="-o ConnectTimeout=5" \
|
|
||||||
--command=' \
|
|
||||||
lsblk;
|
|
||||||
sudo lsof /dev/$DISK_NAME;
|
|
||||||
sudo dmesg;
|
|
||||||
sudo journalctl -b \
|
|
||||||
'
|
|
||||||
|
|
||||||
# Launch the test with the previously created Lightwalletd and Zebra cached state.
|
|
||||||
# Each test runs one of the "Launch test" steps, and skips the other.
|
|
||||||
#
|
#
|
||||||
# SSH into the just created VM, and create a Docker container to run the incoming test
|
# SSH into the just created VM, and create a Docker container to run the incoming test
|
||||||
# from ${{ inputs.test_id }}, then mount the sudo docker volume created in the previous job.
|
# from ${{ inputs.test_id }}, then mount the sudo docker volume created in the previous job.
|
||||||
|
|
@ -473,8 +304,8 @@ jobs:
|
||||||
# VM and to the container might require more steps in this workflow, and additional
|
# VM and to the container might require more steps in this workflow, and additional
|
||||||
# considerations.
|
# considerations.
|
||||||
#
|
#
|
||||||
# The disk mounted in the VM is located at /dev/$DISK_NAME, we want the root `/` of this disk to be
|
# The disk mounted in the VM is located at /dev/$DISK_NAME, we mount the root `/` of this disk to the docker
|
||||||
# available in the docker container at two different paths:
|
# container, and might have two different paths (if lightwalletd state is needed):
|
||||||
# - /var/cache/zebrad-cache -> ${{ inputs.root_state_path }}/${{ inputs.zebra_state_dir }} -> $ZEBRA_CACHED_STATE_DIR
|
# - /var/cache/zebrad-cache -> ${{ inputs.root_state_path }}/${{ inputs.zebra_state_dir }} -> $ZEBRA_CACHED_STATE_DIR
|
||||||
# - /var/cache/lwd-cache -> ${{ inputs.root_state_path }}/${{ inputs.lwd_state_dir }} -> $LIGHTWALLETD_DATA_DIR
|
# - /var/cache/lwd-cache -> ${{ inputs.root_state_path }}/${{ inputs.lwd_state_dir }} -> $LIGHTWALLETD_DATA_DIR
|
||||||
#
|
#
|
||||||
|
|
@ -484,19 +315,16 @@ jobs:
|
||||||
# subdirectories for their data. (But Zebra, lightwalletd, and the test harness must not
|
# subdirectories for their data. (But Zebra, lightwalletd, and the test harness must not
|
||||||
# delete the whole cache directory.)
|
# delete the whole cache directory.)
|
||||||
#
|
#
|
||||||
# This paths must match the variables used by the tests in Rust, which are also set in
|
# These paths must match the variables used by the tests in Rust, which are also set in
|
||||||
# `ci-unit-tests-docker.yml` to be able to run this tests.
|
# `ci-unit-tests-docker.yml` to be able to run this tests.
|
||||||
#
|
#
|
||||||
# Although we're mounting the disk root to both directories, Zebra and Lightwalletd
|
# Although we're mounting the disk root to both directories, Zebra and Lightwalletd
|
||||||
# will only respect the values from $ZEBRA_CACHED_STATE_DIR and $LIGHTWALLETD_DATA_DIR,
|
# will only respect the values from $ZEBRA_CACHED_STATE_DIR and $LIGHTWALLETD_DATA_DIR,
|
||||||
# the inputs like ${{ inputs.lwd_state_dir }} are only used to match those variables paths.
|
# the inputs like ${{ inputs.zebra_state_dir }} and ${{ inputs.lwd_state_dir }}
|
||||||
|
# are only used to match those variables paths.
|
||||||
- name: Launch ${{ inputs.test_id }} test
|
- name: Launch ${{ inputs.test_id }} test
|
||||||
# This step only runs for tests that read or write Lightwalletd and Zebra states.
|
id: launch-test
|
||||||
#
|
shell: /usr/bin/bash -x {0}
|
||||||
# lightwalletd-full-sync reads Zebra and writes lwd, so it is handled specially.
|
|
||||||
# TODO: we should find a better logic for this use cases
|
|
||||||
if: ${{ (inputs.needs_zebra_state && inputs.needs_lwd_state) || inputs.test_id == 'lwd-full-sync' }}
|
|
||||||
shell: /usr/bin/bash -exo pipefail {0}
|
|
||||||
run: |
|
run: |
|
||||||
gcloud compute ssh ${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
|
gcloud compute ssh ${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
|
||||||
--zone ${{ vars.GCP_ZONE }} \
|
--zone ${{ vars.GCP_ZONE }} \
|
||||||
|
|
@ -504,24 +332,31 @@ jobs:
|
||||||
--ssh-flag="-o ConnectionAttempts=20" \
|
--ssh-flag="-o ConnectionAttempts=20" \
|
||||||
--ssh-flag="-o ConnectTimeout=5" \
|
--ssh-flag="-o ConnectTimeout=5" \
|
||||||
--command=' \
|
--command=' \
|
||||||
set -ex;
|
|
||||||
# Extract the correct disk name based on the device-name
|
# Extract the correct disk name based on the device-name
|
||||||
export DISK_NAME=$(ls -l /dev/disk/by-id | grep -oE "google-${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }} -> ../../[^ ]+" | grep -oE "/[^/]+$" | cut -c 2-); \
|
DISK_NAME=$(ls -l /dev/disk/by-id | grep -oE "google-${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }} -> ../../[^ ]+" | grep -oE "/[^/]+$" | cut -c 2-)
|
||||||
|
|
||||||
|
MOUNT_FLAGS="--mount type=volume,volume-driver=local,volume-opt=device=/dev/$DISK_NAME,volume-opt=type=ext4,dst=${{ inputs.root_state_path }}/${{ inputs.zebra_state_dir }}"
|
||||||
|
|
||||||
|
# Check if we need to mount for Lightwalletd state
|
||||||
|
# lightwalletd-full-sync reads Zebra and writes lwd, so it is handled specially.
|
||||||
|
if [[ "${{ inputs.needs_lwd_state }}" == "true" || "${{ inputs.test_id }}" == "lwd-full-sync" ]]; then
|
||||||
|
MOUNT_FLAGS="$MOUNT_FLAGS --mount type=volume,volume-driver=local,volume-opt=device=/dev/$DISK_NAME,volume-opt=type=ext4,dst=${{ inputs.root_state_path }}/${{ inputs.lwd_state_dir }}"
|
||||||
|
fi
|
||||||
|
|
||||||
sudo docker run \
|
sudo docker run \
|
||||||
--name ${{ inputs.test_id }} \
|
--name ${{ inputs.test_id }} \
|
||||||
--tty \
|
--tty \
|
||||||
--detach \
|
--detach \
|
||||||
${{ inputs.test_variables }} \
|
${{ inputs.test_variables }} \
|
||||||
--mount type=volume,volume-driver=local,volume-opt=device=/dev/$DISK_NAME,volume-opt=type=ext4,dst=${{ inputs.root_state_path }}/${{ inputs.zebra_state_dir }} \
|
${MOUNT_FLAGS} \
|
||||||
--mount type=volume,volume-driver=local,volume-opt=device=/dev/$DISK_NAME,volume-opt=type=ext4,dst=${{ inputs.root_state_path }}/${{ inputs.lwd_state_dir }} \
|
|
||||||
${{ vars.GAR_BASE }}/${{ vars.CI_IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} \
|
${{ vars.GAR_BASE }}/${{ vars.CI_IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }} \
|
||||||
'
|
'
|
||||||
|
|
||||||
# Show debug logs if previous job failed
|
# Show debug logs if previous job failed
|
||||||
- name: Show debug logs if previous job failed
|
- name: Show debug logs if previous job failed
|
||||||
if: ${{ failure() && (inputs.needs_zebra_state && inputs.needs_lwd_state) || inputs.test_id == 'lwd-full-sync' }}
|
if: ${{ failure() }}
|
||||||
shell: /usr/bin/bash -exo pipefail {0}
|
shell: /usr/bin/bash -x {0}
|
||||||
run: |
|
run: |
|
||||||
gcloud compute ssh ${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
|
gcloud compute ssh ${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
|
||||||
--zone ${{ vars.GCP_ZONE }} \
|
--zone ${{ vars.GCP_ZONE }} \
|
||||||
|
|
@ -535,58 +370,6 @@ jobs:
|
||||||
sudo journalctl -b \
|
sudo journalctl -b \
|
||||||
'
|
'
|
||||||
|
|
||||||
# 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
|
|
||||||
# We run exactly one of without-cached-state or with-cached-state, and we always skip the other one.
|
|
||||||
needs: [ launch-with-cached-state, launch-without-cached-state ]
|
|
||||||
# If the previous job fails, we also want to run and fail this job,
|
|
||||||
# so that the branch protection rule fails in Mergify and GitHub.
|
|
||||||
if: ${{ !cancelled() }}
|
|
||||||
timeout-minutes: ${{ inputs.is_long_test && 7200 || 180 }}
|
|
||||||
runs-on: zfnd-runners
|
|
||||||
permissions:
|
|
||||||
contents: 'read'
|
|
||||||
id-token: 'write'
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4.1.0
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
fetch-depth: '2'
|
|
||||||
|
|
||||||
- name: Inject slug/short variables
|
|
||||||
uses: rlespinasse/github-slug-action@v4
|
|
||||||
with:
|
|
||||||
short-length: 7
|
|
||||||
|
|
||||||
# Install our SSH secret
|
|
||||||
- name: Install private SSH key
|
|
||||||
uses: shimataro/ssh-key-action@v2.5.1
|
|
||||||
with:
|
|
||||||
key: ${{ secrets.GCP_SSH_PRIVATE_KEY }}
|
|
||||||
name: google_compute_engine
|
|
||||||
known_hosts: unnecessary
|
|
||||||
|
|
||||||
- name: Generate public SSH key
|
|
||||||
run: |
|
|
||||||
sudo apt-get update && sudo apt-get -qq install -y --no-install-recommends openssh-client
|
|
||||||
ssh-keygen -y -f ~/.ssh/google_compute_engine > ~/.ssh/google_compute_engine.pub
|
|
||||||
|
|
||||||
# Setup gcloud CLI
|
|
||||||
- name: Authenticate to Google Cloud
|
|
||||||
id: auth
|
|
||||||
uses: google-github-actions/auth@v1.1.1
|
|
||||||
with:
|
|
||||||
retries: '3'
|
|
||||||
workload_identity_provider: '${{ vars.GCP_WIF }}'
|
|
||||||
service_account: '${{ vars.GCP_DEPLOYMENTS_SA }}'
|
|
||||||
|
|
||||||
- name: Set up Cloud SDK
|
|
||||||
uses: google-github-actions/setup-gcloud@v1.1.1
|
|
||||||
|
|
||||||
# Show all the logs since the container launched,
|
# Show all the logs since the container launched,
|
||||||
# following until we see zebrad startup messages.
|
# following until we see zebrad startup messages.
|
||||||
#
|
#
|
||||||
|
|
@ -600,7 +383,7 @@ jobs:
|
||||||
#
|
#
|
||||||
# Errors in the tests are caught by the final test status job.
|
# Errors in the tests are caught by the final test status job.
|
||||||
- name: Check startup logs for ${{ inputs.test_id }}
|
- name: Check startup logs for ${{ inputs.test_id }}
|
||||||
shell: /usr/bin/bash -exo pipefail {0}
|
shell: /usr/bin/bash -x {0}
|
||||||
run: |
|
run: |
|
||||||
gcloud compute ssh ${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
|
gcloud compute ssh ${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
|
||||||
--zone ${{ vars.GCP_ZONE }} \
|
--zone ${{ vars.GCP_ZONE }} \
|
||||||
|
|
@ -608,10 +391,6 @@ jobs:
|
||||||
--ssh-flag="-o ConnectionAttempts=20" \
|
--ssh-flag="-o ConnectionAttempts=20" \
|
||||||
--ssh-flag="-o ConnectTimeout=5" \
|
--ssh-flag="-o ConnectTimeout=5" \
|
||||||
--command=' \
|
--command=' \
|
||||||
trap "" PIPE;
|
|
||||||
|
|
||||||
# Temporarily disable "set -e" to handle the broken pipe error gracefully
|
|
||||||
set +e;
|
|
||||||
sudo docker logs \
|
sudo docker logs \
|
||||||
--tail all \
|
--tail all \
|
||||||
--follow \
|
--follow \
|
||||||
|
|
@ -633,7 +412,7 @@ jobs:
|
||||||
# with that status.
|
# with that status.
|
||||||
# (`docker wait` can also wait for multiple containers, but we only ever wait for a single container.)
|
# (`docker wait` can also wait for multiple containers, but we only ever wait for a single container.)
|
||||||
- name: Result of ${{ inputs.test_id }} test
|
- name: Result of ${{ inputs.test_id }} test
|
||||||
shell: /usr/bin/bash -exo pipefail {0}
|
shell: /usr/bin/bash -x {0}
|
||||||
run: |
|
run: |
|
||||||
gcloud compute ssh ${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
|
gcloud compute ssh ${{ inputs.test_id }}-${{ env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }} \
|
||||||
--zone ${{ vars.GCP_ZONE }} \
|
--zone ${{ vars.GCP_ZONE }} \
|
||||||
|
|
@ -641,10 +420,6 @@ jobs:
|
||||||
--ssh-flag="-o ConnectionAttempts=20" \
|
--ssh-flag="-o ConnectionAttempts=20" \
|
||||||
--ssh-flag="-o ConnectTimeout=5" \
|
--ssh-flag="-o ConnectTimeout=5" \
|
||||||
--command=' \
|
--command=' \
|
||||||
trap "" PIPE;
|
|
||||||
|
|
||||||
# Temporarily disable "set -e" to handle the broken pipe error gracefully
|
|
||||||
set +e;
|
|
||||||
sudo docker logs \
|
sudo docker logs \
|
||||||
--tail all \
|
--tail all \
|
||||||
--follow \
|
--follow \
|
||||||
|
|
@ -653,7 +428,6 @@ jobs:
|
||||||
grep --max-count=1 --extended-regexp --color=always \
|
grep --max-count=1 --extended-regexp --color=always \
|
||||||
"test result: .*ok.* [1-9][0-9]* passed.*finished in";
|
"test result: .*ok.* [1-9][0-9]* passed.*finished in";
|
||||||
LOGS_EXIT_STATUS=$?;
|
LOGS_EXIT_STATUS=$?;
|
||||||
set -e;
|
|
||||||
|
|
||||||
EXIT_STATUS=$(sudo docker wait ${{ inputs.test_id }} || echo "Error retrieving exit status");
|
EXIT_STATUS=$(sudo docker wait ${{ inputs.test_id }} || echo "Error retrieving exit status");
|
||||||
echo "sudo docker exit status: $EXIT_STATUS";
|
echo "sudo docker exit status: $EXIT_STATUS";
|
||||||
|
|
@ -672,7 +446,7 @@ jobs:
|
||||||
create-state-image:
|
create-state-image:
|
||||||
name: Create ${{ inputs.test_id }} cached state image
|
name: Create ${{ inputs.test_id }} cached state image
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [ test-result, launch-with-cached-state ]
|
needs: [ test-result ]
|
||||||
# We run exactly one of without-cached-state or with-cached-state, and we always skip the other one.
|
# We run exactly one of without-cached-state or with-cached-state, and we always skip the other one.
|
||||||
# Normally, if a job is skipped, all the jobs that depend on it are also skipped.
|
# Normally, if a job is skipped, all the jobs that depend on it are also skipped.
|
||||||
# So we need to override the default success() check to make this job run.
|
# So we need to override the default success() check to make this job run.
|
||||||
|
|
@ -779,7 +553,7 @@ jobs:
|
||||||
# Passes the versions to subsequent steps using the $INITIAL_DISK_DB_VERSION,
|
# Passes the versions to subsequent steps using the $INITIAL_DISK_DB_VERSION,
|
||||||
# $RUNNING_DB_VERSION, and $DB_VERSION_SUMMARY env variables.
|
# $RUNNING_DB_VERSION, and $DB_VERSION_SUMMARY env variables.
|
||||||
- name: Get database versions from logs
|
- name: Get database versions from logs
|
||||||
shell: /usr/bin/bash -exo pipefail {0}
|
shell: /usr/bin/bash -x {0}
|
||||||
run: |
|
run: |
|
||||||
INITIAL_DISK_DB_VERSION=""
|
INITIAL_DISK_DB_VERSION=""
|
||||||
RUNNING_DB_VERSION=""
|
RUNNING_DB_VERSION=""
|
||||||
|
|
@ -869,7 +643,7 @@ jobs:
|
||||||
#
|
#
|
||||||
# Passes the sync height to subsequent steps using the $SYNC_HEIGHT env variable.
|
# Passes the sync height to subsequent steps using the $SYNC_HEIGHT env variable.
|
||||||
- name: Get sync height from logs
|
- name: Get sync height from logs
|
||||||
shell: /usr/bin/bash -exo pipefail {0}
|
shell: /usr/bin/bash -x {0}
|
||||||
run: |
|
run: |
|
||||||
SYNC_HEIGHT=""
|
SYNC_HEIGHT=""
|
||||||
|
|
||||||
|
|
@ -917,7 +691,7 @@ jobs:
|
||||||
- name: Get original cached state height from google cloud
|
- name: Get original cached state height from google cloud
|
||||||
run: |
|
run: |
|
||||||
ORIGINAL_HEIGHT="0"
|
ORIGINAL_HEIGHT="0"
|
||||||
ORIGINAL_DISK_NAME="${{ format('{0}', needs.launch-with-cached-state.outputs.cached_disk_name) }}"
|
ORIGINAL_DISK_NAME="${{ format('{0}', needs.test-result.outputs.cached_disk_name) }}"
|
||||||
|
|
||||||
if [[ -n "$ORIGINAL_DISK_NAME" ]]; then
|
if [[ -n "$ORIGINAL_DISK_NAME" ]]; then
|
||||||
ORIGINAL_HEIGHT=$(gcloud compute images list --filter="status=READY AND name=$ORIGINAL_DISK_NAME" --format="value(labels.height)")
|
ORIGINAL_HEIGHT=$(gcloud compute images list --filter="status=READY AND name=$ORIGINAL_DISK_NAME" --format="value(labels.height)")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue