Use cargo frozen flag in build scripts (#206)

The cargo commands in our docker and ci scripts were at risk for
modifying Cargo.lock and cache.

Using cargo's --frozen flag (and --locked during fetch) ensures our
build is consistent with what's defined across Cargo.toml, Cargo.lock,
and cached build artifacts.

Signed-off-by: Andrew Seigner <siggy@buoyant.io>
This commit is contained in:
Andrew Seigner 2018-01-25 11:08:15 -08:00 committed by GitHub
parent 9410da471a
commit 4e2eb18f1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View File

@ -18,14 +18,15 @@ jobs:
# Compile the application and run tests.
- stage: test
language: rust
rust: stable
cache:
cargo: true
install:
- cargo fetch --locked
script:
- cargo check
- cargo test
- cargo check --frozen
- cargo test --frozen
- language: go
go: 1.9

View File

@ -20,8 +20,8 @@ COPY proto ./proto
COPY proxy ./proxy
ARG RELEASE
RUN if [ -z "$RELEASE" ]; \
then cargo build -p conduit-proxy && mv target/debug/conduit-proxy target/conduit-proxy ; \
else cargo build -p conduit-proxy --release && mv target/release/conduit-proxy target/conduit-proxy ; \
then cargo build --frozen -p conduit-proxy && mv target/debug/conduit-proxy target/conduit-proxy ; \
else cargo build --frozen -p conduit-proxy --release && mv target/release/conduit-proxy target/conduit-proxy ; \
fi
## Install the proxy binary into the base runtime image.

View File

@ -20,9 +20,9 @@ COPY tower-grpc ./tower-grpc
COPY Cargo.toml Cargo.lock ./
COPY proto ./proto
COPY proxy ./proxy
RUN cargo fetch
RUN cargo build -p conduit-proxy
RUN cargo build -p conduit-proxy --release
RUN cargo fetch --locked
RUN cargo build --frozen -p conduit-proxy
RUN cargo build --frozen -p conduit-proxy --release
# Preserve dependency sources and build artifacts without maintaining conduit
# sources/artifacts.