From 25a493ab2e91eb96a49aaf97508bc9114c3ae240 Mon Sep 17 00:00:00 2001 From: folex <0xdxdy@gmail.com> Date: Mon, 23 Aug 2021 18:24:52 +0300 Subject: [PATCH] CI: update aqua-ipfs version in Builtin Services (#22) BREAKING CHANGE: IPFS builtin service id changed from 'ipfs-adapter' to 'aqua-ipfs' --- .circleci/config.yml | 4 +- .github/workflows/release.yml | 61 ++++++++++++++++++++++++-- README.md | 4 +- aqua/README.md | 4 +- aqua/ipfs-api.aqua | 4 +- aqua/ipfs.aqua | 2 +- aqua/target/typescript/src/ipfs-api.ts | 16 +++---- service/artifacts/on_start.air | 6 +-- service/artifacts/on_start.json | 6 +-- service/build.sh | 2 +- 10 files changed, 81 insertions(+), 28 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3e7533b..a52a727 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,7 @@ jobs: sudo bash .github/download_marine.sh - restore_cache: keys: - - ipfs-adapter00-{{ checksum "./service/pure/Cargo.lock" }}-{{ checksum "./service/effector/Cargo.lock" }} + - aqua-ipfs00-{{ checksum "./service/pure/Cargo.lock" }}-{{ checksum "./service/effector/Cargo.lock" }} - run: | rustup toolchain install nightly-2021-04-24-x86_64-unknown-linux-gnu rustup default nightly-2021-04-24-x86_64-unknown-linux-gnu @@ -28,7 +28,7 @@ jobs: paths: - ~/.cargo - ~/.rustup - key: ipfs-adapter00-{{ checksum "./service/pure/Cargo.lock" }}-{{ checksum "./service/effector/Cargo.lock" }} + key: aqua-ipfs00-{{ checksum "./service/pure/Cargo.lock" }}-{{ checksum "./service/effector/Cargo.lock" }} workflows: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 521f846..1c2937a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -66,15 +66,15 @@ jobs: rustup target add wasm32-wasi --toolchain nightly-2021-04-24-x86_64-unknown-linux-gnu ### Build - - name: Build ipfs-adapter + - name: Build aqua-ipfs working-directory: ./service run: ./build.sh - name: Create distribution package working-directory: ./service run: | - mv artifacts ipfs-adapter - tar -zcvf ipfs-adapter.tar.gz ipfs-adapter + mv artifacts aqua-ipfs + tar -zcvf aqua-ipfs.tar.gz aqua-ipfs - name: Compile Aqua to TypeScript working-directory: ./aqua @@ -98,12 +98,13 @@ jobs: ### Publish - name: Release to GitHub + id: release uses: softprops/action-gh-release@v1 with: name: aqua-ipfs ${{ env.RELEASE_VERSION }} tag_name: ${{ env.RELEASE_VERSION }} files: | - ./service/ipfs-adapter.tar.gz + ./service/aqua-ipfs.tar.gz body: ${{steps.github_release.outputs.changelog}} draft: false prerelease: false @@ -136,3 +137,55 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} working-directory: ./aqua/target/typescript + +## Update Builtin Services repo + - name: Get tar.gz URL + id: package-url + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + result-encoding: string + script: | + try { + let assets = await github.repos.listReleaseAssets({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: "${{ steps.release.outputs.id }}", + }); + console.dir(assets); + let package = assets.data.find((a) => a.name === 'aqua-ipfs.tar.gz'); + let url = package.browser_download_url; + console.log("URL: " + url); + return url; + } catch (e) { + console.log("Err: " + e); + throw e; + } + + - name: Calculate SHA256 + run: | + du -hs ./service/aqua-ipfs.tar.gz + echo $(sha256sum ./service/aqua-ipfs.tar.gz) + echo "SHA256=$(sha256sum ./service/aqua-ipfs.tar.gz | awk '{ print $1 }')" >> $GITHUB_ENV + + - name: Update version in builtins repo + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: update_service + repo: fluencelabs/builtin-services + ref: 'main' + token: ${{ secrets.PERSONAL_TOKEN }} + inputs: '{ + "name": "aqua-ipfs", + "version": "${{ env.RELEASE_VERSION }}", + "url": "${{ steps.package-url.outputs.result }}", + "sha256": "${{ env.SHA256 }}" + }' + + - name: Log notice + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + console.dir(core); + core.info("aqua-ipfs was updated to ${{ env.RELEASE_VERSION }} in Builtin Services Repo"); diff --git a/README.md b/README.md index 9768484..785cdcc 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ cid === localCID // true ``` ## Directory structure -- `aqua` Aqua API of IPFS-adapter, go to its [README](/aqua/README.md) +- `aqua` Aqua API of AquaIPFS. See [aqua/README](/aqua/README.md) - `service` contains Rust service that implements all the IPFS calls by using `ipfs` cli mounted binary - `example` A simple example of how to use ipfs adapter from TypeScript - `local-network` contains Docker Compose YAML config to run a local Fluence network of 3 nodes @@ -35,4 +35,4 @@ cid === localCID // true # Contribution Contributions are welcome! -`ipfs-adapter` integrates with IPFS by using `ipfs` CLI, so it's possible to expose virtually any IPFS API to Aqua. Feel free to open an issue or contribute APIs and patterns you find useful. +`aqua-ipfs` integrates with IPFS by using `ipfs` CLI, so it's possible to expose virtually any IPFS API to Aqua. Feel free to open an issue or contribute APIs and patterns you find useful. diff --git a/aqua/README.md b/aqua/README.md index 42873d9..6666e65 100644 --- a/aqua/README.md +++ b/aqua/README.md @@ -1,4 +1,4 @@ -# Aqua API of IPFS-adapter +# Aqua API of AquaIPFS ## Documentation See [Aqua Book](https://fluence.dev/aqua-book/libraries/aqua-ipfs). @@ -6,7 +6,7 @@ See [Aqua Book](https://fluence.dev/aqua-book/libraries/aqua-ipfs). ## API Public API is defined in [ipfs-api.aqua](/aqua/ipfs-api.aqua). -ipfs-adapter service API is defined in [ipfs.aqua](/aqua/ipfs.aqua). +aqua-ipfs service API is defined in [ipfs.aqua](/aqua/ipfs.aqua). ## How to use Aqua API in TypeScript There's a simple example in [example](/example/index.ts) diff --git a/aqua/ipfs-api.aqua b/aqua/ipfs-api.aqua index c217970..ef03f7f 100644 --- a/aqua/ipfs-api.aqua +++ b/aqua/ipfs-api.aqua @@ -46,7 +46,7 @@ func get_and_cache( <- localCid -- Upload file `path` to IPFS node running on `node` --- path should exist & be available to `ipfs-adapter` +-- path should exist & be available to `aqua-ipfs` func put(node: PeerId, path: string) -> IpfsPutResult: on node: result <- Ipfs.put(path) @@ -58,7 +58,7 @@ func get_from(node: PeerId, cid: CID, from: Multiaddr) -> IpfsGetResult: result <- Ipfs.get_from(cid, from) <- result --- Set timeout for IPFS calls in `ipfs-adapter` +-- Set timeout for IPFS calls in `aqua-ipfs` func set_timeout(node: PeerId, timeout_sec: u64): on node: Ipfs.set_timeout(timeout_sec) diff --git a/aqua/ipfs.aqua b/aqua/ipfs.aqua index b2d9437..bd0b87d 100644 --- a/aqua/ipfs.aqua +++ b/aqua/ipfs.aqua @@ -17,7 +17,7 @@ data IpfsResult: success: bool error: string -service Ipfs("ipfs-adapter"): +service Ipfs("aqua-ipfs"): connect(multiaddr: string) -> IpfsResult get(hash: string) -> IpfsGetResult get_external_api_multiaddr() -> IpfsMultiaddrResult diff --git a/aqua/target/typescript/src/ipfs-api.ts b/aqua/target/typescript/src/ipfs-api.ts index 1588b9d..7ab071e 100644 --- a/aqua/target/typescript/src/ipfs-api.ts +++ b/aqua/target/typescript/src/ipfs-api.ts @@ -32,7 +32,7 @@ export async function set_timeout(client: FluenceClient, node: string, timeout_s (call -relay- ("op" "noop") []) ) (xor - (call node ("ipfs-adapter" "set_timeout") [timeout_sec]) + (call node ("aqua-ipfs" "set_timeout") [timeout_sec]) (seq (call -relay- ("op" "noop") []) (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) @@ -101,12 +101,12 @@ export async function get_and_cache(client: FluenceClient, node: string, cid: st ) (xor (seq - (call node ("ipfs-adapter" "get_from") [cid from] get) + (call node ("aqua-ipfs" "get_from") [cid from] get) (xor (match get.$.success! true (xor (seq - (call node ("ipfs-adapter" "put") [get.$.path!] put) + (call node ("aqua-ipfs" "put") [get.$.path!] put) (xor (match put.$.success! true (xor @@ -228,7 +228,7 @@ export async function get_from(client: FluenceClient, node: string, cid: string, (call -relay- ("op" "noop") []) ) (xor - (call node ("ipfs-adapter" "get_from") [cid from] result) + (call node ("aqua-ipfs" "get_from") [cid from] result) (seq (call -relay- ("op" "noop") []) (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) @@ -299,7 +299,7 @@ export async function get_local_api_multiaddr(client: FluenceClient, node: strin (call -relay- ("op" "noop") []) ) (xor - (call node ("ipfs-adapter" "get_local_api_multiaddr") [] result) + (call node ("aqua-ipfs" "get_local_api_multiaddr") [] result) (seq (call -relay- ("op" "noop") []) (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) @@ -368,7 +368,7 @@ export async function get_external_swarm_multiaddr(client: FluenceClient, node: (call -relay- ("op" "noop") []) ) (xor - (call node ("ipfs-adapter" "get_external_swarm_multiaddr") [] result) + (call node ("aqua-ipfs" "get_external_swarm_multiaddr") [] result) (seq (call -relay- ("op" "noop") []) (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) @@ -440,7 +440,7 @@ export async function put(client: FluenceClient, node: string, path: string, con (call -relay- ("op" "noop") []) ) (xor - (call node ("ipfs-adapter" "put") [path] result) + (call node ("aqua-ipfs" "put") [path] result) (seq (call -relay- ("op" "noop") []) (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) @@ -510,7 +510,7 @@ export async function get_external_api_multiaddr(client: FluenceClient, node: st (call -relay- ("op" "noop") []) ) (xor - (call node ("ipfs-adapter" "get_external_api_multiaddr") [] result) + (call node ("aqua-ipfs" "get_external_api_multiaddr") [] result) (seq (call -relay- ("op" "noop") []) (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) diff --git a/service/artifacts/on_start.air b/service/artifacts/on_start.air index 9b3771a..025a2c3 100644 --- a/service/artifacts/on_start.air +++ b/service/artifacts/on_start.air @@ -1,7 +1,7 @@ (seq (seq (seq - (call relay ("ipfs-adapter" "set_local_api_multiaddr") [local_api_multiaddr] local_api_res) + (call relay ("aqua-ipfs" "set_local_api_multiaddr") [local_api_multiaddr] local_api_res) (xor (match local_api_res.$.success! true (null) @@ -10,7 +10,7 @@ ) ) (seq - (call relay ("ipfs-adapter" "set_external_api_multiaddr") [external_api_multiaddr] external_api_res) + (call relay ("aqua-ipfs" "set_external_api_multiaddr") [external_api_multiaddr] external_api_res) (xor (match external_api_res.$.success! true (null) @@ -20,7 +20,7 @@ ) ) (seq - (call relay ("ipfs-adapter" "set_external_swarm_multiaddr") [external_swarm_multiaddr] external_swarm_res) + (call relay ("aqua-ipfs" "set_external_swarm_multiaddr") [external_swarm_multiaddr] external_swarm_res) (xor (match external_swarm_res.$.success! true (call %init_peer_id% ("op" "return") [true]) diff --git a/service/artifacts/on_start.json b/service/artifacts/on_start.json index 559bdf7..ebbcd07 100644 --- a/service/artifacts/on_start.json +++ b/service/artifacts/on_start.json @@ -1,5 +1,5 @@ { - "external_swarm_multiaddr": "$FLUENCE_ENV_IPFS_ADAPTER_EXTERNAL_SWARM_MULTIADDR", - "local_api_multiaddr": "$FLUENCE_ENV_IPFS_ADAPTER_LOCAL_API_MULTIADDR", - "external_api_multiaddr": "$FLUENCE_ENV_IPFS_ADAPTER_EXTERNAL_API_MULTIADDR" + "external_swarm_multiaddr": "$FLUENCE_ENV_AQUA_IPFS_EXTERNAL_SWARM_MULTIADDR", + "local_api_multiaddr": "$FLUENCE_ENV_AQUA_IPFS_LOCAL_API_MULTIADDR", + "external_api_multiaddr": "$FLUENCE_ENV_AQUA_IPFS_EXTERNAL_API_MULTIADDR" } diff --git a/service/build.sh b/service/build.sh index becb7b8..93cc732 100755 --- a/service/build.sh +++ b/service/build.sh @@ -18,4 +18,4 @@ mkdir -p artifacts rm -f artifacts/*.wasm cp target/wasm32-wasi/release/ipfs_effector.wasm artifacts/ cp target/wasm32-wasi/release/ipfs_pure.wasm artifacts/ -marine aqua artifacts/ipfs_pure.wasm -s Ipfs -i ipfs-adapter >../aqua/ipfs.aqua +marine aqua artifacts/ipfs_pure.wasm -s Ipfs -i aqua-ipfs >../aqua/ipfs.aqua