Skip to content

Commit

Permalink
Fix CI run-tests (opensearch-project#110)
Browse files Browse the repository at this point in the history
This commit updates the recursion limit for
api_generator and avoids copying the src/bin
directory, which impacts ability to cache layers in
the docker image and is not required for tests.

(cherry picked from commit d645836)
  • Loading branch information
russcam committed Jun 18, 2020
1 parent 8d67092 commit c9da1b3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
29 changes: 17 additions & 12 deletions .ci/DockerFile
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,34 @@ ENV CFG_RELEASE_CHANNEL=nightly
# create app directory
WORKDIR /usr/src/elasticsearch-rs

# copy just the Cargo.toml (and certs), and create a "fake" [lib/main].rs so that Docker caches all package dependencies
# copy just enough to build dependencies
COPY .ci/certs ./.ci/certs
COPY Cargo.toml ./Cargo.toml
COPY README.md ./README.md
COPY elasticsearch/Cargo.toml ./elasticsearch/
COPY api_generator/Cargo.toml ./api_generator/
COPY yaml_test_runner/Cargo.toml ./yaml_test_runner/
COPY elasticsearch/Cargo.toml ./elasticsearch/Cargo.toml
COPY api_generator/Cargo.toml ./api_generator/Cargo.toml
COPY yaml_test_runner/Cargo.toml ./yaml_test_runner/Cargo.toml

# cache dependencies
RUN mkdir -p elasticsearch/src; \
echo "// dummy file" > elasticsearch/src/lib.rs; \
mkdir -p api_generator/src; \
echo "// dummy file" > api_generator/src/lib.rs; \
mkdir -p yaml_test_runner/src; \
echo "// dummy file" > yaml_test_runner/src/main.rs; \
cargo build --tests
cargo build --tests; \
rm elasticsearch/src/lib.rs; \
rm api_generator/src/lib.rs; \
rm yaml_test_runner/src/main.rs;

# install app dependencies and build
COPY elasticsearch ./elasticsearch
# copy all source
COPY elasticsearch/src ./elasticsearch/src
COPY elasticsearch/build.rs ./elasticsearch/build.rs
COPY api_generator ./api_generator
COPY yaml_test_runner ./yaml_test_runner

# Run cargo build separately on packages. Running cargo build at the workspace level fails for the api_generator/bin/run.rs
# This may be related to the caching hack above. TODO: Investigate
RUN cargo build -p api_generator; \
cargo build -p elasticsearch; \
cargo build -p yaml_test_runner
# build
RUN rm ./target/debug/deps/api_generator*; \
rm ./target/debug/deps/elasticsearch*; \
rm ./target/debug/deps/yaml_test_runner*; \
cargo build --tests;
5 changes: 2 additions & 3 deletions .ci/run-repository.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ echo -e "\033[1m>>>>> Run [elastic/elasticsearch-rs container] >>>>>>>>>>>>>>>>>

repo=$(realpath $(dirname $(realpath -s $0))/../)

# ES_TEST_SERVER en var is needed for cargo tests
# ES_TEST_SERVER env var is needed for cargo test
docker run \
--network=${network_name} \
--env "ES_TEST_SERVER=${ELASTICSEARCH_URL}" \
Expand All @@ -40,5 +40,4 @@ docker run \
"cargo run -p yaml_test_runner -- -u \"${ELASTICSEARCH_URL}\"; \\
mkdir -p test_results; \\
cargo test -p yaml_test_runner -- --test-threads=1 -Z unstable-options --format json | tee test_results/results.json; \\
cat test_results/results.json | cargo2junit > test_results/junit.xml"

cat test_results/results.json | cargo2junit > test_results/cargo-junit.xml"
7 changes: 5 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ target
docs
.vscode
.idea
elasticsearch/docs
elasticsearch/examples

api_generator/src/bin

yaml_test_runner/tests
!yaml_test_runner/tests/common
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* text=auto

*.sh text eol=lf
*.sh text eol=lf
.ci/run-tests text eol=lf
2 changes: 1 addition & 1 deletion api_generator/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// needed for quote!
#![recursion_limit = "256"]
#![recursion_limit = "512"]

#[macro_use]
extern crate lazy_static;
Expand Down

0 comments on commit c9da1b3

Please sign in to comment.