Skip to content

Commit ecea9da

Browse files
rexhoffmanbors-libra
authored andcommitted
[cargo] use unstable cargo feature resolver.
Closes: diem#5199 Approved by: sausagee
1 parent fd1a837 commit ecea9da

File tree

12 files changed

+78
-30
lines changed

12 files changed

+78
-30
lines changed

.circleci/config.yml

+43-28
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ commands:
5151
echo 'export LIBRA_DUMP_LOGS=1' >> $BASH_ENV
5252
echo 'export CARGO_INCREMENTAL=0' >> $BASH_ENV
5353
echo 'export CI_TIMEOUT="timeout 40m"' >> $BASH_ENV
54-
echo 'export RUST_NIGHTLY=nightly-2020-07-08' >> $BASH_ENV
54+
export RUST_NIGHTLY=$(cat cargo-toolchain)
55+
echo 'export RUST_NIGHTLY='${RUST_NIGHTLY} >> $BASH_ENV
56+
5557
install_deps:
5658
steps:
5759
- run:
@@ -65,11 +67,12 @@ commands:
6567
- run:
6668
name: Set cargo Environment
6769
command: |
70+
# https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#features
71+
export CARGOFLAGS=$(cat cargo-flags)
72+
echo 'export CARGOFLAGS='${CARGOFLAGS} >> $BASH_ENV
6873
# Use nightly version of cargo to access the new feature resolver
6974
echo 'export CARGO=$(rustup which --toolchain $RUST_NIGHTLY cargo)' >> $BASH_ENV
7075
# Turn on the experimental feature resolver in cargo. See:
71-
# https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#features
72-
echo 'export CARGOFLAGS=-Zfeatures=all' >> $BASH_ENV
7376
install_code_coverage_deps:
7477
steps:
7578
- run:
@@ -622,18 +625,20 @@ jobs:
622625
- run:
623626
name: should pre build docker images (targeting a release branch)?
624627
command: |
625-
export RELEASE_BRANCH_PATTERN='^v[0-9]+-release$'
626-
export TEST_BRANCH_PATTERN="^testflow[0-9]+$"
627628
export commit_message=$( git log -1 --pretty=%B )
628629
export pr_num=`echo "$commit_message" | tail -2 | head -1 | sed 's/Closes: #//'`
629630
if [ -z $pr_num ]; then
630631
echo "Did not find pull request num in commit message. -\\_(O_o)_/-";
631632
exit 1
632633
fi
633634
curl -o /tmp/pr https://api.github.com/repos/libra/libra/pulls/${pr_num}
634-
export TARGET_BRANCH=$( cat /tmp/pr | jq ".base .ref" | sed 's/"//g' )
635-
if [[ $TARGET_BRANCH =~ $RELEASE_BRANCH_PATTERN ]] || [[ $TARGET_BRANCH =~ $TEST_BRANCH_PATTERN ]]; then
636-
export BRANCH=$TARGET_BRANCH
635+
export BRANCH=$( cat /tmp/pr | jq ".base .ref" | sed 's/"//g' )
636+
637+
export IS_RELEASE=$( if [[ "$BRANCH" =~ "^v[0-9|.]+-release$" ]]; then echo true; else echo false; fi )
638+
export IS_TEST=$( if [[ "$BRANCH" =~ "^testflow[0-9|.]+$" ]]; then echo true; else echo false; fi )
639+
export IS_PRE_RELEASE=$( if [[ "$BRANCH" =~ "^premainnet-[0-9|.]+$" ]]; then echo true; else echo false; fi )
640+
641+
if [[ $IS_RELEASE || $IS_TEST || $IS_PRE_RELEASE ]] ; then
637642
echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
638643
docker/update_or_build.sh -u -p -b ${BRANCH} -n client
639644
docker/update_or_build.sh -u -p -b ${BRANCH} -n init
@@ -679,16 +684,18 @@ workflows:
679684
ignore:
680685
- gh-pages
681686
- master
682-
- /^testflow[\d]+$/
683-
- /^v[\d]+-release$/
687+
- /^testflow[\d|.]+$/
688+
- /^premainnet-[\d|.]+$/
689+
- /^v[\d|.]+-release$/
684690
- terraform:
685691
filters:
686692
branches:
687693
ignore:
688694
- gh-pages
689695
- master
690-
- /^testflow[\d]+$/
691-
- /^v[\d]+-release$/
696+
- /^testflow[\d|.]+$/
697+
- /^premainnet-[\d|.]+$/
698+
- /^v[\d|.]+-release$/
692699
- prefetch-crates
693700
- lint:
694701
requires:
@@ -697,8 +704,9 @@ workflows:
697704
branches:
698705
ignore:
699706
- gh-pages
700-
- /^testflow[\d]+$/
701-
- /^v[\d]+-release$/
707+
- /^testflow[\d|.]+$/
708+
- /^premainnet-0.[\d|.]+$/
709+
- /^v[\d|.]+-release$/
702710
- build-dev:
703711
requires:
704712
- prefetch-crates
@@ -707,8 +715,9 @@ workflows:
707715
ignore:
708716
- gh-pages
709717
- master
710-
- /^testflow[\d]+$/
711-
- /^v[\d]+-release$/
718+
- /^testflow[\d|.]+$/
719+
- /^premainnet-[\d|.]+$/
720+
- /^v[\d|.]+-release$/
712721
- build-release:
713722
requires:
714723
- prefetch-crates
@@ -717,8 +726,9 @@ workflows:
717726
ignore:
718727
- gh-pages
719728
- master
720-
- /^testflow[\d]+$/
721-
- /^v[\d]+-release$/
729+
- /^testflow[\d|.]+$/
730+
- /^premainnet-[\d|.]+$/
731+
- /^v[\d|.]+-release$/
722732
- run-e2e-test:
723733
requires:
724734
- prefetch-crates
@@ -727,8 +737,9 @@ workflows:
727737
ignore:
728738
- gh-pages
729739
- master
730-
- /^testflow[\d]+$/
731-
- /^v[\d]+-release$/
740+
- /^testflow[\d|.]+$/
741+
- /^premainnet-[\d|.]+$/
742+
- /^v[\d|.]+-release$/
732743
- run-unit-test:
733744
requires:
734745
- prefetch-crates
@@ -737,8 +748,9 @@ workflows:
737748
ignore:
738749
- gh-pages
739750
- master
740-
- /^testflow[\d]+$/
741-
- /^v[\d]+-release$/
751+
- /^testflow[\d|.]+$/
752+
- /^premainnet-[\d|.]+$/
753+
- /^v[\d|.]+-release$/
742754
- run-crypto-unit-test:
743755
requires:
744756
- prefetch-crates
@@ -747,17 +759,19 @@ workflows:
747759
ignore:
748760
- gh-pages
749761
- master
750-
- /^testflow[\d]+$/
751-
- /^v[\d]+-release$/
762+
- /^testflow[\d|.]+$/
763+
- /^premainnet-[\d|.]+$/
764+
- /^v[\d|.]+-release$/
752765
- build-docs:
753766
requires:
754767
- lint
755768
filters:
756769
branches:
757770
ignore:
758771
- gh-pages
759-
- /^testflow[\d]+$/
760-
- /^v[\d]+-release$/
772+
- /^testflow[\d|.]+$/
773+
- /^premainnet-[\d|.]+$/
774+
- /^v[\d|.]+-release$/
761775
- deploy-docs:
762776
requires:
763777
- build-docs
@@ -779,8 +793,9 @@ workflows:
779793
filters:
780794
branches:
781795
only:
782-
- /^testflow[\d]+$/
783-
- /^v[\d]+-release$/
796+
- /^testflow[\d|.]+$/
797+
- /^premainnet-[\d|.]+$/
798+
- /^v[\d|.]+-release$/
784799

785800
scheduled-workflow:
786801
triggers:

cargo-flags

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Zfeatures=all

cargo-toolchain

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nightly-2020-07-08

docker/build-common.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ set -e
77
# It unifies RUSFLAGS, compilation flags (like --release) and set of binary crates to compile in common docker layer
88

99
export RUSTFLAGS="-Ctarget-cpu=skylake -Ctarget-feature=+aes,+sse2,+sse4.1,+ssse3"
10-
cargo build --release -p libra-genesis-tool -p libra-node -p cli -p config-builder -p libra-key-manager -p safety-rules -p db-bootstrapper -p backup-cli -p cluster-test "$@"
10+
11+
# We are using a pinned nightly cargo until feature resolver v2 is released (around 10/2020), but compiling with stable rustc
12+
export RUST_NIGHTLY=$(cat cargo-toolchain)
13+
export CARGO=$(rustup which --toolchain $RUST_NIGHTLY cargo)
14+
export CARGOFLAGS=$(cat cargo-flags)
15+
16+
${CARGO} ${CARGOFLAGS} build --release -p libra-genesis-tool -p libra-node -p cli -p config-builder -p libra-key-manager -p safety-rules -p db-bootstrapper -p backup-cli -p cluster-test "$@"
1117

1218
rm -rf target/release/{build,deps,incremental}
1319

docker/client/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ WORKDIR /libra
1212
COPY rust-toolchain /libra/rust-toolchain
1313
RUN rustup install $(cat rust-toolchain)
1414

15+
COPY cargo-toolchain /libra/cargo-toolchain
16+
RUN rustup install $(cat cargo-toolchain)
17+
1518
FROM toolchain AS builder
1619

1720
COPY . /libra

docker/cluster-test/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ WORKDIR /libra
1212
COPY rust-toolchain /libra/rust-toolchain
1313
RUN rustup install $(cat rust-toolchain)
1414

15+
COPY cargo-toolchain /libra/cargo-toolchain
16+
RUN rustup install $(cat cargo-toolchain)
17+
1518
FROM toolchain AS builder
1619

1720
COPY . /libra

docker/init/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ WORKDIR /libra
1212
COPY rust-toolchain /libra/rust-toolchain
1313
RUN rustup install $(cat rust-toolchain)
1414

15+
COPY cargo-toolchain /libra/cargo-toolchain
16+
RUN rustup install $(cat cargo-toolchain)
17+
1518
FROM toolchain AS builder
1619

1720
COPY . /libra

docker/mint/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ WORKDIR /libra
1212
COPY rust-toolchain /libra/rust-toolchain
1313
RUN rustup install $(cat rust-toolchain)
1414

15+
COPY cargo-toolchain /libra/cargo-toolchain
16+
RUN rustup install $(cat cargo-toolchain)
17+
1518
FROM toolchain AS builder
1619

1720
COPY . /libra

docker/safety-rules/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ WORKDIR /libra
1212
COPY rust-toolchain /libra/rust-toolchain
1313
RUN rustup install $(cat rust-toolchain)
1414

15+
COPY cargo-toolchain /libra/cargo-toolchain
16+
RUN rustup install $(cat cargo-toolchain)
17+
1518
FROM toolchain AS builder
1619

1720
COPY . /libra

docker/tools/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ WORKDIR /libra
1212
COPY rust-toolchain /libra/rust-toolchain
1313
RUN rustup install $(cat rust-toolchain)
1414

15+
COPY cargo-toolchain /libra/cargo-toolchain
16+
RUN rustup install $(cat cargo-toolchain)
17+
1518
FROM toolchain AS builder
1619

1720
COPY . /libra

docker/validator/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ WORKDIR /libra
1212
COPY rust-toolchain /libra/rust-toolchain
1313
RUN rustup install $(cat rust-toolchain)
1414

15+
COPY cargo-toolchain /libra/cargo-toolchain
16+
RUN rustup install $(cat cargo-toolchain)
17+
1518
FROM toolchain AS builder
1619

1720
COPY . /libra

scripts/coverage_report.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ export RUST_MIN_STACK=8388608 # 8 * 1024 * 1024
9090
echo "Cleaning project..."
9191
(cd "$TEST_DIR"; cargo clean)
9292

93+
export RUST_NIGHTLY=$(cat cargo-toolchain)
94+
export CARGO=$(rustup which --toolchain $RUST_NIGHTLY cargo)
95+
export CARGOFLAGS=$(cat cargo-flags)
96+
9397
echo check ulimits
9498
ulimit -a
9599

@@ -106,7 +110,7 @@ while read -r line; do
106110
fi
107111
# Don't fail out of the loop here. We just want to run the test binary
108112
# to collect its profile data. Also note which crates fail under coverage.
109-
( cd "$dirline" && pwd && RUST_BACKTRACE=1 cargo xtest ) || FAILED_CRATES="${FAILED_CRATES}:${subdir}"
113+
( cd "$dirline" && pwd && RUST_BACKTRACE=1 ${CARGO} ${CARGOFLAGS} xtest ) || FAILED_CRATES="${FAILED_CRATES}:${subdir}"
110114
done < <(find "$TEST_DIR" -name 'Cargo.toml')
111115

112116
# Make the coverage directory if it doesn't exist

0 commit comments

Comments
 (0)