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

feat: build scripts (rust 1.81) #149

Merged
merged 14 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash

(cd discussions && cargo near build)
(cd community && cargo near build)
(cd community-factory && cargo near build)
cargo near build
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.sh | sh

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/latest/download/cargo-near-installer.sh | sh
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cargo-near fails to install in the ghcr.io/near/near-devcontainer image.

2024-09-10 19:39:47.137Z: downloading cargo-near 0.8.2 x86_64-unknown-linux-gnu
2024-09-10 19:39:48.739Z: installing to /usr/local/cargo/bin
2024-09-10 19:39:48.743Z: cp: cannot create regular file '/usr/local/cargo/bin/cargo-near': Permission denied
2024-09-10 19:39:48.748Z: ERROR�(B�[m: command failed: cp /tmp/tmp.NHfv1kPqDY/cargo-near /usr/local/cargo/bin

Consider applying the change from here:

https://github.com/NEAR-DevHub/neardevhub-contract/pull/148/files#diff-24ad71c8613ddcf6fd23818cb3bb477a1fb6d83af4550b0bad43099813088686

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@petersalomonsen i overlooked that change in .devcontainer/devcontainer.json when copying from #148 ,
only copied from .devcontainer/post-create.sh.

i'll add it too


(cd community-factory && cargo near build --no-docker)
cargo near build --no-docker
8 changes: 2 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ jobs:
- uses: Swatinem/rust-cache@v1
- name: Install cargo-near
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/latest/download/cargo-near-installer.sh | sh
- name: Build discussions contract
run: cd discussions && cargo near build
- name: Build community contract
run: cd community && cargo near build
- name: Build community factory contract
run: cd community-factory && cargo near build
run: cd community-factory && cargo near build --no-docker
- name: Build devhub contract
run: cargo near build
run: cargo near build --no-docker
- name: Unit tests
run: cargo test
8 changes: 2 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@ jobs:
- uses: Swatinem/rust-cache@v1
- name: Install cargo-near
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/cargo-near/releases/latest/download/cargo-near-installer.sh | sh
- name: Build discussions contract
run: cd discussions && cargo near build
- name: Build community contract
run: cd community && cargo near build
- name: Build community factory contract
run: cd community-factory && cargo near build
run: cd community-factory && cargo near build --no-docker
- name: Build devhub contract
run: cargo near build
run: cargo near build --no-docker
- name: Install near CLI
run: |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/download/v0.3.1/near-cli-rs-v0.3.1-installer.sh | sh
Expand Down
117 changes: 106 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ near-sdk = { version = "5.1.0", features = ["unit-testing"] }
insta = { version = "1.31.0", features = ["json", "redactions"] }
regex = "1"
near-workspaces = { version = "0.10.0", features = ["unstable"], default-features = false }
cargo-near-build = "0.1.0"
tokio = { version = "1.10.0", features = ["full"] }
anyhow = "1.0"

Expand Down
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ Before starting, make sure you have the following installed:
From the root directory, run:

```sh
cd discussions
cargo near build
cd ../community
cargo near build
cd ../community-factory
cargo near build
cd community-factory
cargo near build --no-docker
cd ..
cargo near build
cargo near build --no-docker
```

## Running Tests
Expand All @@ -36,12 +32,22 @@ From the root directory, run:
cargo test
```

NOTE: integration tests automatically build the `devhub-community-factory` and
`devhub` they depend on and place them into `target/devhub-tests-contracts`.

To trigger rebuild of contracts being tested, e.g. after their modification,
one should run:

```bash
rm -rf target/devhub-tests-contracts
```
dj8yfo marked this conversation as resolved.
Show resolved Hide resolved

## Deploying

Using [cargo-near](https://github.com/near/cargo-near), run the following command. Be sure to set your own account id and corresponding network.

```sh
cargo near deploy {{account.near}}
cargo near deploy --no-docker {{account.near}}
cd community-factory
cargo near deploy {{community.account.near}}
cargo near deploy --no-docker {{community.account.near}}
```
Loading
Loading