Skip to content
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
wants to merge 32 commits into from
Closed

merge main 3 #172

wants to merge 32 commits into from

Conversation

dj8yfo
Copy link
Collaborator

@dj8yfo dj8yfo commented Jul 5, 2024

FroVolod and others added 30 commits February 23, 2024 09:57
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"),
                },
            },
        },
```
…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)
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>
dj8yfo and others added 2 commits July 5, 2024 17:03
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)
@dj8yfo dj8yfo closed this Jul 5, 2024
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.

4 participants