11#! /bin/bash
22
3- # This script runs the analysis of the bot's performance and generates a report.
3+ # This script runs the analysis workflow and updates the dashboard.
4+ set -euo pipefail
45
56CONFIG_FILE=" input/config.json"
6- # make sure venv is up to date
7- uv sync
87
9- # run analysis using the bot's command line interface
10- uv run sw-metadata-bot run-analysis --config-file $CONFIG_FILE
8+ USE_UV=false
9+ if command -v uv > /dev/null 2>&1 && [ -d " .venv" ]; then
10+ USE_UV=true
11+ fi
12+
13+ if [ " $USE_UV " = true ]; then
14+ echo " Using uv environment (.venv detected)."
15+ uv sync
16+ else
17+ echo " Using pip fallback (uv missing or .venv not found)."
18+
19+ if [ -x " .venv/bin/python" ]; then
20+ PYTHON_BIN=" .venv/bin/python"
21+ elif command -v python3 > /dev/null 2>&1 ; then
22+ PYTHON_BIN=" python3"
23+ elif command -v python > /dev/null 2>&1 ; then
24+ PYTHON_BIN=" python"
25+ else
26+ echo " Error: No Python interpreter found."
27+ exit 1
28+ fi
29+
30+ " $PYTHON_BIN " -m pip install --upgrade pip
31+ " $PYTHON_BIN " -m pip install " pystache>=0.6.8" " sw-metadata-bot>=0.4.1"
32+ fi
33+
34+ if [ " $USE_UV " = true ]; then
35+ uv run sw-metadata-bot run-analysis --config-file " $CONFIG_FILE "
36+ else
37+ " $PYTHON_BIN " -m sw_metadata_bot.main run-analysis --config-file " $CONFIG_FILE "
38+ fi
1139
1240echo " Analysis completed. Publishing results to respective repositories..."
1341
14- OUTPUT_DIR=$( uv run python -c " import read_config; config = read_config.read_config('$CONFIG_FILE '); print(read_config.get_output_folder(config))" )
15- # get latest subfolder created from config file
16- LATEST_SUBFOLDER=$( ls -td $OUTPUT_DIR /* / | head -1)
42+ if [ " $USE_UV " = true ]; then
43+ OUTPUT_DIR=$( uv run python -c " import read_config; config = read_config.read_config('$CONFIG_FILE '); print(read_config.get_output_folder(config))" )
44+ else
45+ OUTPUT_DIR=$(
46+ " $PYTHON_BIN " -c " import read_config; config = read_config.read_config('$CONFIG_FILE '); print(read_config.get_output_folder(config))"
47+ )
48+ fi
49+
50+ # Get latest snapshot folder from output directory.
51+ LATEST_SUBFOLDER=$( ls -td " $OUTPUT_DIR " /* / | head -1)
52+ if [ -z " ${LATEST_SUBFOLDER:- } " ]; then
53+ echo " Error: No snapshot folder found under $OUTPUT_DIR "
54+ exit 1
55+ fi
56+
57+ if [ " $USE_UV " = true ]; then
58+ uv run sw-metadata-bot publish --analysis-root " $LATEST_SUBFOLDER "
59+ else
60+ " $PYTHON_BIN " -m sw_metadata_bot.main publish --analysis-root " $LATEST_SUBFOLDER "
61+ fi
1762
18- # publish results to github pages
19- uv run sw-metadata-bot publish --analysis-root $LATEST_SUBFOLDER /
2063echo " Issues submitted to the repositories"
2164
22- # generate landing page
23- uv run python generate_landing_page.py
65+ if [ " $USE_UV " = true ]; then
66+ uv run python generate_landing_page.py --config-file " $CONFIG_FILE "
67+ else
68+ " $PYTHON_BIN " generate_landing_page.py --config-file " $CONFIG_FILE "
69+ fi
0 commit comments