#!/bin/bash

set -e

cd /var/app

# run linting of python and yaml files
echo 'Running linting...'
uv run sqlfluff lint .

# run seed
echo 'Running using test target ...'
uv run dbt seed --full-refresh --target test

# run models
run_command="uv run dbt run --target test"
if [ -n "${DBT_FULL_REFRESH}" ]; then
  run_command+=" --full-refresh"
fi
echo "Running dbt run command: ${run_command}"
$run_command

# run test
uv run dbt test --target test

echo 'Done!'
