-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_ci_local.sh
More file actions
executable file
·120 lines (105 loc) · 3.89 KB
/
run_ci_local.sh
File metadata and controls
executable file
·120 lines (105 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env bash
# run_ci_local.sh - Run CI checks locally (mirrors .github/workflows/ci.yml)
#
# Usage:
# ./run_ci_local.sh
#
# Runs the same steps as CI in order:
# 1. uv sync --locked --dev --all-extras (install deps)
# 2. Python version verification
# 3. ruff critical errors (blocking)
# 4. ruff format check (blocking)
# 5. ruff full check (non-blocking, informational)
# 6. actionlint (validate CI workflow syntax)
# 7. pytest safe subset with STRICT marker exclusions
set -uo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Terminal colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BOLD='\033[1m'
NC='\033[0m'
FAILED_COUNT=0
PASSED_COUNT=0
FAILED_NAMES=""
step() {
local name="$1"
shift
echo ""
echo -e "${BOLD}=== $name ===${NC}"
if "$@"; then
echo -e "${GREEN}✓ PASSED: $name${NC}"
PASSED_COUNT=$((PASSED_COUNT + 1))
else
echo -e "${RED}✗ FAILED: $name${NC}"
FAILED_COUNT=$((FAILED_COUNT + 1))
FAILED_NAMES="$FAILED_NAMES\n ✗ $name"
fi
}
step_nonblocking() {
local name="$1"
shift
echo ""
echo -e "${BOLD}=== $name (non-blocking) ===${NC}"
if "$@"; then
echo -e "${GREEN}✓ PASSED: $name${NC}"
else
echo -e "${YELLOW}⚠ ISSUES: $name (informational only, not blocking)${NC}"
fi
PASSED_COUNT=$((PASSED_COUNT + 1))
}
echo -e "${BOLD}=== autorun Local CI ===${NC}"
echo "Working directory: $SCRIPT_DIR"
# Step 1: Install dependencies
# UV workspace with committed uv.lock -- use --locked to reproduce exact environment.
# --dev installs [dependency-groups] dev (pytest, pytest-asyncio, pytest-cov, etc.)
# --all-extras also installs [project.optional-dependencies] extras.
step "Install dependencies (uv sync --locked --dev --all-extras)" \
uv sync --locked --dev --all-extras
# Step 2: Verify Python version
step "Verify Python version" \
uv run python --version
# Step 3: Lint - critical errors only (blocking: syntax errors, undefined names)
# E9=syntax, F63/F7/F82=undefined names/imports
step "Lint - critical errors (blocking)" \
uvx ruff check --select E9,F63,F7,F82 .
# TODO: enable ruff format --check once the codebase has been uniformly formatted.
# The code was not written with ruff format -- 150 of 153 files need reformatting.
# Run `uvx ruff format .` in a dedicated commit when ready, then uncomment:
# step "Lint - format check (blocking)" uvx ruff format --check .
# Step 4 (renumbered): Lint - full check (non-blocking: style, imports, etc.)
step_nonblocking "Lint - full check (informational)" \
uvx ruff check .
# Step 6: Validate CI workflow syntax
if command -v actionlint &>/dev/null; then
step "Validate CI workflow (actionlint)" \
actionlint .github/workflows/ci.yml
else
echo ""
echo -e "${YELLOW}⚠ actionlint not found -- skipping workflow validation${NC}"
echo " Install with: brew install actionlint"
fi
# Step 7: Safe unit test subset
# Run from plugins/autorun/ so pytest discovers plugins/autorun/pyproject.toml
# for asyncio_mode, markers, timeout config (not the workspace root pyproject.toml).
# Tests live at plugins/autorun/tests/ -- running from repo root finds nothing.
# Coverage threshold (fail_under=60) not applied -- run 'make test-all' for full coverage.
step "Unit tests (safe CI subset)" \
bash -c "cd '$SCRIPT_DIR/plugins/autorun' && uv run pytest tests/ \
-m 'not tmux and not daemon and not subprocess and not e2e and not interactive and not stress and not race and not slow' \
--tb=short -v \
--junitxml='$SCRIPT_DIR/test_results_local.xml'"
# Summary
echo ""
echo -e "${BOLD}=== Summary ===${NC}"
echo -e "${GREEN}Passed: $PASSED_COUNT${NC}"
if [ "$FAILED_COUNT" -gt 0 ]; then
echo -e "${RED}Failed: $FAILED_COUNT${NC}"
echo -e "${RED}$FAILED_NAMES${NC}"
echo ""
exit 1
else
echo -e "${GREEN}All checks passed!${NC}"
fi