<commit_before>#!/bin/bash
# Create the GCE instance that will host the Staging VMs. All this script
# does is provision the instances; the actual config and tests are
# handled by the adjacent gce-runner script.
set -u
set -e

TOPLEVEL="$(git rev-parse --show-toplevel)"
# shellcheck source=devops/gce-nested/ci-env.sh
. "${TOPLEVEL}/devops/gce-nested/ci-env.sh"


function create_gce_ssh_key() {
    # Ensure SSH key in-place
    if [[ ! -f "$SSH_PUBKEY" ]]; then
        mkdir -p "$EPHEMERAL_DIRECTORY"
        ssh-keygen -f "$SSH_PRIVKEY" -q -P ""
    fi
}

# Lookup the latest GCE image available for use with SD CI.
# Value will be used in the create call.
function find_latest_ci_image() {
    gcloud_call compute images list \
        --filter="family:fpf-securedrop AND name ~ ^ci-nested-virt-stretch" \
        --sort-by=~Name --limit=1 --format="value(Name)"
}

# Call out to GCE API and start a new instance, designating
# the SD CI network settings.
function create_sd_ci_gce_instance() {
  # First check that a suitable instance isn't already running.
  if ! gcloud_call compute instances describe "${FULL_JOB_ID}" >/dev/null 2>&1; then
      # Fetch latest image id, for use in create call
      local ci_image<commit_msg>Hardcodes CI image id in scripts<commit_after>#!/bin/bash
# Create the GCE instance that will host the Staging VMs. All this script
# does is provision the instances; the actual config and tests are
# handled by the adjacent gce-runner script.
set -u
set -e

TOPLEVEL="$(git rev-parse --show-toplevel)"
# shellcheck source=devops/gce-nested/ci-env.sh
. "${TOPLEVEL}/devops/gce-nested/ci-env.sh"


function create_gce_ssh_key() {
    # Ensure SSH key in-place
    if [[ ! -f "$SSH_PUBKEY" ]]; then
        mkdir -p "$EPHEMERAL_DIRECTORY"
        ssh-keygen -f "$SSH_PRIVKEY" -q -P ""
    fi
}

# Lookup the latest GCE image available for use with SD CI.
# Value will be used in the create call.
function find_latest_ci_image() {
    #gcloud_call compute images list \
    #    --filter="family:fpf-securedrop AND name ~ ^ci-nested-virt-stretch" \
    #    --sort-by=~Name --limit=1 --format="value(Name)"
    # Return hardcoded image id to prevent newer builds from breaking CI
    echo "ci-nested-virt-stretch-1557975808"
}

# Call out to GCE API and start a new instance, designating
# the SD CI network settings.
function create_sd_ci_gce_instance() {
  # First check that a suitable instance isn't already running.
  if ! gcloud_call compute instances describe "${FULL_JOB_ID}" >/dev/null 2>&1; then
      # Fetch latest image id, for use in create call
      local ci_image
{'fraction_non_alphanumeric': 0.10711553175210406, 'fraction_numerical': 0.00612088752869166, 'mean_word_length': 3.3729096989966556, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2860979', 'n_tokens_mistral': 880, 'n_tokens_neox': 846, 'n_words': 295}