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

chore(ci): support local replica for local deployment #469

Merged
merged 5 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 26 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,38 @@ jobs:
uses: mozilla-actions/[email protected]
- name: 'Install dfx'
uses: dfinity/setup-dfx@main
- name: 'Start local replica'
- name: 'Start PocketIC'
run: dfx start --clean --pocketic --host 127.0.0.1:4943 --background
- name: 'Perform local deployment'
run: ./orbit --init
- name: 'Test local deployment'
run: |
curl http://werw6-ayaaa-aaaaa-774aa-cai.localhost:4943/ | grep "<title>Orbit Wallet</title>"
deployment-test-replica:
name: 'deployment-test-replica:required'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'Setup Python'
uses: actions/setup-python@v5
- name: 'Install cbor2'
run: pip install cbor2
- name: 'Install crc32'
run: sudo apt install -y libarchive-zip-perl
- name: 'Setup Node'
uses: ./.github/actions/setup-node
- name: 'Run sccache-cache'
uses: mozilla-actions/[email protected]
- name: 'Install dfx'
uses: dfinity/setup-dfx@main
- name: 'Start local replica'
run: dfx start --clean --host 127.0.0.1:4943 --background
- name: 'Perform local deployment'
run: ./orbit --init
- name: 'Test local deployment'
run: |
curl http://werw6-ayaaa-aaaaa-774aa-cai.localhost:4943/ | grep "<title>Orbit Wallet</title>"
prod-deployment-test:
name: 'prod-deployment-test:required'
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ dfx start --clean --pocketic --host 127.0.0.1:4943

Note that the local replica should be stopped using `dfx stop` rather than by CTRL^C.

If you want to resume your local replica after `dfx stop`, then you need to install the Python package `cbor2`,
have the binary `crc32` to compute CRC32 checksums on your executable path,
and use the following command for the first time:

```
dfx start --clean --host 127.0.0.1:4943
```

Then the following steps can be used to setup the Orbit canister ecosystem for local development.

```bash
Expand Down
15 changes: 14 additions & 1 deletion orbit
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,23 @@ function install_cmc() {
"
}

function textual_encode() {
( echo "$1" | xxd -r -p | crc32 /dev/stdin; echo -n "$1" ) |
xxd -r -p | base32 | tr A-Z a-z |
tr -d = | fold -w5 | paste -sd'-' -
}

function setup_cmc() {
uninstall_cmc
install_cmc
SUBNET_IDS="$(curl http://localhost:4943/_/topology 2>/dev/null | jq -r '.subnet_configs | to_entries | map(select(.value.subnet_kind == "Application"))[] | .key' | sed "s/\(.*\)/principal\\\"\1\\\";/")"
TOPO="$(curl http://localhost:4943/_/topology 2>/dev/null)"
if [[ "$?" != "0" || "$TOPO" == "Endpoint not found." ]]
then
SUBNET_ID_HEX="$(curl http://localhost:4943/api/v2/status 2>/dev/null | python3 -c "import cbor2; import hashlib; import sys; status=cbor2.loads(sys.stdin.buffer.read()); hash=hashlib.sha224(status['root_key']).digest(); principal=hash+b'\x02'; print(principal.hex())")"
SUBNET_IDS="principal\"$(textual_encode $SUBNET_ID_HEX)\";"
else
SUBNET_IDS="$(echo $TOPO | jq -r '.subnet_configs | to_entries | map(select(.value.subnet_kind == "Application"))[] | .key' | sed "s/\(.*\)/principal\\\"\1\\\";/")"
fi
dfx canister call cmc set_authorized_subnetwork_list "(record {
who=null;
subnets=vec {$SUBNET_IDS};
Expand Down
Loading