Skip to content

Conversation

frol
Copy link
Collaborator

@frol frol commented May 29, 2025

It is a more robust version of near/cargo-near#350, which works for all existing contracts that will pull in the latest near-sdk-rs.

image

Without this patch cargo build will succeed, but this confuses users as they cannot find the wasm file.

This PR ensured that none of the legacy commands will fail:

  • cargo test will pass thanks to unit-testing feature being enabled in all contracts for near-sdk in dev-dependency
  • cargo build --target=wasm... will pass since this check does not trigger compilation error if target_family="wasm"
  • cargo near build will set __abi_generate feature for the ABI build, and target_family="wasm" for the contract build

Copy link

codecov bot commented May 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.35%. Comparing base (4a1dc8e) to head (6b8eede).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1361      +/-   ##
==========================================
+ Coverage   80.34%   80.35%   +0.01%     
==========================================
  Files         104      104              
  Lines       15243    15243              
==========================================
+ Hits        12247    12249       +2     
+ Misses       2996     2994       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@frol
Copy link
Collaborator Author

frol commented May 29, 2025

@race-of-sloths include

@race-of-sloths
Copy link

race-of-sloths commented May 29, 2025

@frol Thank you for your contribution! Your pull request is now a part of the Race of Sloths!
Weekly streak is on the road, smart strategy! Secure your streak with another PR!

Shows inviting banner with latest news.

Shows profile picture for the author of the PR

Current status: executed
Reviewer Score
@dj8yfo 8

Your contribution is much appreciated with a final score of 8!
You have received 90 (80 base + 10 monthly bonus) Sloth points for this contribution

@dj8yfo received 25 Sloth Points for reviewing and scoring this pull request.

Congratulations @frol! Your PR was highly scored and you completed another monthly streak! To keep your monthly streak make another pull request next month and get 8+ score for it

What is the Race of Sloths

Race of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow

For contributors:

  • Tag @race-of-sloths inside your pull requests
  • Wait for the maintainer to review and score your pull request
  • Check out your position in the Leaderboard
  • Keep weekly and monthly streaks to reach higher positions
  • Boast your contributions with a dynamic picture of your Profile

For maintainers:

  • Score pull requests that participate in the Race of Sloths and receive a reward
  • Engage contributors with fair scoring and fast responses so they keep their streaks
  • Promote the Race to the point where the Race starts promoting you
  • Grow the community of your contributors

Feel free to check our website for additional details!

Bot commands
  • For contributors
    • Include a PR: @race-of-sloths include to enter the Race with your PR
  • For maintainers:
    • Invite contributor @race-of-sloths invite to invite the contributor to participate in a race or include it, if it's already a runner.
    • Assign points: @race-of-sloths score [1/2/3/5/8/13] to award points based on your assessment.
    • Reject this PR: @race-of-sloths exclude to send this PR back to the drawing board.
    • Exclude repo: @race-of-sloths pause to stop bot activity in this repo until @race-of-sloths unpause command is called

Comment on lines +120 to +122
"⚠️ Use `cargo near build` instead of `cargo build` to compile your contract

💡 Install cargo-near from https://github.com/near/cargo-near"
Copy link
Contributor

@dj8yfo dj8yfo May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the message is misleading, as it assumes the reason of error, and tells nothing to user about the
actual not(any( test, doctest, clippy, target_family = "wasm", feature = "unit-testing", feature = "__abi-generate" )) condition, that has been checked.

I do believe that the actual reason has to be printed first (so that it doesn't require to dig into sources), and one of assumed possible reasons Use cargo near build instead of cargo build to compile your contract suggested after that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dj8yfo The longer the message, the less likely users will read it fully, so while I agree with you in general, this is the conscious tradeoff I had to make.

Copy link
Contributor

@dj8yfo dj8yfo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@race-of-sloths score 8

it looks to me the collection of footguns will be expanded while deleting 1 existing exhibit

a newly added footgun https://github.com/near/cargo-near/blob/main/cargo-near/src/commands/new/new-project-template/Cargo.template.toml#L42 won't be a problem in context of cargo near new skeleton project, but it may pop elsewhere

@frol frol merged commit e5ef0a5 into master May 29, 2025
41 checks passed
@frol frol deleted the feat/hint-to-use-cargo-near branch May 29, 2025 21:22
@github-project-automation github-project-automation bot moved this from NEW❗ to Shipped 🚀 in DevTools May 29, 2025
@frol frol mentioned this pull request May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Shipped 🚀
Development

Successfully merging this pull request may close these issues.

3 participants