commit
b3fe000d51
37
functions.sh
37
functions.sh
|
@ -180,6 +180,24 @@ function get_fork_name() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_full_tag() {
|
||||||
|
local variant
|
||||||
|
local tag
|
||||||
|
local full_tag
|
||||||
|
variant="$1"
|
||||||
|
shift
|
||||||
|
tag="$1"
|
||||||
|
shift
|
||||||
|
if [ -z "${variant}" ]; then
|
||||||
|
full_tag="${tag}"
|
||||||
|
elif [ "${variant}" = "default" ]; then
|
||||||
|
full_tag="${tag}"
|
||||||
|
else
|
||||||
|
full_tag="${tag}-${variant}"
|
||||||
|
fi
|
||||||
|
echo "${full_tag}"
|
||||||
|
}
|
||||||
|
|
||||||
function get_full_version() {
|
function get_full_version() {
|
||||||
local version
|
local version
|
||||||
version=$1
|
version=$1
|
||||||
|
@ -206,6 +224,25 @@ function get_major_minor_version() {
|
||||||
echo "$(echo "${fullversion}" | cut -d'.' -f1).$(echo "${fullversion}" | cut -d'.' -f2)"
|
echo "$(echo "${fullversion}" | cut -d'.' -f1).$(echo "${fullversion}" | cut -d'.' -f2)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_path() {
|
||||||
|
local version
|
||||||
|
local variant
|
||||||
|
local path
|
||||||
|
version="$1"
|
||||||
|
shift
|
||||||
|
variant="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
if [ -z "${variant}" ]; then
|
||||||
|
path="${version}/${variant}"
|
||||||
|
elif [ "${variant}" = "default" ]; then
|
||||||
|
path="${version}"
|
||||||
|
else
|
||||||
|
path="${version}/${variant}"
|
||||||
|
fi
|
||||||
|
echo "${path}"
|
||||||
|
}
|
||||||
|
|
||||||
function get_tag() {
|
function get_tag() {
|
||||||
local version
|
local version
|
||||||
version=$1
|
version=$1
|
||||||
|
|
|
@ -27,16 +27,8 @@ function build() {
|
||||||
tag="$1"
|
tag="$1"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
if [ -z "${variant}" ]; then
|
full_tag=$(get_full_tag "${variant}" "${tag}")
|
||||||
full_tag="${tag}"
|
path=$(get_path "${version}" "${variant}")
|
||||||
path="${version}/${variant}"
|
|
||||||
elif [ "${variant}" = "default" ]; then
|
|
||||||
full_tag="${tag}"
|
|
||||||
path="${version}"
|
|
||||||
else
|
|
||||||
full_tag="${tag}-${variant}"
|
|
||||||
path="${version}/${variant}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
info "Building ${full_tag}..."
|
info "Building ${full_tag}..."
|
||||||
|
|
||||||
|
@ -44,9 +36,28 @@ function build() {
|
||||||
fatal "Build of ${full_tag} failed!"
|
fatal "Build of ${full_tag} failed!"
|
||||||
fi
|
fi
|
||||||
info "Build of ${full_tag} succeeded."
|
info "Build of ${full_tag} succeeded."
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_image() {
|
||||||
|
local full_version
|
||||||
|
local variant
|
||||||
|
local tag
|
||||||
|
local full_tag
|
||||||
|
full_version="$1"
|
||||||
|
shift
|
||||||
|
variant="$1"
|
||||||
|
shift
|
||||||
|
tag="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
full_tag=$(get_full_tag "${variant}" "${tag}")
|
||||||
|
|
||||||
info "Testing ${full_tag}"
|
info "Testing ${full_tag}"
|
||||||
docker run --rm -v "$PWD/test-image.sh:/usr/local/bin/test.sh" node:"${full_tag}" test.sh "${full_version}"
|
(
|
||||||
|
export full_version=${full_version}
|
||||||
|
export full_tag=${full_tag}
|
||||||
|
bats test-image.bats
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
cd "$(cd "${0%/*}" && pwd -P)" || exit
|
cd "$(cd "${0%/*}" && pwd -P)" || exit
|
||||||
|
@ -66,6 +77,7 @@ for version in "${versions[@]}"; do
|
||||||
# Required for chakracore
|
# Required for chakracore
|
||||||
if [ -f "${version}/Dockerfile" ]; then
|
if [ -f "${version}/Dockerfile" ]; then
|
||||||
build "${version}" "default" "${tag}"
|
build "${version}" "default" "${tag}"
|
||||||
|
test_image "${full_version}" "default" "${tag}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get supported variants according to the target architecture.
|
# Get supported variants according to the target architecture.
|
||||||
|
@ -78,9 +90,11 @@ for version in "${versions[@]}"; do
|
||||||
|
|
||||||
if [ "${variant}" = "onbuild" ]; then
|
if [ "${variant}" = "onbuild" ]; then
|
||||||
build "${version}" "${default_variant}" "$tag"
|
build "${version}" "${default_variant}" "$tag"
|
||||||
|
test_image "${full_version}" "${default_variant}" "$tag"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
build "${version}" "${variant}" "${tag}"
|
build "${version}" "${variant}" "${tag}"
|
||||||
|
test_image "${full_version}" "${variant}" "${tag}"
|
||||||
done
|
done
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
@test "Test for node and version" {
|
||||||
|
run docker run --rm -it node:"$full_tag" node -e "process.stdout.write(process.versions.node)"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$output" == "${full_version}" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "Test for npm" {
|
||||||
|
run docker run --rm -it node:"$full_tag" npm --version
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "Test for yarn" {
|
||||||
|
run docker run --rm -it node:"$full_tag" yarn --version
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
|
@ -1,18 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
if [ "$(node -e "process.stdout.write(process.versions.node)")" != "${1}" ]; then
|
|
||||||
echo "Test for node failed!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Test for node succeeded."
|
|
||||||
|
|
||||||
if ! npm --version >/dev/null; then
|
|
||||||
echo "Test for npm failed!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Test for npm succeeded."
|
|
||||||
|
|
||||||
if ! yarn --version >/dev/null; then
|
|
||||||
echo "Test of yarn failed!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Test for yarn succeeded."
|
|
Loading…
Reference in New Issue