Skip to content

Commit

Permalink
feat: justfile works with Linux now (#177)
Browse files Browse the repository at this point in the history
* feat: fix ci and tests

Signed-off-by: Smuu <18609909+Smuu@users.noreply.github.com>

* fix: race condition

Signed-off-by: Smuu <18609909+Smuu@users.noreply.github.com>

* feat: upgrade celestia app v3.0.2 and node v0.20.4 and creates

Signed-off-by: Smuu <18609909+Smuu@users.noreply.github.com>

* feat: remove protoc from github ci

Signed-off-by: Smuu <18609909+Smuu@users.noreply.github.com>

* feat(justfile): support linux

Signed-off-by: Smuu <18609909+Smuu@users.noreply.github.com>

* fix: build

Signed-off-by: Smuu <18609909+Smuu@users.noreply.github.com>

* fix: merge conflict

Signed-off-by: Smuu <18609909+Smuu@users.noreply.github.com>

* fix: dont need double build

Signed-off-by: Smuu <18609909+Smuu@users.noreply.github.com>

* feat: helper function with docker cmd

Signed-off-by: Smuu <18609909+Smuu@users.noreply.github.com>

---------

Signed-off-by: Smuu <18609909+Smuu@users.noreply.github.com>
  • Loading branch information
smuu authored Dec 18, 2024
1 parent 987b01c commit 34876ff
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# Define the path to your docker-compose.yml file
DOCKER_COMPOSE_FILE := "ci/docker-compose.yml"

# Helper function to use correct docker compose command
docker_compose_cmd := if `uname -s` == "Linux" { "docker compose" } else { "docker-compose" }

celestia-up:
#!/usr/bin/env bash
set -euo pipefail
echo "Cleaning up any existing Docker resources..."
docker-compose -f {{DOCKER_COMPOSE_FILE}} down -v --remove-orphans
{{docker_compose_cmd}} -f {{DOCKER_COMPOSE_FILE}} down -v --remove-orphans

echo "Building Docker images..."
docker-compose -f {{DOCKER_COMPOSE_FILE}} build
{{docker_compose_cmd}} -f {{DOCKER_COMPOSE_FILE}} build

echo "Spinning up a fresh Docker Compose stack..."
docker-compose -f {{DOCKER_COMPOSE_FILE}} up -d --force-recreate --renew-anon-volumes
{{docker_compose_cmd}} -f {{DOCKER_COMPOSE_FILE}} up -d --force-recreate --renew-anon-volumes

echo "Waiting for services to be ready..."
timeout=120
Expand All @@ -21,7 +24,7 @@ celestia-up:
bridge_node_ready=false

while true; do
logs=$(docker-compose -f {{DOCKER_COMPOSE_FILE}} logs)
logs=$( {{docker_compose_cmd}} -f {{DOCKER_COMPOSE_FILE}} logs )

if [[ $logs == *"Configuration finished. Running a light node"* ]]; then
light_node_ready=true
Expand All @@ -43,22 +46,21 @@ celestia-up:

if [ $elapsed -ge $timeout ]; then
echo "Timeout waiting for services to be ready. Check the logs for more information."
docker-compose -f {{DOCKER_COMPOSE_FILE}} logs
{{docker_compose_cmd}} -f {{DOCKER_COMPOSE_FILE}} logs
exit 1
fi

echo "Still waiting... (${elapsed}s elapsed)"
sleep 5
done


echo "Celestia stack is up and running!"

celestia-down:
docker-compose -f {{DOCKER_COMPOSE_FILE}} down -v --remove-orphans
{{docker_compose_cmd}} -f {{DOCKER_COMPOSE_FILE}} down -v --remove-orphans

celestia-logs:
docker-compose -f {{DOCKER_COMPOSE_FILE}} logs -f
{{docker_compose_cmd}} -f {{DOCKER_COMPOSE_FILE}} logs -f

# Command to run integration tests with a fresh Docker setup
integration-test:
Expand Down Expand Up @@ -123,6 +125,19 @@ install-deps:
exit 1; \
fi

# On Linux, ensure essential packages are installed
if [ "$OS" = "Linux" ]; then \
for package in build-essential pkg-config libssl-dev libclang-dev clang; do \
if ! dpkg -s $package > /dev/null 2>&1; then \
echo "Installing $package..."; \
sudo apt update; \
sudo apt install $package -y; \
else \
echo "$package is already installed."; \
fi; \
done; \
fi

# Install Redis if not present
if ! command -v redis-server > /dev/null; then \
echo "Installing Redis..."; \
Expand All @@ -141,15 +156,15 @@ install-deps:
echo "Redis is already installed."; \
fi

if ! command -v cargo prove > /dev/null; then \
if ! cargo prove --version > /dev/null 2>&1; then \
echo "Installing SP1..."
curl -L https://sp1.succinct.xyz | bash; \
source ~/.bashrc || source ~/.bash_profile || source ~/.zshrc; \

echo "Running sp1up to install SP1 toolchain..."
sp1up

if command -v cargo prove > /dev/null; then \
if cargo prove --version > /dev/null 2>&1; then \
echo "SP1 installation successful!"; \
cargo prove --version; \
else \
Expand Down

0 comments on commit 34876ff

Please sign in to comment.