Skip to content

Commit

Permalink
fix broken test.sh node image replacement logic
Browse files Browse the repository at this point in the history
This fixes tests for PR disney#161. The test.sh file did not handle swapping in the node image maintained by meteor for version 14.21.4.
  • Loading branch information
donstephan committed Jul 24, 2024
1 parent 46143f4 commit d87db7e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env bash
source ./support.sh


exit_code=0 # Keep global, so that code below can get return value of this function
run_with_suppressed_output () {
run_with_suppressed_output() {
exit_code=0
logs=$(eval "$1 2>&1") || exit_code=$?
if [ $exit_code -ne 0 ]; then
Expand All @@ -15,9 +14,9 @@ run_with_suppressed_output () {
source ./versions.sh

if [ -n "${CI_VERSION:-}" ]; then
meteor_versions=( "$CI_VERSION" )
meteor_versions=("$CI_VERSION")
elif [[ "${1-x}" != x ]]; then
meteor_versions=( "$1" )
meteor_versions=("$1")
fi

cd example
Expand All @@ -39,7 +38,15 @@ for version in "${meteor_versions[@]}"; do

cp "${dockerfile}" test.dockerfile
do_sed "s|FROM geoffreybooth/meteor-base:.*|FROM geoffreybooth/meteor-base:${version}|" test.dockerfile
do_sed "s|FROM node:.*|FROM node:${node_version}-alpine|" test.dockerfile

if [[ $(get_version_string "${node_version}") -ge $(get_version_string 14.21.4) && $(get_version_string "${node_version}") -lt $(get_version_string 18.0.0) ]]; then
echo 'Using Meteor fork of Node Docker image...'
do_sed "s|FROM node:.*|FROM meteor/node:${node_version}-alpine3.17|" test.dockerfile
else
echo 'Using official Node Docker image...'
do_sed "s|FROM node:.*|FROM node:${node_version}-alpine|" test.dockerfile
fi

do_sed "s|/app|/test-app|g" test.dockerfile

cp docker-compose.yml test.docker-compose.yml
Expand All @@ -53,7 +60,7 @@ for version in "${meteor_versions[@]}"; do

# Poll until docker-compose network ready, timing out after 20 seconds
for i in {1..20}; do
(curl --silent --fail http://localhost/ | grep __meteor_runtime_config__) > /dev/null 2>&1 && break || {
(curl --silent --fail http://localhost/ | grep __meteor_runtime_config__) >/dev/null 2>&1 && break || {
if [ "$i" -lt 21 ]; then
sleep 1
else
Expand Down Expand Up @@ -97,7 +104,7 @@ for version in "${meteor_versions[@]}"; do
fi
done

if $at_least_one_failure ; then
if $at_least_one_failure; then
printf "${RED}FAIL! At least one image failed the test${NC}\n"
exit 1
else
Expand Down

0 comments on commit d87db7e

Please sign in to comment.