Skip to content

Use workspaces to separate crates #379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 19, 2019

Conversation

rrybarczyk
Copy link
Contributor

Use Rust's workspaces to separate the lightning and lightning-net-tokio crates. Tests from both workspaces will execute when cargo test is invoked at the top level directory.

@TheBlueMatt
Copy link
Collaborator

Nice! Looks good, not sure why travis is failing on stable, but 1.22 looks like its because net-tokio doesn't support 1.22 (for various reasons). That's OK but we need to figure out how to make travis only run the main crate tests for 1.22.

@codecov
Copy link

codecov bot commented Nov 15, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@ae0ad19). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #379   +/-   ##
=========================================
  Coverage          ?   87.49%           
=========================================
  Files             ?       29           
  Lines             ?    15791           
  Branches          ?        0           
=========================================
  Hits              ?    13817           
  Misses            ?     1974           
  Partials          ?        0
Impacted Files Coverage Δ
lightning/src/ln/channelmanager.rs 81.57% <ø> (ø)
lightning/src/ln/chanmon_update_fail_tests.rs 97.01% <ø> (ø)
lightning/src/util/events.rs 0% <ø> (ø)
lightning/src/lib.rs 100% <ø> (ø)
lightning/src/ln/onion_utils.rs 95.96% <ø> (ø)
lightning/src/util/chacha20poly1305rfc.rs 97.95% <ø> (ø)
lightning/src/util/transaction_utils.rs 98.64% <ø> (ø)
lightning/src/util/macro_logger.rs 76% <ø> (ø)
lightning/src/util/ser.rs 89.88% <ø> (ø)
lightning/src/chain/keysinterface.rs 95.74% <ø> (ø)
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ae0ad19...b371ec5. Read the comment docs.

@TheBlueMatt
Copy link
Collaborator

Hmm, looks like it needs a rebase, sadly. Are you still working on this @rrybarczyk ?

@rrybarczyk
Copy link
Contributor Author

Yeah @TheBlueMatt, rebasing rn. Still need to figure out how to make Travis to skip over the net-tokio tests for Rust v1.22 though.

@TheBlueMatt
Copy link
Collaborator

Probably just update the script in .travis.yml to skip it based on the rustup show grep pattern already there.

@rrybarczyk
Copy link
Contributor Author

So change L18 from
if [ "$(rustup show | grep default | grep stable)" != "" ]; then cd lightning-net-tokio && cargo build --verbose && cd ..; fi
to
if [ "$(rustup show | grep default | grep stable && rustup show | grep default | grep 1.22.0)" != "" ]; then cd lightning-net-tokio && cargo build --verbose && cd ..; fi
?

@TheBlueMatt
Copy link
Collaborator

Ohhh, I guess I don't know how workspaces works? Can you change the root test to cd to the main workspace before testing so that it doesnt test all the workspaces, or does that test all the workspaces?

@rrybarczyk
Copy link
Contributor Author

rrybarczyk commented Nov 18, 2019

The command to just test the lightning workspace is $ cargo test -p lightning, similarly to only test the lightning-net-tokio workspace is $ cargo test -p lightning-net-tokio.

I think I am having issues because I am not quite comfortable with Travis and am unclear on exactly what it should be building/testing for which version of Rust.

Can you let me know if my understanding of the .travis.yml file is correct:
L14 - build the lightning crate for Rust stable, beta, 1.22.0, and 1.34.2
L15 - remove old binaries
L16 - test the lightning crate for Rust stable, beta, 1.22.0, and 1.34.2
L17 - run the lightning crate fuzz tests for Rust 1.34.2
L18 - build lightning-net-tokio for Rust stable
L19 - run L20 - L32 for Rust stable, these lines just perform logic required for Travis CI to work?

If my understanding of the above is correct, how do you feel about this update to the script section:

script:
     # Build workspaces with Rust stable, beta, and 1.34.0
     - if [ "$(rustup show | grep default | grep 1.22.0)" == "" ]; RUSTFLAGS="-C link-dead-code" cargo build --verbose
     - rm -f target/debug/lightning-* # Make sure we drop old test binaries
     # Build lightning workspace with Rust 1.22.0
     - if [ "$(rustup show | grep default | grep 1.22.0)" != "" ]; RUSTFLAGS="-C link-dead-code" cargo build --verbose -p lightning
     # Test workspaces for Rust stable, beta, and 1.34.2
     - if [ "$(rustup show | grep default | grep 1.22.0)" == "" ]; RUSTFLAGS="-C link-dead-code" cargo test --verbose
     # Test lightning workspace for 1.22.0
     - if [ "$(rustup show | grep default | grep 1.22.0)" != "" ]; RUSTFLAGS="-C link-dead-code" cargo test --verbose -p lightning
     # Run lightning workspace fuzz tests for Rust 1.34.2
     - if [ "$(rustup show | grep default | grep 1.34.2)" != "" ]; then cd lightning/fuzz && cargo test --verbose && ./travis-fuzz.sh; fi
     - if [ "$(rustup show | grep default | grep stable)" != "" ]; then
           wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz &&
           tar xzf master.tar.gz &&
           cd kcov-master &&
           mkdir build &&
           cd build &&
           cmake .. &&
           make &&
           make install DESTDIR=../../kcov-build &&
           cd ../.. &&
           rm -rf kcov-master &&
           for file in target/debug/lightning-*; do [ -x "${file}" ] || continue; mkdir -p "target/cov/$(basename $file)"; ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file"; done &&
           bash <(curl -s https://codecov.io/bash) &&
           echo "Uploaded code coverage"; fi

If my understanding is in correct, let me know where I am going wrong/what I am missing and I will update accordingly.

@TheBlueMatt
Copy link
Collaborator

Your understanding is correct, L20-33 do the codecov integration so we get code coverage reports....its some magic I just copied from their sample.

Your proposed version looks good, but you probably need to move the "Make sure we drop old test binaries" down to below the Build on Rust 1.22.0 line.

@TheBlueMatt
Copy link
Collaborator

Oops, sorry, merging #395 conflicted this PR. If you're working on it now can do a quick rebase + merge, otherwise may be a moving target...

@rrybarczyk
Copy link
Contributor Author

@TheBlueMatt I am actively working on it rn. I had a syntax issue in the last .travis.yaml. I pushed a fix and it looks like everything is building ok rn, but it still has not finished all the way yet. Once this build (hopefully) passes, I can squash all my commits and have it ready to merge asap.

@rrybarczyk
Copy link
Contributor Author

Ok, looks like all the builds are passing now! I squashed my WIP comments into one and pulled from master so everything should be up to date. Going to do a force push on this branch rn and it should be ready to merge

@TheBlueMatt TheBlueMatt merged commit 126b514 into lightningdevkit:master Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants