From 7b401d82769fb93fb6cf88efe15c24d1f21e3a10 Mon Sep 17 00:00:00 2001 From: Alex Finnarn Date: Wed, 6 Mar 2024 12:46:46 -0500 Subject: [PATCH] update scripts --- .tugboat/config.yml | 14 -------------- scripts/next-build-frontend.sh | 15 +++++++-------- scripts/next-install.sh | 2 ++ scripts/next-start.sh | 13 +++++++++++++ 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.tugboat/config.yml b/.tugboat/config.yml index 1f5a83dfa2..b5caf1add9 100644 --- a/.tugboat/config.yml +++ b/.tugboat/config.yml @@ -37,7 +37,6 @@ services: # General useful development tools - apt-get install jq nano -# @todo Can cypress/included image be used instead? # cypress-axe dependencies - https://docs.cypress.io/guides/getting-started/installing-cypress.html#System-requirements - apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb @@ -74,7 +73,6 @@ services: # The internal tools ALB idle timeout is set to longer than a typical GQL query takes. - sed -e 's/KeepAliveTimeout 5/KeepAliveTimeout 185/' -i /etc/apache2/apache2.conf -# @todo These should be aligned with other environments... # BRD Environments are set to 1G, Tugboat and Lando are -1 (unlimited). - echo "memory_limit = 4G" >> /usr/local/etc/php/conf.d/my-php.ini # Set unlimited memory limit for PHP CLI to allow Composer to run. @@ -143,7 +141,6 @@ services: - ./scripts/install-nvm.sh # Ensure that we're using version 2 of composer. -# @todo I'm guessing it is always version two now... - composer self-update --2 # Install the Task task runner/build tool. @@ -166,7 +163,6 @@ services: update: # Install/update packages managed by composer, including drush. # Composer options are in composer.json, 'config' key. -# @todo Isn't this already done in the build step? - composer install - bash -lc 'nvm install' - bash -lc 'npm install' @@ -196,7 +192,6 @@ services: # This j2 command is shared in both the build & clone stages. If modifying, change the other too. - j2 "${TUGBOAT_ROOT}/.tugboat/.env.j2" -o "${TUGBOAT_ROOT}/.env" -# @todo If this is shared, why not abstract it to a script? # This command is shared by the clone and build stages, make sure to update both stages. - j2 "${TUGBOAT_ROOT}/.web/403-error-document.j2.html" -o "${TUGBOAT_ROOT}/.web/403-error-document.html" - j2 "${TUGBOAT_ROOT}/.storybook/403-error-document.j2.html" -o "${TUGBOAT_ROOT}/.storybook/403-error-document.html" @@ -258,15 +253,6 @@ services: - find -L "${DOCROOT}/vendor/va-gov/content-build/node_modules/.bin" -type f -exec chmod +x {} \+ - find "${DOCROOT}/vendor/va-gov/content-build/script" -type f -exec chmod +x {} \+ - # Put necessary env variables in place for next's Drupal Preview before building server - # Need to construct this way instead of TUGBOAT_DEFAULT_SERVICE_URL in order to drop the trailing / -# @todo Can the config file use set env vars and these commands set them? -# @todo e.g. TUGBOAT_DEFAULT_SERVICE_URL=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN} - - echo "NEXT_PUBLIC_DRUPAL_BASE_URL=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat - - echo "NEXT_IMAGE_DOMAIN=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat - - echo "DRUPAL_CLIENT_ID=${DRUPAL_CLIENT_ID}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat - - echo "DRUPAL_CLIENT_SECRET=${DRUPAL_CLIENT_SECRET}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat - # Build storybook and the frontends (web, next) in parallel - bash -lc 'time task --taskfile=tugboat.yml' diff --git a/scripts/next-build-frontend.sh b/scripts/next-build-frontend.sh index 106a53a1d1..fd3d37e9f6 100644 --- a/scripts/next-build-frontend.sh +++ b/scripts/next-build-frontend.sh @@ -58,8 +58,10 @@ if [ "${next_build_version}" != "__default" ]; then echo "==> Checking out the requested frontend version" >> ${logfile} pushd ${reporoot}/next - # Stash any local changes. - git stash &>> ${logfile} + # Reset the working directory to the last commit. + # This is necessary because we set some env vars in "next-start.sh" for Tugboat + # which prevents the checkout from working if the working directory is dirty. + git reset --hard &>> ${logfile} if echo "${next_build_version}" | grep -qE '^[0-9]+$' > /dev/null; then echo "==> Checking out PR #${next_build_version}" @@ -70,16 +72,11 @@ if [ "${next_build_version}" != "__default" ]; then fi git checkout FETCH_HEAD &>> ${logfile} - # Pop the stash if we stashed anything. - git stash pop &>> ${logfile} - popd else echo "==> Using default next-build version" >> ${logfile} fi -# Stop the next server. - # Install 3rd party deps. echo "==> Installing yarn dependencies" >> ${logfile} composer va:next:install &>> ${logfile} @@ -102,7 +99,9 @@ else fi # Build vets-website again. -${reporoot}/scripts/vets-web-setup.sh +# @todo Do the symlinks need to be re-created? +echo "==> Re-building Vets Website" >> ${logfile} +${reporoot}/scripts/vets-web-setup.sh &>> ${logfile} # Run the build. echo "==> Starting build" >> ${logfile} diff --git a/scripts/next-install.sh b/scripts/next-install.sh index d75e3dd451..e2edfd0146 100755 --- a/scripts/next-install.sh +++ b/scripts/next-install.sh @@ -38,4 +38,6 @@ echo "Node $(node -v)" echo "NPM $(npm -v)" echo "Yarn $(yarn -v)" +# @todo Should the manual steps go here like copying the .env file? or maybe in next-start.sh? + yarn install diff --git a/scripts/next-start.sh b/scripts/next-start.sh index 99e451d759..595ef7389c 100755 --- a/scripts/next-start.sh +++ b/scripts/next-start.sh @@ -22,8 +22,21 @@ NEXT_SERVER_PIDS=$(ps aux | grep '[.]/scripts/yarn/start.js' | awk '{print $2}') # In case we have multiple processes, loop through them. for pid in ${NEXT_SERVER_PIDS}; do + echo "Killing process ${pid}..." kill $pid done +# Set environment variables if on Tugboat. +if [ "${APP_ENV}" == "tugboat" ]; then + echo "Setting up Tugboat environment variables for Next.js..." + + # Put necessary env variables in place for next's Drupal Preview before building server + # Need to construct this way instead of TUGBOAT_DEFAULT_SERVICE_URL in order to drop the trailing / + echo "NEXT_PUBLIC_DRUPAL_BASE_URL=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}" >> ${ROOT}/next/envs/.env.tugboat + echo "NEXT_IMAGE_DOMAIN=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}" >> ${ROOT}/next/envs/.env.tugboat + echo "DRUPAL_CLIENT_ID=${DRUPAL_CLIENT_ID}" >> ${ROOT}/next/envs/.env.tugboat + echo "DRUPAL_CLIENT_SECRET=${DRUPAL_CLIENT_SECRET}" >> ${ROOT}/next/envs/.env.tugboat +fi + # Start the dev server. Vets-website assets need to be in place prior to this build. yarn start