Skip to content

Commit

Permalink
Adds ICU test environments by version
Browse files Browse the repository at this point in the history
This will allow us to run CI builds for each combination of ICU versions
and features.  Issue google#38 will be resolved once all environments of
interest are being tested.  This commit adds only one new test target,
as an example.
  • Loading branch information
filmil committed Jan 9, 2020
1 parent 341499b commit 6c54e3a
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 15 deletions.
23 changes: 20 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ else
TTY :=
endif

# The buildenv version that will be used to build and test.
USED_BUILDENV_VERSION := 0.0.3
# The buildenv version that will be used to build and test. This allows us to
# update the buildenv code but not use it immediately. You can modify the
# buildenv version by passing its value through env variables like so:
#
# make USED_BUILDENV_VERSION=whatever-you-want docker-test
USED_BUILDENV_VERSION ?= 0.0.3

test:
env LD_LIBRARY_PATH="$(shell icu-config --libdir)" cargo test
Expand All @@ -21,16 +25,29 @@ test:
# so that as much as possible of the host configuration is retained.
TMP ?= /tmp
CARGO_TARGET_DIR := ${TMP}/rust_icu-${USER}-target

# The docker testing target. Used to run tests in a dockerized environment,
# based off of a fresh checkout of source in the current directory.
# Pass different values for DOCKER_TEST_ENV and DOCKER_TEST_CARGO_TEST_ARGS to
# test different configurations. This is useful in Travis CI matrix tests, for
# example.
DOCKER_TEST_ENV ?= rust_icu_testenv-64
DOCKER_TEST_CARGO_TEST_ARGS ?=
docker-test:
mkdir -p ${CARGO_TARGET_DIR}
docker run ${TTY} \
--user=${UID}:${GID} \
--volume=${TOP_DIR}:/src/rust_icu \
--volume=${CARGO_TARGET_DIR}:/build/cargo \
--volume=${HOME}/.cargo:/usr/local/cargo \
${DOCKER_REPO}/rust_icu_testenv:${USED_BUILDENV_VERSION}
--env="CARGO_TEST_ARGS=${DOCKER_TEST_CARGO_TEST_ARGS}" \
${DOCKER_REPO}/${DOCKER_TEST_ENV}:${USED_BUILDENV_VERSION}
.PHONY: docker-test

docker-test-65-renaming:
$(call run-docker-test,rust_icu_testenv-65,--no-default-features --features=renaming)
.PHONY: docker-test-65-renaming

# Builds and pushes the build environment containers. You would not normally
# need to do this.
buildenv:
Expand Down
5 changes: 3 additions & 2 deletions build/Dockerfile.maint-64 → build/Dockerfile.maint
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
ARG DOCKER_REPO=filipfilmar
ARG VERSION=0.0.0
ARG ICU_VERSION_TAG=maint/maint-64
FROM $DOCKER_REPO/rust_icu_buildenv:$VERSION AS buildenv

# Install ICU from source.
ENV ICU_SOURCE_DIR="/src/icu"
RUN git clone https://github.com/unicode-org/icu.git && \
cd $ICU_SOURCE_DIR && \
git fetch origin maint/maint-64 && \
git checkout maint/maint-64
git fetch origin $ICU_VERSION_TAG && \
git checkout $ICU_VERSION_TAG

ENV ICU4C_BUILD_DIR=/build/icu4c-build
RUN mkdir -p $ICU4C_BUILD_DIR && \
Expand Down
14 changes: 7 additions & 7 deletions build/Dockerfile.testenv
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# on source that has been mounted in.
ARG DOCKER_REPO=filipfilmar
ARG VERSION=0.0.0
FROM $DOCKER_REPO/rust_icu_maint-64:$VERSION AS buildenv
ARG ICU_VERSION_TAG=maint-64
FROM $DOCKER_REPO/rust_icu_$ICU_VERSION_TAG:$VERSION AS buildenv

# Mount the rust_icu source top level directory here.
ENV RUST_ICU_SOURCE_DIR=/src/rust_icu
Expand All @@ -14,11 +15,10 @@ RUN mkdir -p $RUST_ICU_SOURCE_DIR && \
/build \
/usr/local/cargo

RUN ls -lR /src /build $HOME && ls -ld /
COPY entrypoint.sh /entrypoint.sh
RUN chmod a+rwx /entrypoint.sh

ENTRYPOINT ( \
cd $RUST_ICU_SOURCE_DIR; \
cargo install bindgen rustfmt; \
env LD_LIBRARY_PATH=/usr/local/lib cargo test; \
)

ENV CARGO_TEST_ARGS=""
ENTRYPOINT /entrypoint.sh

31 changes: 28 additions & 3 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,42 @@ VERSION ?= $(RAW_VERSION:buildenv-%=%)
# The docker repo should be a more official one.
DOCKER_REPO ?= filipfilmar

.DEFAULT_GOAL: all

build-%: Dockerfile.%
docker build \
--build-arg DOCKER_REPO=${DOCKER_REPO} \
--build-arg VERSION=${VERSION} \
-f $< -t $*:latest .
-f $< -t rust_icu_$*:latest .

build-maint-%: Dockerfile.maint
docker build \
--build-arg DOCKER_REPO=${DOCKER_REPO} \
--build-arg VERSION=${VERSION} \
--build-arg ICU_VERSION_TAG=maint/maint-$* \
-f $< -t rust_icu_maint-$*:latest .

build-testenv-%: Dockerfile.testenv
docker build \
--build-arg DOCKER_REPO=${DOCKER_REPO} \
--build-arg VERSION=${VERSION} \
--build-arg ICU_VERSION_TAG=maint-$* \
-f $< -t rust_icu_testenv-$*:latest .

tag-%: build-%
docker tag $*:latest ${DOCKER_REPO}/rust_icu_$*:${VERSION}
docker tag rust_icu_$*:latest ${DOCKER_REPO}/rust_icu_$*:${VERSION}

push-%: tag-%
docker push ${DOCKER_REPO}/rust_icu_$*:${VERSION}

all: push-buildenv push-maint-64 push-hermetic push-testenv
all: \
push-buildenv \
push-maint-64 \
push-testenv-64 \
push-maint-65 \
push-testenv-65 \
push-maint-66 \
push-testenv-66 \
push-testenv \
push-hermetic
echo "buildenv-version: ${VERSION}"
15 changes: 15 additions & 0 deletions build/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /bin/bash
set -x
env
cd $RUST_ICU_SOURCE_DIR
cargo install bindgen rustfmt
(
cd rust_icu_sys
env LD_LIBRARY_PATH="/usr/local/lib" cargo test ${CARGO_TEST_ARGS}
)
(
cd rust_icu_common
env LD_LIBRARY_PATH="/usr/local/lib" cargo test ${CARGO_TEST_ARGS}
)
env LD_LIBRARY_PATH="/usr/local/lib" cargo test

0 comments on commit 6c54e3a

Please sign in to comment.