Skip to content

Commit

Permalink
Merge branch 'add-waypoint' of https://github.com/pennlabs/infrastruc…
Browse files Browse the repository at this point in the history
…ture into add-waypoint
  • Loading branch information
joyliu-q committed Feb 9, 2025
2 parents 1841461 + 06c03d7 commit 55b4abc
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 33 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/cdkactions_docker-waypoint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by cdkactions. Do not modify
# Generated as part of the 'waypoint' stack.
name: Publish waypoint
on:
push:
paths:
- docker/waypoint/**
jobs:
publish-waypoint:
name: Publish waypoint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: buildx-publish-waypoint
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build/Publish
uses: docker/build-push-action@v2
with:
context: docker/waypoint
file: docker/waypoint/Dockerfile
push: ${{ github.ref == 'refs/heads/master' }}
cache-from: type=local,src=/tmp/.buildx-cache,type=registry,ref=pennlabs/waypoint:latest
cache-to: type=local,dest=/tmp/.buildx-cache
tags: pennlabs/waypoint:latest,pennlabs/waypoint:${{ github.sha }}
64 changes: 31 additions & 33 deletions docker/waypoint/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,16 @@ def clone_product(product: str) -> None:
print(f"Repository {product} already exists, skipping clone")


def clone_products() -> None:
def clone_and_init_products() -> None:
"""Clone all products from GitHub if they don't exist."""
for product in PRODUCTS:
clone_product(product)
init_product(product)


def init() -> None:
"""Set up waypoint, install dependencies."""
clone_products()
clone_and_init_products()

if not os.path.exists(os.path.join(WAYPOINT_DIR, "secrets")):
print("No secrets found. Skipping...")
Expand Down Expand Up @@ -169,6 +170,7 @@ def init_product(product: str) -> None:
shell=True,
check=True,
)


# Make .initialized file
with open(os.path.join(product_path, ".initialized"), "w") as f:
Expand Down Expand Up @@ -310,15 +312,11 @@ def main() -> None:

switch_parser = subparsers.add_parser(
"switch",
help="""
Switch to a product environment:
Starts the uv virtual enviroment assosiated with the product, and opens the product in VSCode if in a dev container.
You can also specify --no-vsc to not open VSCode.
help="""Switch to a product environment:
Starts the uv virtual enviroment assosiated with the product, and opens the product in VSCode if in a dev container.
You can also specify --no-vsc to not open VSCode.
Example: waypoint switch office-hours-queue --no-vsc
""",
Example: waypoint switch office-hours-queue --no-vsc""",
)
switch_parser.add_argument(
"product", help="Product to switch to, options: " + ", ".join(PRODUCTS.keys())
Expand All @@ -330,48 +328,48 @@ def main() -> None:
subparsers.add_parser(
"start",
help="""
Start both the backend and frontend of the current development environment:
Runs `python manage.py runserver` and `yarn dev` in the appropriate directories.
Note: Must be in a dev container to run this command.
Start both the backend and frontend of the current development environment:
Runs `python manage.py runserver` and `yarn dev` in the appropriate directories.
Note: Must be in a dev container to run this command.
Example: waypoint start
Example: waypoint start
""",
)

subparsers.add_parser(
"backend",
help="""
Start current product backend
-------------Start current product backend-------------------
Runs `python manage.py runserver` in the appropriate directory.
Note: Must be in a dev container to run this command.
Runs `python manage.py runserver` in the appropriate directory.
Note: Must be in a dev container to run this command.
Example: waypoint backend
Example: waypoint backend
-------------------------------------------------------------
""",
)
subparsers.add_parser(
"frontend",
help="""
Start current product frontend
Runs `yarn dev` in the appropriate directory.
Note: Must be in a dev container to run this command.
-------------Start current product frontend-------------------
Runs `yarn dev` in the appropriate directory.
Note: Must be in a dev container to run this command.
Example: waypoint frontend
""",
Example: waypoint frontend
-------------------------------------------------------------
"""
)

services_parser = subparsers.add_parser(
"services",
help="""
Manage background services:
Starts, stop or chec the status of the PostgreSQL and Redis services.
If no mode is specified, it will start the services.
Example: waypoint services start
""",
-------------Manage background services----------------------
Starts, stop or chec the status of the PostgreSQL and Redis services.
If no mode is specified, it will start the services.
Example: waypoint services start
-------------------------------------------------------------
""",
)
services_parser.add_argument(
"mode",
Expand Down
21 changes: 21 additions & 0 deletions test-waypoint/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

INSTALL_DIR="/usr/local/bin"
WAYPOINT_VERSION="v0.0.2.0"
GITHUB_ORG="pennlabs"
REPO_NAME="infrastructure"

TMP_DIR=$(mktemp -d)
cd $TMP_DIR

echo "Downloading Waypoint..."
curl -L "https://github.com/${GITHUB_ORG}/${REPO_NAME}/releases/download/${WAYPOINT_VERSION}/waypoint-client" -o waypoint-client

chmod +x waypoint-client
sudo mv waypoint-client $INSTALL_DIR/

echo "Waypoint client installed successfully!"
echo "Run 'waypoint-client configure' to get started."
echo "Run 'waypoint-client --help' to see available commands."

rm -rf $TMP_DIR

0 comments on commit 55b4abc

Please sign in to comment.