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

Dynamically update the hello-world hash on the guides #2249

Merged
merged 9 commits into from
Jul 23, 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
25 changes: 14 additions & 11 deletions .github/workflows/main_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:
# install IPFS
sudo apt-get install -y wget
sudo npm install -g markdown-spellcheck
wget -O ./go-ipfs.tar.gz https://dist.ipfs.io/go-ipfs/v0.6.0/go-ipfs_v0.6.0_linux-amd64.tar.gz
wget -O ./go-ipfs.tar.gz https://github.com/ipfs/kubo/releases/download/v0.6.0/go-ipfs_v0.6.0_linux-amd64.tar.gz
tar xvfz go-ipfs.tar.gz
sudo mv go-ipfs/ipfs /usr/local/bin/ipfs
ipfs init
Expand Down Expand Up @@ -228,7 +228,7 @@ jobs:

# install IPFS
sudo apt-get install -y wget
wget -O ./go-ipfs.tar.gz https://dist.ipfs.io/go-ipfs/v0.6.0/go-ipfs_v0.6.0_linux-amd64.tar.gz
wget -O ./go-ipfs.tar.gz https://github.com/ipfs/kubo/releases/download/v0.6.0/go-ipfs_v0.6.0_linux-amd64.tar.gz
tar xvfz go-ipfs.tar.gz
sudo mv go-ipfs/ipfs /usr/local/bin/ipfs
ipfs init
Expand Down Expand Up @@ -273,18 +273,21 @@ jobs:
name: Install dependencies (macos-12)
run: |
pip install tomte[tox]==0.2.17
brew install gcc

# brew install protobuf
# brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/72457f0166d5619a83f508f2345b22d0617b5021/Formula/protobuf.rb
wget https://github.com/protocolbuffers/protobuf/releases/download/v24.3/protoc-24.3-osx-x86_64.zip
unzip protoc-24.3-osx-x86_64.zip -d protoc
sudo mv protoc/bin/protoc /usr/local/bin/protoc
brew tap yoheimuta/protolint
brew install protolint

# install protolint
curl -L -o protolint.tar.gz https://github.com/yoheimuta/protolint/releases/download/v0.50.2/protolint_0.50.2_darwin_amd64.tar.gz
tar -xzvf protolint.tar.gz
sudo mv protolint /usr/local/bin/protolint
sudo chmod +x /usr/local/bin/protolint

# install ipfs
curl -O https://dist.ipfs.io/go-ipfs/v0.6.0/go-ipfs_v0.6.0_darwin-amd64.tar.gz
tar -xvzf go-ipfs_v0.6.0_darwin-amd64.tar.gz
curl -L -o ipfs.tar.gz https://github.com/ipfs/kubo/releases/download/v0.6.0/go-ipfs_v0.6.0_darwin-amd64.tar.gz
tar -xvzf ipfs.tar.gz
cd go-ipfs
sudo ./install.sh
cd ..
Expand Down Expand Up @@ -342,13 +345,13 @@ jobs:
#protolint version

# install ipfs
curl https://dist.ipfs.io/go-ipfs/v0.6.0/go-ipfs_v0.6.0_windows-amd64.zip -o go-ipfs_v0.6.0.zip
Expand-Archive -Path go-ipfs_v0.6.0.zip -DestinationPath ~\Apps\
curl -L -o go-ipfs.zip https://github.com/ipfs/kubo/releases/download/v0.6.0/go-ipfs_v0.6.0_windows-amd64.zip
Expand-Archive -Path go-ipfs.zip -DestinationPath ~\Apps\
cp ~\Apps\go-ipfs\ipfs.exe C:\Users\runneradmin\go\bin\
ipfs init

# install Tendermint
wget -O tendermint.tar.gz https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_windows_amd64.tar.gz
curl -L -o tendermint.tar.gz https://github.com/tendermint/tendermint/releases/download/v0.34.19/tendermint_0.34.19_windows_amd64.tar.gz
tar -xvzf tendermint.tar.gz
cp tendermint.exe C:\Users\runneradmin\go\bin\

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ In the workspace folder, create a file `fsm_specification.yaml`, which formally
```yaml title="fsm_specification.yaml"
alphabet_in:
- DONE
- NONE
- NO_MAJORITY
- RESET_TIMEOUT
- ROUND_TIMEOUT
Expand All @@ -61,6 +62,7 @@ In the workspace folder, create a file `fsm_specification.yaml`, which formally
- SelectKeeperRound
transition_func:
(CollectRandomnessRound, DONE): SelectKeeperRound
(CollectRandomnessRound, NONE): CollectRandomnessRound
(CollectRandomnessRound, NO_MAJORITY): CollectRandomnessRound
(CollectRandomnessRound, ROUND_TIMEOUT): CollectRandomnessRound
(PrintMessageRound, DONE): ResetAndPauseRound
Expand All @@ -70,6 +72,7 @@ In the workspace folder, create a file `fsm_specification.yaml`, which formally
(ResetAndPauseRound, NO_MAJORITY): RegistrationRound
(ResetAndPauseRound, RESET_TIMEOUT): RegistrationRound
(SelectKeeperRound, DONE): PrintMessageRound
(SelectKeeperRound, NONE): RegistrationRound
(SelectKeeperRound, NO_MAJORITY): RegistrationRound
(SelectKeeperRound, ROUND_TIMEOUT): RegistrationRound
```
4 changes: 3 additions & 1 deletion docs/guides/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ Before starting this guide, ensure that your machine satisfies the framework req

1. Fetch the [Hello World service](https://docs.autonolas.network/demos/hello-world/) from the remote registry. Within the workspace folder (not the local registry) run:

<div class="dynamic-hash" packages-json-url="https://raw.githubusercontent.com/valory-xyz/hello-world/main/packages/packages.json" key="service/valory/hello_world/0.1.0">
```bash
autonomy fetch valory/hello_world:0.1.0:bafybeibp2iiojzyykcbkadqdszd35laq2ub34eovyghrsr33t2vrxmk2r4 --service
autonomy fetch valory/hello_world:0.1.0:<hash> --service
```
</div>

This command will download the service package corresponding to the specified hash from the remote IPFS registry and store it in the `hello_world` folder locally.

Expand Down
38 changes: 38 additions & 0 deletions docs/javascripts/dynamic-hash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Dynamically update hashes on MkDocs/Material code blocks.
// Limitations: it does not include the "copy to clipboard" button on the rendered code block.
//
// Example of usage:
// <div class="dynamic-hash" packages-json-url="https://raw.githubusercontent.com/valory-xyz/hello-world/main/packages/packages.json" key="service/valory/hello_world/0.1.0">
// ```
// autonomy fetch valory/hello_world:0.1.0:<hash> --service
// ```
// </div>

document.addEventListener('DOMContentLoaded', function() {
const dynamicHashElements = document.querySelectorAll('.dynamic-hash');

dynamicHashElements.forEach(dynamicHashElement => {
const url = dynamicHashElement.getAttribute('packages-json-url');
const key = dynamicHashElement.getAttribute('key');

fetch(url)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
const hash = data.dev[key] || '<hash>';
console.log(`hash=`, hash);
const originalText = dynamicHashElement.innerText;
const updatedText = originalText.replace(/<hash>/g, hash);
console.log('originalText:', originalText);
console.log('updatedText:', updatedText);
dynamicHashElement.innerHTML = `<div class="highlight"><pre><span></span><code>${updatedText}</code></pre></div>`;
})
.catch(error => {
console.error('Error:', error);
});
});
});
3 changes: 1 addition & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ nav:
- Base: 'api/plugins/aea_test_autonomy/helpers/base.md'
- Contracts: 'api/plugins/aea_test_autonomy/helpers/contracts.md'
- Tendermint Utils: 'api/plugins/aea_test_autonomy/helpers/tendermint_utils.md'
- Data:
- Watcher: 'api/data/Dockerfiles/dev/watcher.md'
- Connections:
- ABCI:
- Check Dependencies: 'api/connections/abci/check_dependencies.md'
Expand Down Expand Up @@ -320,3 +318,4 @@ extra_javascript:
- javascripts/mathjax.js
- https://polyfill.io/v3/polyfill.min.js?features=es6
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
- javascripts/dynamic-hash.js
Loading