Skip to content

Commit d645836

Browse files
authored
Fix CI run-tests (#110)
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.
1 parent 5fe1e53 commit d645836

File tree

5 files changed

+27
-19
lines changed

5 files changed

+27
-19
lines changed

.ci/DockerFile

+17-12
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,34 @@ ENV CFG_RELEASE_CHANNEL=nightly
5050
# create app directory
5151
WORKDIR /usr/src/elasticsearch-rs
5252

53-
# copy just the Cargo.toml (and certs), and create a "fake" [lib/main].rs so that Docker caches all package dependencies
53+
# copy just enough to build dependencies
5454
COPY .ci/certs ./.ci/certs
5555
COPY Cargo.toml ./Cargo.toml
5656
COPY README.md ./README.md
57-
COPY elasticsearch/Cargo.toml ./elasticsearch/
58-
COPY api_generator/Cargo.toml ./api_generator/
59-
COPY yaml_test_runner/Cargo.toml ./yaml_test_runner/
57+
COPY elasticsearch/Cargo.toml ./elasticsearch/Cargo.toml
58+
COPY api_generator/Cargo.toml ./api_generator/Cargo.toml
59+
COPY yaml_test_runner/Cargo.toml ./yaml_test_runner/Cargo.toml
6060

61+
# cache dependencies
6162
RUN mkdir -p elasticsearch/src; \
6263
echo "// dummy file" > elasticsearch/src/lib.rs; \
6364
mkdir -p api_generator/src; \
6465
echo "// dummy file" > api_generator/src/lib.rs; \
6566
mkdir -p yaml_test_runner/src; \
6667
echo "// dummy file" > yaml_test_runner/src/main.rs; \
67-
cargo build --tests
68+
cargo build --tests; \
69+
rm elasticsearch/src/lib.rs; \
70+
rm api_generator/src/lib.rs; \
71+
rm yaml_test_runner/src/main.rs;
6872

69-
# install app dependencies and build
70-
COPY elasticsearch ./elasticsearch
73+
# copy all source
74+
COPY elasticsearch/src ./elasticsearch/src
75+
COPY elasticsearch/build.rs ./elasticsearch/build.rs
7176
COPY api_generator ./api_generator
7277
COPY yaml_test_runner ./yaml_test_runner
7378

74-
# Run cargo build separately on packages. Running cargo build at the workspace level fails for the api_generator/bin/run.rs
75-
# This may be related to the caching hack above. TODO: Investigate
76-
RUN cargo build -p api_generator; \
77-
cargo build -p elasticsearch; \
78-
cargo build -p yaml_test_runner
79+
# build
80+
RUN rm ./target/debug/deps/api_generator*; \
81+
rm ./target/debug/deps/elasticsearch*; \
82+
rm ./target/debug/deps/yaml_test_runner*; \
83+
cargo build --tests;

.ci/run-repository.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ echo -e "\033[1m>>>>> Run [elastic/elasticsearch-rs container] >>>>>>>>>>>>>>>>>
2828

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

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

.dockerignore

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@ target
66
docs
77
.vscode
88
.idea
9-
elasticsearch/docs
10-
elasticsearch/examples
9+
10+
api_generator/src/bin
11+
12+
yaml_test_runner/tests
13+
!yaml_test_runner/tests/common

.gitattributes

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
* text=auto
22

3-
*.sh text eol=lf
3+
*.sh text eol=lf
4+
.ci/run-tests text eol=lf

api_generator/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// needed for quote!
2-
#![recursion_limit = "256"]
2+
#![recursion_limit = "512"]
33

44
#[macro_use]
55
extern crate lazy_static;

0 commit comments

Comments
 (0)