near / cargo-near

Cargo extension for building Rust smart contracts on NEAR
Apache License 2.0
34 stars 17 forks source link

feat: `env` flag for external parameters of docker build and regular build #226

Closed dj8yfo closed 1 month ago

dj8yfo commented 1 month ago

tested docker build cases:

  1. no command in manifest via --env cli flags sample_no_workspace =>
sample-crate-88.testnet

```json { "build_info": { "build_command": [ "cargo", "near", "build", "--env", "GOOGLE_QUERY=https://www.google.com/search?q=google+translate&sca_esv=3c150c50f502bc5d", "--env", "KEY=VALUE" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-pr-226@sha256:a33c44bc06ae8411458fb23cf57b6d760f51592481276f66f5bc292ed6b80378", "contract_path": "", "source_code_snapshot": "git+https://github.com/dj8yfo/sample_no_workspace?rev=7a9793727ddd6f8be5482944130a9235f62aa1e9" }, "link": "https://github.com/dj8yfo/sample_no_workspace/tree/7a9793727ddd6f8be5482944130a9235f62aa1e9", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "0.7.7" } ```

  1. via passed_env in manifest and exported env sample_no_workspace
sample-crate-90.testnet

```json { "build_info": { "build_command": [ "cargo", "near", "build", "--env", "KEY=VALUE", "--env", "GOOGLE_QUERY=https://www.google.com/search?q=google+translate&sca_esv=3c150c50f502bc5d" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-pr-226@sha256:a33c44bc06ae8411458fb23cf57b6d760f51592481276f66f5bc292ed6b80378", "contract_path": "", "source_code_snapshot": "git+https://github.com/dj8yfo/sample_no_workspace?rev=485c69441acc449078b1157b812bb69b744c870d" }, "link": "https://github.com/dj8yfo/sample_no_workspace/tree/485c69441acc449078b1157b812bb69b744c870d", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "0.7.7" } ```

  1. no command in manifest via --env cli flags neardevhub-contract
discussions.gothamuniquehandle3.community.devhub-test-4.testnet

```json { "build_info": { "build_command": [ "cargo", "near", "build", "--env", "KEY=VALUE", "--env", "GOOGLE_QUERY=https://www.google.com/search?q=google+translate&sca_esv=3c150c50f502bc5d" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-pr-226@sha256:a33c44bc06ae8411458fb23cf57b6d760f51592481276f66f5bc292ed6b80378", "contract_path": "discussions", "source_code_snapshot": "git+https://github.com/dj8yfo/neardevhub-contract?rev=bba6a9b63c00dcf5399e1eb2bf8bf18d6d8d2c4e" }, "link": "https://github.com/dj8yfo/neardevhub-contract/tree/bba6a9b63c00dcf5399e1eb2bf8bf18d6d8d2c4e", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "0.1.0" } ```

d673dee7ff8e9e5534796a67154e7d43db27b6e57934c33e2848d6b1b5ebf892  community.devhub-test-4.testnet.wasm
e6ddea282b05a29aae383e46ba7fc26c127caa4de18a8283190a3d86256e70ac  devhub-test-4.testnet.wasm
836a14c755f567a331f9e4ad9f3e99fe696c992525df7c55f8acb18973218c6d  discussions.gothamuniquehandle3.community.devhub-test-4.testnet.wasm
85b3054c02e74e8dbf5eab526e8ee867dce1cc3768aa11b32b4d4110fdc78757  gothamuniquehandle3.community.devhub-test-4.testnet.wasm
85b3054c02e74e8dbf5eab526e8ee867dce1cc3768aa11b32b4d4110fdc78757  standalone-devhub-community-4.testnet.wasm
836a14c755f567a331f9e4ad9f3e99fe696c992525df7c55f8acb18973218c6d  standalone-devhub-discussions-4.testnet.wasm
  1. via passed_env in manifest and exported env ; following cases are deployed from the same source-code neardevhub

    • no variables exports
    discussions.uniquehandle.community.devhub-no-vars.testnet

    ```json { "build_info": { "build_command": [ "cargo", "near", "build" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-pr-226@sha256:a33c44bc06ae8411458fb23cf57b6d760f51592481276f66f5bc292ed6b80378", "contract_path": "discussions", "source_code_snapshot": "git+https://github.com/dj8yfo/neardevhub-contract?rev=d05268b3583b8273540d94871f897efa120eb0a5" }, "link": "https://github.com/dj8yfo/neardevhub-contract/tree/d05268b3583b8273540d94871f897efa120eb0a5", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "0.1.0" } ```

    e8fbe501978ac5458a71913ff2fe7ebc1a72573b615ca3fa346f32677d7ca7fc  community.devhub-no-vars.testnet.wasm
    df5992c0f3df6c28b3fa439fdb965cd8ecb8fdec37d65f632affc8de901e0092  devhub-no-vars.testnet.wasm
    4382ba6c1e1e004e8b69d98efc0e7652c2c4cf3c16ae9e2dd4d441e85719523f  discussions.uniquehandle.community.devhub-no-vars.testnet.wasm
    175ae0c5719a21dfab545d418050f91807c858e68983434f4f60ec75cf99f92c  standalone-devhub-community-no-vars.testnet.wasm
    4382ba6c1e1e004e8b69d98efc0e7652c2c4cf3c16ae9e2dd4d441e85719523f  standalone-devhub-discussions-no-vars.testnet.wasm
    175ae0c5719a21dfab545d418050f91807c858e68983434f4f60ec75cf99f92c  uniquehandle.community.devhub-no-vars.testnet.wasm
    • one variable export
    discussions.uniquehandle.community.devhub-one-var.testnet

    ```json { "build_info": { "build_command": [ "cargo", "near", "build", "--env", "GOOGLE_QUERY=https://www.google.com/search?q=google+translate&sca_esv=3c150c50f502bc5d" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-pr-226@sha256:a33c44bc06ae8411458fb23cf57b6d760f51592481276f66f5bc292ed6b80378", "contract_path": "discussions", "source_code_snapshot": "git+https://github.com/dj8yfo/neardevhub-contract?rev=d05268b3583b8273540d94871f897efa120eb0a5" }, "link": "https://github.com/dj8yfo/neardevhub-contract/tree/d05268b3583b8273540d94871f897efa120eb0a5", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "0.1.0" } ```

    1787219b148d4298ed56cad04ae430c40d92779c6163e6165b88e5207549f41f  community.devhub-one-var.testnet.wasm
    87ecd58d10df0718f599af334601674ffe11f203134358add7b993441a943e19  devhub-one-var.testnet.wasm
    18fc865aaa2990d80175033e93ecd471f954bf269b340d700885c427476d6e9c  discussions.uniquehandle.community.devhub-one-var.testnet.wasm
    ad3b3a4a26618f32c1fde9958dbd4209b7364ff49e20ab3fc515cff6fcb31ca5  standalone-devhub-community-one-var.testnet.wasm
    18fc865aaa2990d80175033e93ecd471f954bf269b340d700885c427476d6e9c  standalone-devhub-discussions-one-var.testnet.wasm
    ad3b3a4a26618f32c1fde9958dbd4209b7364ff49e20ab3fc515cff6fcb31ca5  uniquehandle.community.devhub-one-var.testnet.wasm
    • two variables export
    discussions.uniquehandle.community.devhub-two-var.testnet

    ```json { "build_info": { "build_command": [ "cargo", "near", "build", "--env", "KEY=VALUE", "--env", "GOOGLE_QUERY=https://www.google.com/search?q=google+translate&sca_esv=3c150c50f502bc5d" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-pr-226@sha256:a33c44bc06ae8411458fb23cf57b6d760f51592481276f66f5bc292ed6b80378", "contract_path": "discussions", "source_code_snapshot": "git+https://github.com/dj8yfo/neardevhub-contract?rev=d05268b3583b8273540d94871f897efa120eb0a5" }, "link": "https://github.com/dj8yfo/neardevhub-contract/tree/d05268b3583b8273540d94871f897efa120eb0a5", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "0.1.0" } ```

    cda103ad337d322341f2d8ce442c7cac2b57f945f7c37de814c3951f499967f5  community.devhub-two-var.testnet.wasm
    79dc0629f9dde96eb16a823110afd9bcfa6b0e5d7f3b1256fbd3f5da887211b8  devhub-two-var.testnet.wasm
    549d312421e600d583fb9847ddc8142909d6f6c5a75a3a44ef9a1e2198b08443  discussions.uniquehandle.community.devhub-two-var.testnet.wasm
    804550e43cbfe5f463a8b866a4a5eb65ef845cb9b625af93f43a91ec96dd95a3  standalone-devhub-community-two-var.testnet.wasm
    549d312421e600d583fb9847ddc8142909d6f6c5a75a3a44ef9a1e2198b08443  standalone-devhub-discussions-two-var.testnet.wasm
    804550e43cbfe5f463a8b866a4a5eb65ef845cb9b625af93f43a91ec96dd95a3  uniquehandle.community.devhub-two-var.testnet.wasm
dj8yfo commented 1 month ago

@race-of-sloths ping

race-of-sloths commented 1 month ago

@dj8yfo Thank you for your contribution! Your pull request is now a part of the Race of Sloths!

[

<source media="(prefers-color-scheme: light)" srcset="https://badge.race-of-sloths.com/dj8yfo?type=bot&pr=near/cargo-near/226&theme=light">
<img alt="Shows profile picture for the author of the PR" src="https://badge.race-of-sloths.com/dj8yfo?type=bot&pr=near/cargo-near/226&theme=white">

](https://race-of-sloths.com/profile/dj8yfo)

Current status: executed | Reviewer | Score | |--------|--------| | @frol | 8 | Your contribution is much appreciated with a final score of 8! You have received 88 (80 base + 10% lifetime bonus) Sloth points for this contribution
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](https://race-of-sloths.com/leaderboard) - Keep weekly and monthly streaks to reach higher positions - Boast your contributions with a dynamic picture of your [Profile](https://race-of-sloths.com/profile/dj8yfo) For maintainers: - Score pull requests that participate in the Race of Sloths - 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](https://race-of-sloths.com) 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