Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: justfile works with Linux now #177

Merged
merged 10 commits into from
Dec 18, 2024
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 \
smuu marked this conversation as resolved.
Show resolved Hide resolved
echo "SP1 installation successful!"; \
cargo prove --version; \
else \
Expand Down
Loading