From c9bb0d0ccbec00a332b7e0ad141814a804b06ff5 Mon Sep 17 00:00:00 2001 From: Zach Date: Fri, 23 Jun 2023 14:27:05 -0400 Subject: [PATCH 1/3] Lasso stack (#434) * lasso stack * add readme * copy pasta --- app/data/compose/docker-compose-lasso.yml | 8 ++++++++ app/data/container-build/cerc-lasso/build.sh | 4 ++++ app/data/container-image-list.txt | 1 + app/data/pod-list.txt | 1 + app/data/repository-list.txt | 1 + app/data/stacks/lasso/README.md | 7 +++++++ app/data/stacks/lasso/stack.yml | 8 ++++++++ 7 files changed, 30 insertions(+) create mode 100644 app/data/compose/docker-compose-lasso.yml create mode 100755 app/data/container-build/cerc-lasso/build.sh create mode 100644 app/data/stacks/lasso/README.md create mode 100644 app/data/stacks/lasso/stack.yml diff --git a/app/data/compose/docker-compose-lasso.yml b/app/data/compose/docker-compose-lasso.yml new file mode 100644 index 00000000..6e54b5ee --- /dev/null +++ b/app/data/compose/docker-compose-lasso.yml @@ -0,0 +1,8 @@ +version: "3.2" + +services: + lasso: + image: cerc/lasso:local + restart: always + ports: + - "0.0.0.0:3000:3000" diff --git a/app/data/container-build/cerc-lasso/build.sh b/app/data/container-build/cerc-lasso/build.sh new file mode 100755 index 00000000..a27f2fcd --- /dev/null +++ b/app/data/container-build/cerc-lasso/build.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +# Build the lasso image +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/lasso:local -f ${CERC_REPO_BASE_DIR}/lasso/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/lasso diff --git a/app/data/container-image-list.txt b/app/data/container-image-list.txt index 5ed4b2d2..3e4877c0 100644 --- a/app/data/container-image-list.txt +++ b/app/data/container-image-list.txt @@ -42,3 +42,4 @@ cerc/ipld-eth-state-snapshot cerc/watcher-gelato cerc/lotus cerc/go-opera +cerc/lasso diff --git a/app/data/pod-list.txt b/app/data/pod-list.txt index a871c112..70fc5330 100644 --- a/app/data/pod-list.txt +++ b/app/data/pod-list.txt @@ -29,3 +29,4 @@ watcher-azimuth watcher-gelato fixturenet-lotus mainnet-go-opera +lasso diff --git a/app/data/repository-list.txt b/app/data/repository-list.txt index 3d159686..7c7bc1d4 100644 --- a/app/data/repository-list.txt +++ b/app/data/repository-list.txt @@ -35,3 +35,4 @@ github.com/cerc-io/gelato-watcher-ts github.com/filecoin-project/lotus git.vdb.to/cerc-io/test-project github.com/Fantom-foundation/go-opera +github.com/cerc-io/lasso diff --git a/app/data/stacks/lasso/README.md b/app/data/stacks/lasso/README.md new file mode 100644 index 00000000..226e4e39 --- /dev/null +++ b/app/data/stacks/lasso/README.md @@ -0,0 +1,7 @@ +# lasso + +``` +laconic-so --stack lasso setup-repositories +laconic-so --stack lasso build-containers +laconic-so --stack lasso deploy up +``` diff --git a/app/data/stacks/lasso/stack.yml b/app/data/stacks/lasso/stack.yml new file mode 100644 index 00000000..e756202c --- /dev/null +++ b/app/data/stacks/lasso/stack.yml @@ -0,0 +1,8 @@ +version: "0.1" +name: lasso +repos: + - github.com/cerc-io/lasso +containers: + - cerc/lasso +pods: + - lasso -- 2.45.2 From ea725ed512c78c071a9f88403645b8b7509e0b4b Mon Sep 17 00:00:00 2001 From: David Boreham Date: Sat, 24 Jun 2023 11:06:57 -0600 Subject: [PATCH 2/3] Fixes for repos checked out from a tag rather than a branch --- app/setup_repositories.py | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/app/setup_repositories.py b/app/setup_repositories.py index bfcbe0ec..98d9a825 100644 --- a/app/setup_repositories.py +++ b/app/setup_repositories.py @@ -69,8 +69,26 @@ def host_and_path_for_repo(fully_qualified_repo): return repo_host_split[0], "/".join(repo_host_split[1:]), repo_branch +# See: https://stackoverflow.com/questions/18659425/get-git-current-branch-tag-name +def _get_repo_current_branch_or_tag(full_filesystem_repo_path): + current_repo_branch_or_tag = "***UNDETERMINED***" + is_branch = False + try: + current_repo_branch_or_tag = git.Repo(full_filesystem_repo_path).active_branch.name + is_branch = True + except TypeError as error: + # This means that the current ref is not a branch, so possibly a tag + # Let's try to get the tag + current_repo_branch_or_tag = git.Repo(full_filesystem_repo_path).git.describe("--tags", "--exact-match") + # Note that git is assymetric -- the tag you told it to check out may not be the one + # you get back here (if there are multiple tags associated with the same commit) + return current_repo_branch_or_tag, is_branch + + # TODO: fix the messy arg list here def process_repo(verbose, quiet, dry_run, pull, check_only, git_ssh, dev_root_path, branches_array, fully_qualified_repo): + if verbose: + print(f"Processing repo: {fully_qualified_repo}") repo_host, repo_path, repo_branch = host_and_path_for_repo(fully_qualified_repo) git_ssh_prefix = f"git@{repo_host}:" git_http_prefix = f"https://{repo_host}/" @@ -78,9 +96,9 @@ def process_repo(verbose, quiet, dry_run, pull, check_only, git_ssh, dev_root_pa repoName = repo_path.split("/")[-1] full_filesystem_repo_path = os.path.join(dev_root_path, repoName) is_present = os.path.isdir(full_filesystem_repo_path) - current_repo_branch = git.Repo(full_filesystem_repo_path).active_branch.name if is_present else None + (current_repo_branch_or_tag, is_branch) = _get_repo_current_branch_or_tag(full_filesystem_repo_path) if is_present else None if not quiet: - present_text = f"already exists active branch: {current_repo_branch}" if is_present \ + present_text = f"already exists active {'branch' if is_branch else 'tag'}: {current_repo_branch_or_tag}" if is_present \ else 'Needs to be fetched' print(f"Checking: {full_filesystem_repo_path}: {present_text}") # Quick check that it's actually a repo @@ -93,9 +111,12 @@ def process_repo(verbose, quiet, dry_run, pull, check_only, git_ssh, dev_root_pa if verbose: print(f"Running git pull for {full_filesystem_repo_path}") if not check_only: - git_repo = git.Repo(full_filesystem_repo_path) - origin = git_repo.remotes.origin - origin.pull(progress=None if quiet else GitProgress()) + if is_branch: + git_repo = git.Repo(full_filesystem_repo_path) + origin = git_repo.remotes.origin + origin.pull(progress=None if quiet else GitProgress()) + else: + print(f"skipping pull because this repo checked out a tag") else: print("(git pull skipped)") if not is_present: @@ -122,14 +143,15 @@ def process_repo(verbose, quiet, dry_run, pull, check_only, git_ssh, dev_root_pa branch_to_checkout = repo_branch if branch_to_checkout: - if current_repo_branch is None or (current_repo_branch and (current_repo_branch != branch_to_checkout)): + if current_repo_branch_or_tag is None or (current_repo_branch_or_tag and (current_repo_branch_or_tag != branch_to_checkout)): if not quiet: print(f"switching to branch {branch_to_checkout} in repo {repo_path}") git_repo = git.Repo(full_filesystem_repo_path) + # git checkout works for both branches and tags git_repo.git.checkout(branch_to_checkout) else: if verbose: - print(f"repo {repo_path} is already switched to branch {branch_to_checkout}") + print(f"repo {repo_path} is already on branch/tag {branch_to_checkout}") def parse_branches(branches_string): -- 2.45.2 From b19b772334384c22c7c8201332a03a2030bd2ddf Mon Sep 17 00:00:00 2001 From: David Boreham Date: Sat, 24 Jun 2023 11:13:19 -0600 Subject: [PATCH 3/3] Fix happy path --- app/setup_repositories.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/setup_repositories.py b/app/setup_repositories.py index 98d9a825..db0bd779 100644 --- a/app/setup_repositories.py +++ b/app/setup_repositories.py @@ -96,7 +96,7 @@ def process_repo(verbose, quiet, dry_run, pull, check_only, git_ssh, dev_root_pa repoName = repo_path.split("/")[-1] full_filesystem_repo_path = os.path.join(dev_root_path, repoName) is_present = os.path.isdir(full_filesystem_repo_path) - (current_repo_branch_or_tag, is_branch) = _get_repo_current_branch_or_tag(full_filesystem_repo_path) if is_present else None + (current_repo_branch_or_tag, is_branch) = _get_repo_current_branch_or_tag(full_filesystem_repo_path) if is_present else (None, None) if not quiet: present_text = f"already exists active {'branch' if is_branch else 'tag'}: {current_repo_branch_or_tag}" if is_present \ else 'Needs to be fetched' -- 2.45.2