From c7230a04fea908153a6bd20058d1ec9b8b8506f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Miko=C5=82ajczyk?= Date: Fri, 26 Apr 2024 12:43:32 +0200 Subject: [PATCH] oct-1541: rebase master - ci fix --- ci/Dockerfile.multideployer | 16 -- ci/argocd/application.sh | 4 +- ci/argocd/get_multideployer_url.sh | 16 -- ci/argocd/templates/octant-application.yaml | 9 -- localenv/multideployer/Dockerfile | 18 --- localenv/multideployer/server.py | 157 -------------------- 6 files changed, 1 insertion(+), 219 deletions(-) delete mode 100644 ci/Dockerfile.multideployer delete mode 100644 ci/argocd/get_multideployer_url.sh delete mode 100644 localenv/multideployer/Dockerfile delete mode 100644 localenv/multideployer/server.py diff --git a/ci/Dockerfile.multideployer b/ci/Dockerfile.multideployer deleted file mode 100644 index cae93cd928..0000000000 --- a/ci/Dockerfile.multideployer +++ /dev/null @@ -1,16 +0,0 @@ -# This image is copied as-is from localenv/multideployer directory -FROM _CONTRACTS_IMAGE_PLACEHOLDER_ as hardhat -FROM _SUBGRAPH_IMAGE_PLACEHOLDER_ as graph - -RUN apk add curl python3 bash - -WORKDIR /app - -RUN mkdir /hardhat/ -COPY --from=hardhat /app/ /hardhat/ - -COPY --chmod=+x entrypoint.sh . -COPY --chmod=+x wait_for_subgraph.sh . -COPY server.py /app/server.py - -ENTRYPOINT ["./entrypoint.sh"] diff --git a/ci/argocd/application.sh b/ci/argocd/application.sh index 12c17318d3..bf8c88a030 100644 --- a/ci/argocd/application.sh +++ b/ci/argocd/application.sh @@ -59,9 +59,7 @@ if [[ "$ACTION" == "create" ]]; then elif [[ "$ACTION" == "update" ]]; then if [[ "$NETWORK_NAME" == "local" || "$NETWORK_NAME" == "localhost" ]]; then - if [[ "$WEB_CLIENT_REPLICAS" != "0" ]]; then - export FRONTEND_RPC_URL; FRONTEND_RPC_URL=https://$(bash $CI_PROJECT_DIR/ci/argocd/get_rpc_url.sh) - fi + export FRONTEND_RPC_URL; FRONTEND_RPC_URL=https://$(bash $CI_PROJECT_DIR/ci/argocd/get_rpc_url.sh) export BACKEND_RPC_URL=http://anvil:8545 else # This will make webclient use default (wagmi) endpoint diff --git a/ci/argocd/get_multideployer_url.sh b/ci/argocd/get_multideployer_url.sh deleted file mode 100644 index 7f49552120..0000000000 --- a/ci/argocd/get_multideployer_url.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -## Returns the multideployer rpc url used in the environment and healthchecks - -set -e - -URL=$(curl -s -H "Authorization: Bearer ${ARGOCD_ACCESS_TOKEN}" \ - "${ARGOCD_URL}/api/v1/applications/${DEPLOYMENT_ID}/resource?namespace=${DEPLOYMENT_ID}&resourceName=multideployer-fake&version=v1&kind=Ingress&group=networking.k8s.io" \ - | jq -r .manifest | jq -r '.spec.rules[0].host') - -timeout --foreground -s TERM 300 bash -c \ - 'until [[ "$(dig +short -t A ${0}.)" != "" ]]; do\ - >&2 echo "[-] Waiting for ${0} nslookup" && sleep 10;\ - done' $URL - -echo $URL diff --git a/ci/argocd/templates/octant-application.yaml b/ci/argocd/templates/octant-application.yaml index a3f35bdeab..222cca5adc 100644 --- a/ci/argocd/templates/octant-application.yaml +++ b/ci/argocd/templates/octant-application.yaml @@ -33,8 +33,6 @@ spec: value: '$NETWORK_NAME' - name: 'webClient.hideCurrentProjectsOutsideAW' value: 'false' - - name: 'webClient.safeEndpoint' - value: 'https://safe-transaction-sepolia.safe.global/' ## Graph Node - name: graphNode.graph.env.NETWORK value: '$NETWORK_NAME' @@ -44,10 +42,6 @@ spec: value: '100000' - name: graphHealtchecker.replicas value: '${GRAPH_HEALTHCHECKER_REPLICAS:-1}' - - name: subgraph.deploy - value: '$SUBGRAPH_DEPLOY' - - name: graphHealtchecker.enabled - value: '$GRAPH_HEALTCHECKER_ENABLED' ## Coin Prices Server - name: coinPricesServer.replicas value: '${COIN_PRICES_SERVER_REPLICAS:-2}' @@ -109,9 +103,6 @@ spec: value: 'true' - name: ingress.cloudflareProxied.graph-ipfs value: 'true' - # APITests / Multideployer - - name: multideployer.enabled - value: '$MULTIDEPLOYER_ENABLED' - repoURL: 'https://gitlab.com/api/v4/projects/48137258/packages/helm/devel' targetRevision: 0.0.10 chart: octant-anvil diff --git a/localenv/multideployer/Dockerfile b/localenv/multideployer/Dockerfile deleted file mode 100644 index a4ee41711a..0000000000 --- a/localenv/multideployer/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM octant/contracts:latest as hardhat -FROM octant/subgraph:latest as graph - -RUN apk add curl python3 bash - - -RUN mkdir /hardhat/ -WORKDIR /hardhat/ -COPY --from=hardhat /app/ /hardhat/ -RUN npx hardhat compile - -WORKDIR /app/ - -COPY --chmod=+x entrypoint.sh . -COPY --chmod=+x wait_for_subgraph.sh . -COPY server.py /app/server.py - -ENTRYPOINT ["./entrypoint.sh"] diff --git a/localenv/multideployer/server.py b/localenv/multideployer/server.py deleted file mode 100644 index dd48d4a186..0000000000 --- a/localenv/multideployer/server.py +++ /dev/null @@ -1,157 +0,0 @@ -import json -import os -import subprocess - -from http.server import BaseHTTPRequestHandler -from urllib.parse import parse_qsl, urlparse -from http.server import HTTPServer -from typing import Dict - -subgraph_admin_url = os.environ["SUBGRAPH_ADMIN_URL"] -subgraph_query_url = os.environ["SUBGRAPH_QUERY_URL"] -rpc_url = os.environ["RPC_URL"] -ipfs_url = os.environ["IPFS_URL"] - -# cache for already deployed environments -# key is subgraph name -# value is a dict -deployments = {} - - -def make_env(defs): - os.environ.update(defs) - return os.environ - - -def get_addresses(lines): - def is_address(line): - return "CONTRACT_ADDRESS=" in line - - envs = list(filter(is_address, lines)) - return {var.split("=")[0]: var.split("=")[1] for var in envs} - - -def setup_subgraph(contracts, testname): - env = dict(contracts) - fn = f"/tmp/{testname}_subgraph_networks.json" - env["NETWORK_FILE"] = fn - subprocess.run(["./configure-network.sh"], env=make_env(env), check=True) - subprocess.run( - ["yarn", "codegen"], - env=make_env(env), - check=True, - ) - subprocess.run( - ["yarn", "graph", "build", "--network", "localhost", "--network-file", fn], - check=True, - ) - subprocess.run( - ["yarn", "graph", "create", "--node", subgraph_admin_url, testname], - check=True, - ) - subprocess.run( - [ - "yarn", - "graph", - "deploy", - "--ipfs", - ipfs_url, - "--node", - subgraph_admin_url, - "--network", - "localhost", - "--version-label=v0.0.1", - "--network-file", - fn, - testname, - ], - check=True, - ) - subprocess.run( - ["./wait_for_subgraph.sh", f"{subgraph_query_url}/subgraphs/name/{testname}"], - check=True, - ) - - -class WebRequestHandler(BaseHTTPRequestHandler): - def run_sync(self, query): - return subprocess.run(query, capture_output=True, text=True) - - def get_env(self, name): - if name in deployments: - print(f"Cached deployment of {name}") - return deployments[name] - else: - print(f"New deployment of {name}") - new_deployment = self.new_deployment(name) - deployments[name] = new_deployment - return new_deployment - - def new_deployment(self, name) -> Dict[str, str]: - contracts = subprocess.run( - [ - "npx", - "hardhat", - "--network", - "localhost", - "deploy", - "--reset", - "--write", - "false", - "--tags", - "local", - ], - check=True, - capture_output=True, - text=True, - cwd="../hardhat/", - ) - addrs = get_addresses(contracts.stdout.split("\n")) - - setup_subgraph(addrs, name) - addrs["SUBGRAPH_NAME"] = name - - return addrs - - def url(self): - return urlparse(self.path) - - def query_data(self): - return dict(parse_qsl(self.url().query)) - - def do_GET(self): - if self.path == "/ping": - self.send_response(200) - self.send_header('Content-type', "text/plain") - self.end_headers() - return - - query = self.query_data() - if "name" not in query: - self.send_response(400) - self.wfile.write('Missing "name" field in GET query fields'.encode("utf-8")) - return - results = self.get_env(query["name"]) - if ("Accept" in self.headers) and ( - self.headers["Accept"] == "application/json" - ): - content_type = "application/json" - output = json.dumps(results).encode("utf-8") - else: - content_type = "text/plain" - output = "\n".join([f"{k}={v}" for k, v in results.items()]).encode("utf-8") - self.send_response(200) - self.send_header("Content-Type", content_type) - self.end_headers() - self.wfile.write(output) - - -if __name__ == "__main__": - host = "0.0.0.0" - port = 8022 - print(f"Multideployer listening on http://{host}:{port}") - print( - f"Run GET with appropriate timeout value against http://{host}:{port}/?name=NAME_OF_YOUR_SUBGRAPH" - ) - server = HTTPServer((host, port), WebRequestHandler) - server.serve_forever()