-
Notifications
You must be signed in to change notification settings - Fork 16
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
merge main 3 #172
Closed
Closed
merge main 3 #172
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Passing uid, gid to container to preserve the privileges the same as for host system, while building to mounted volume from host. - [append timestamp and pid to container name to make it unique](near@fdc5ee6) - [use image with non-root user builder](near@f3c3b11) - [implement cross-platform uid,gid support with platform-specific dependencies](near@40f98ba)
this adds ability to configure image via [`Cargo.toml`](https://github.com/dj8yfo/sample_no_workspace/blob/set_metadata/Cargo.toml#L14-L16) : ```toml [package.metadata.near.reproducible_build] image = "docker.io/sourcescan/cargo-near:0.6.0-builder" image_digest = "sha256:d21001ebc889478deac105a07efbefcd667d6a2e927e8ea5f1526cd1877ae84a" ``` `cargo` doesn't automatically populate `package.metadata` with `workspace.metadata` near-examples/update-migrate-rust@d3259c3 ```bash # package ... metadata: Object { "near": Object { "reproducible_build": Object { "image": Object { "workspace": Bool(true), }, }, }, }, ... # workspace workspace_metadata: Object { "near": Object { "reproducible_build": Object { "image": String("docker.io/sourcescan/cargo-near:0.6.0@sha256:bf488476d9c4e49e36862bbdef2c595f88d34a295fd551cc65dc291553849471"), }, }, }, ```
…bedded, remove `--no-docker` flag (near#144) Following output was generated by using the branch of current pr with [build local `cargo-near` Dockerfile](https://github.com/dj8yfo/cargo-near-image/tree/0.x.x-builer-local-cargo-near) => [image](https://hub.docker.com/r/dj8yfo/sourcescan/tags) on this [repo](https://github.com/dj8yfo/sample_no_workspace/tree/set_metadata) ![Screenshot_20240412_230234](https://github.com/near/cargo-near/assets/26653921/9014a2de-33f8-4ddb-9d7d-d9a78ddb43df) ![Screenshot_20240412_230436](https://github.com/near/cargo-near/assets/26653921/a6f3023b-4858-460c-bbf0-4cdc94ea5bae) ![Screenshot_20240412_230749](https://github.com/near/cargo-near/assets/26653921/36f7f64f-ae50-4620-aa35-81f4db54eed0)
…docker` flow (near#153) Following has been compared to `--no-docker` counterparts, they produce the same output `*.wasm` paths (`*.json` and `*.zst` aren't produced as result of a build). Tested on https://github.com/dj8yfo/sample_no_workspace/tree/set_metadata_with_repo . - [x] without arg - [x] `cargo near build --no-abi` - [x] `cargo near build ` - [x] `cargo near deploy` - [x] with arg - [x] `cargo near build --no-abi --out-dir /path/to/tmp_build_destination` - [x] `cargo near build --out-dir /path/to/tmp_build_destination` - [x] `cargo near deploy --out-dir /path/to/tmp_build_destination` ![Screenshot_20240419_230137](https://github.com/near/cargo-near/assets/26653921/de7dcffa-8c30-4993-9406-f4589cccd289)
`build_command` key set: https://github.com/dj8yfo/sample_no_workspace/tree/metadata_image_repo_build_cmd ![Screenshot_20240423_182924](https://github.com/near/cargo-near/assets/26653921/25b88fcb-db92-464b-89d8-82757dc9e4a4) --- `build_command` key not set: https://github.com/dj8yfo/sample_no_workspace/tree/metadata_image_repo ![Screenshot_20240423_183205](https://github.com/near/cargo-near/assets/26653921/a8a85d28-c757-4ced-bb44-f46cd6f9d5ab) --- typo in key: https://github.com/dj8yfo/sample_no_workspace/tree/metadata_image_repo_wrong_key ![Screenshot_20240423_180816](https://github.com/near/cargo-near/assets/26653921/15f44b3c-0720-4b68-94ba-56224d9c39a8) --------- Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
) this addresses near#153 (comment) screenshot from https://github.com/dj8yfo/sample_no_workspace/tree/metadata_image_repo_build_cmd ![Screenshot_20240424_154301](https://github.com/near/cargo-near/assets/26653921/afe9a29c-6c78-494d-bb42-b71b1ff260f2)
Summary of changes: - `git dirty` check copied to `cargo near build` flow, it produces a warning, unlike the error in `cargo near deploy` flow - added `source_code_git_url` field to reproducible build metadata - `git pushed to remote` check logic reworked - repo is opened and `HEAD` is determined - relative path of contract within repo is determined - `CARGO_NEAR_SOURCE_CODE_SNAPSHOT` (adapted from [cargo::core::SourceId](https://docs.rs/cargo/latest/cargo/core/struct.SourceId.html)) and `CARGO_NEAR_CONTRACT_PATH` are exported into container - [x] github, package in root of a repo: https://github.com/dj8yfo/sample_no_workspace/tree/6c5ae44150ce51349a95e1605ba053c4fe53cf28 - [x] github, package in subpath in repo : https://github.com/dj8yfo/sample_workspace/tree/b2d5580037c84fd4038b467564a9be9e520611de/self-updates/update - [x] github, package in submodule in repo : https://github.com/dj8yfo/sample_workspace_with_submodules/tree/3d87c81517e1e23a5716c300fe4789b1aafc4c6f/self-updates - [x] bitbucket, package in root of a repo: https://bitbucket.org/dj8yfomule/scratch_check_git/src/master/ ![Screenshot_20240503_204916](https://github.com/near/cargo-near/assets/26653921/046dca51-accb-4838-9eb0-5ae531cf4a59)
commit near@ca13500 was lost in merge of near#159, as it was accidentally not pushed to remote before merge, which was discovered when testing on [contract](https://github.com/dj8yfo/sample_no_workspace/blob/d42d1c69a3883889c4bb688b11e0a8dffb384a15/Cargo.toml) --- SIDENOTE: commit near@787c3a4 fixes somewhat unrelated problem, also present in `main` . It can be cherry-picked into a standalone pr to `main` : as `cargo metadata` is called without any additional args (`--features` or whatnot), the following diff: ```diff -near-sdk = { version = "5.1.0", features = ["legacy"], git = "https://github.com/dj8yfo/near-sdk-rs.git", branch = "add_contract_metadata" } +near-sdk = { version = "5.1.0", default-features = false, features = ["wee_alloc", "legacy"], git = "https://github.com/dj8yfo/near-sdk-rs.git", branch = "add_contract_metadata" } ``` results in ```bash Error: 0: `near-sdk` dependency must have the `abi` feature enabled ``` which somewhat contradicts [no explicit `abi` feature](https://github.com/near-examples/factory-rust/blob/main/Cargo.toml#L16) , which is promoted for use by [near-docs](https://github.com/near-examples/factory-rust/pull/2/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R74) --------- Co-authored-by: Jacob Lindahl <encody@users.noreply.github.com>
git(source-scan): create empty merge commit
fast-forward extension of near#164 1. [Cargo.toml](https://github.com/dj8yfo/sample_no_workspace/blob/1fd39bcbe4d523ac26c3d07c1f49ecc0fc65d9e7/Cargo.toml) => `sample-crate-12.testnet` <details> <summary>contract_source_metadata</summary><p> ```json { "build_info": { "build_command": [ "cargo", "near", "build", "--no-default-features", "--features", "near-sdk/expensive-debug" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-cargo-near-finalization@sha256:f86a095cb3daed21d0b5f86a4b5d9da0c0e26835f85c42678e1d460c9caa2c12", "contract_path": "", "source_code_snapshot": "git+https://github.com/dj8yfo/sample_no_workspace.git?rev=1fd39bcbe4d523ac26c3d07c1f49ecc0fc65d9e7" }, "link": "https://github.com/dj8yfo/sample_no_workspace/tree/1fd39bcbe4d523ac26c3d07c1f49ecc0fc65d9e7", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "0.7.7" } ``` </p> </details> 2. [Cargo.toml](https://github.com/dj8yfo/sample_workspace/blob/86aa6ccf4610f072cd207db86869e6324779780f/self-updates/update/Cargo.toml) => `sample-subpath-in-repo-6.testnet` <details> <summary>contract_source_metadata</summary><p> ```json { "build_info": { "build_command": [ "cargo", "near", "build", "--no-release", "--no-doc" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-cargo-near-finalization@sha256:f86a095cb3daed21d0b5f86a4b5d9da0c0e26835f85c42678e1d460c9caa2c12", "contract_path": "self-updates/update", "source_code_snapshot": "git+https://github.com/dj8yfo/sample_workspace.git?rev=86aa6ccf4610f072cd207db86869e6324779780f" }, "link": "https://github.com/dj8yfo/sample_workspace/tree/86aa6ccf4610f072cd207db86869e6324779780f", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "1.7.7" } ``` </p> </details> 3. [dir containing submodule](https://github.com/dj8yfo/sample_workspace_with_submodules/tree/4b466921b89df67d6e8d1f9956b55a677edb2497/self-updates) => `sample-crate-in-submodule-5.testnet` <details> <summary>contract_source_metadata</summary><p> ```json { "build_info": { "build_command": [ "cargo", "near", "build", "--no-release", "--no-doc" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-cargo-near-finalization@sha256:f86a095cb3daed21d0b5f86a4b5d9da0c0e26835f85c42678e1d460c9caa2c12", "contract_path": "self-updates/update", "source_code_snapshot": "git+https://github.com/dj8yfo/sample_workspace_with_submodules.git?rev=4b466921b89df67d6e8d1f9956b55a677edb2497" }, "link": "https://github.com/dj8yfo/sample_workspace_with_submodules/tree/4b466921b89df67d6e8d1f9956b55a677edb2497", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "1.0.0" } ``` </p> </details> 4. [Cargo.toml](https://bitbucket.org/dj8yfomule/scratch_check_git/src/finalization/Cargo.toml) => `bitbucket-scratch-4.testnet` <details> <summary>contract_source_metadata</summary><p> ```json { "build_info": { "build_command": [ "cargo", "near", "build", "--no-release", "--no-doc" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-cargo-near-finalization@sha256:f86a095cb3daed21d0b5f86a4b5d9da0c0e26835f85c42678e1d460c9caa2c12", "contract_path": "", "source_code_snapshot": "git+https://feepdake27@bitbucket.org/dj8yfomule/scratch_check_git.git?rev=af9e835380053205f7fcc9b232a7ebb1c2c20694" }, "link": "https://bitbucket.org/dj8yfomule/scratch_check_git/src/finalization/", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "0.1.0" } ``` </p> </details> 5. factory [Cargo.toml](https://github.com/dj8yfo/factory-rust/blob/62a34ac86e6323ee6351b20fded7fc668b1e0277/factory/Cargo.toml) => `repro-fct-19.testnet` <details> <summary>contract_source_metadata</summary><p> ```json { "build_info": { "build_command": [ "cargo", "near", "build", "--no-default-features", "--features", "near-sdk/expensive-debug" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-cargo-near-finalization@sha256:f86a095cb3daed21d0b5f86a4b5d9da0c0e26835f85c42678e1d460c9caa2c12", "contract_path": "factory", "source_code_snapshot": "git+https://github.com/dj8yfo/factory-rust.git?rev=62a34ac86e6323ee6351b20fded7fc668b1e0277" }, "link": "https://github.com/dj8yfo/factory-rust/tree/62a34ac86e6323ee6351b20fded7fc668b1e0277", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "0.1.13" } ``` </p> </details> 6. `repro-fct-19.testnet` => product `donation-product.repro-fct-19.testnet` <details> <summary>contract_source_metadata</summary><p> ```json { "build_info": { "build_command": [ "cargo", "near", "build" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-cargo-near-finalization@sha256:f86a095cb3daed21d0b5f86a4b5d9da0c0e26835f85c42678e1d460c9caa2c12", "contract_path": "product-donation", "source_code_snapshot": "git+https://github.com/dj8yfo/factory-rust.git?rev=62a34ac86e6323ee6351b20fded7fc668b1e0277" }, "link": "https://github.com/dj8yfo/factory-rust/tree/62a34ac86e6323ee6351b20fded7fc668b1e0277", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "0.2.9" } ``` </p> </details> 7. product [Cargo.toml](https://github.com/dj8yfo/factory-rust/blob/62a34ac86e6323ee6351b20fded7fc668b1e0277/product-donation/Cargo.toml) => `repro-fct-product-19.testnet` <details> <summary>contract_source_metadata</summary><p> ```json { "build_info": { "build_command": [ "cargo", "near", "build" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-cargo-near-finalization@sha256:f86a095cb3daed21d0b5f86a4b5d9da0c0e26835f85c42678e1d460c9caa2c12", "contract_path": "product-donation", "source_code_snapshot": "git+https://github.com/dj8yfo/factory-rust.git?rev=62a34ac86e6323ee6351b20fded7fc668b1e0277" }, "link": "https://github.com/dj8yfo/factory-rust/tree/62a34ac86e6323ee6351b20fded7fc668b1e0277", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "0.2.9" } ``` </p> </details>
this [line](https://github.com/near/cargo-near/blob/main/integration-tests/src/lib.rs#L59) was fluke-nuking the added test, due to following commands ```bash export CARGO_TARGET_DIR=/home/target cargo metadata ``` corrupting `cargo metadata` output, so the new test was put into a separate binary. ![Screenshot_20240703_203008](https://github.com/near/cargo-near/assets/26653921/2854b7ad-edc4-4b53-99d9-6a78fc9c5f80)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
sh -c
(from<Ctrl-C>
) (forward interrupt from docker subprocess tosh -c
(from<Ctrl-C>
) #137)std::fs::rename
withstd::fs::rename
, handle error (replacestd::fs::rename
withstd::fs::copy
, handle error #138)cargo-near
embedded, remove--no-docker
flag (feat(source-scan): logging, refactor, image with samecargo-near
embedded, remove--no-docker
flag #144)main
branch (chore(source-scan): merge frommain
branch #150)--locked
by default, add--no-locked
flag (feat(source-scan): implicit--locked
by default, add--no-locked
flag #152)--no-docker
flow (feat(source-scan): similar behaviour of build destination with--no-docker
flow #153)main
(git(source-scan): resolve conflicts withmain
#162)