From 0e07bd6bd83791dd466fa651420c7c23159add62 Mon Sep 17 00:00:00 2001 From: Sandipan Dey Date: Sun, 11 Feb 2024 21:45:19 +0530 Subject: [PATCH] tilt ci --- .github/workflows/ci.yml | 45 +++++++++++++++++++ .gitignore | 1 - Makefile | 3 ++ dev/.env | 2 + dev/Tiltfile | 18 ++++++++ dev/bin/blocks.sh | 12 +++++ dev/bin/setup.sh | 25 +++++++++++ .../galoy-quickstart/docker-compose.yml | 2 + 8 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 dev/.env create mode 100755 dev/bin/blocks.sh create mode 100755 dev/bin/setup.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..bf8d5023e5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: tilt-ci + +on: [push] + +jobs: + tilt-ci-android: + name: Tilt CI Android + runs-on: ["self-hosted", "Linux", "X64"] + + steps: + - uses: actions/checkout@v2 + - uses: DeterminateSystems/magic-nix-cache-action@v2 + - name: Tilt CI + run: | + for i in {1..5}; do + echo "Tilt CI attempt $i" + nix develop -c sh -c 'cd dev && tilt ci' && exit 0 || sleep 60 + done + exit 1 + - name: Destroy backend + if: always() + continue-on-error: true + run: nix develop -c sh -c 'cd dev && tilt down' + + # tilt-ci-ios: + # name: Tilt CI MacOS + # runs-on: ["self-hosted", "MacOS", "ARM64"] + + # steps: + # - uses: actions/checkout@v2 + # - uses: DeterminateSystems/magic-nix-cache-action@v2 + # - name: Run local backend in background + # run: | + # nix develop -c echo "nix flake built" + # nix develop -c make tilt-up & + # echo $? > dev/.tilt-pid.tmp.ci + # sleep 5 + # - name: Wait for backend to be ready + # run: nix develop -c tilt wait --timeout 1h --for=condition=Ready uiresources init-setup + # - name: Destroy backend + # if: always() + # continue-on-error: true + # run: | + # kill $(cat dev/.tilt-pid.tmp.ci) || true + # nix develop -c make tilt-down diff --git a/.gitignore b/.gitignore index c1af39c5a3..022f8c6869 100644 --- a/.gitignore +++ b/.gitignore @@ -75,7 +75,6 @@ yalc.lock *.log -.env .dependencies ios/assets ios/GaloyApp/assets diff --git a/Makefile b/Makefile index a4a3d85d61..ef215e473e 100644 --- a/Makefile +++ b/Makefile @@ -24,3 +24,6 @@ tilt-up: tilt-down: cd dev && GALOY_QUICKSTART_PATH="dev/vendor/galoy-quickstart" tilt down + +tilt-ci: + cd dev && GALOY_QUICKSTART_PATH="dev/vendor/galoy-quickstart" tilt ci diff --git a/dev/.env b/dev/.env new file mode 100644 index 0000000000..9ed68f86c3 --- /dev/null +++ b/dev/.env @@ -0,0 +1,2 @@ +ALICE_PHONE="+919876540001" +BOB_PHONE="+919876540002" diff --git a/dev/Tiltfile b/dev/Tiltfile index 4926e49750..4ef74db2d9 100644 --- a/dev/Tiltfile +++ b/dev/Tiltfile @@ -31,3 +31,21 @@ for service in bitcoin_services: dc_resource('otel-agent', labels = ["otel"]) dc_resource('quickstart-test', labels = ['quickstart'], auto_init=False) + +local_resource( + name='init-setup', + labels = ['dev-setup'], + cmd='bin/setup.sh', + resource_deps = galoy_services + [ + "init-lightning" + ] +) + +# local_resource( +# name='blocks', +# labels = ['dev-setup'], +# cmd='bin/blocks.sh', +# resource_deps = [ +# "init-setup" +# ] +# ) diff --git a/dev/bin/blocks.sh b/dev/bin/blocks.sh new file mode 100755 index 0000000000..0369178c58 --- /dev/null +++ b/dev/bin/blocks.sh @@ -0,0 +1,12 @@ +#!/bin/bash + + set -e + + REPO_ROOT=$(git rev-parse --show-toplevel) + + source ${REPO_ROOT}/dev/vendor/galoy-quickstart/bin/helpers.sh + + while true; do + bitcoin_cli -generate 1 + sleep 2 + done diff --git a/dev/bin/setup.sh b/dev/bin/setup.sh new file mode 100755 index 0000000000..9dc2c54989 --- /dev/null +++ b/dev/bin/setup.sh @@ -0,0 +1,25 @@ +#!/bin/bash + + set -e + + REPO_ROOT=$(git rev-parse --show-toplevel) + + source ${REPO_ROOT}/dev/vendor/galoy-quickstart/bin/helpers.sh + source ${REPO_ROOT}/dev/.env + + login_user "alice" "$ALICE_PHONE" "000000" + echo "alice logged in" + ALICE_TOKEN=$(read_value "alice") + receive_onchain + echo "alice funded" + + login_user "alice" "$BOB_PHONE" "000000" + echo "bob logged in" + BOB_TOKEN=$(read_value "alice") + receive_onchain + echo "bob funded" + + cat < .env.tmp.ci + ALICE_TOKEN="$ALICE_TOKEN" + BOB_TOKEN="$BOB_TOKEN" + EOF diff --git a/dev/vendor/galoy-quickstart/docker-compose.yml b/dev/vendor/galoy-quickstart/docker-compose.yml index 951b087fea..f3a488b360 100644 --- a/dev/vendor/galoy-quickstart/docker-compose.yml +++ b/dev/vendor/galoy-quickstart/docker-compose.yml @@ -219,6 +219,8 @@ services: - OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-agent:4318 ports: - 6685:6685 + links: + - notifications-pg:notifications-pg notifications-pg: image: postgres:14.1 environment: