-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathlefthook.yaml
More file actions
192 lines (169 loc) · 6.76 KB
/
lefthook.yaml
File metadata and controls
192 lines (169 loc) · 6.76 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
pre-commit:
commands:
1_upgrade_drizzle_metadata:
run: |
set -e
pnpm run upgrade_drizzle_metadata
git add ./drizzle_migrations
2_generate_drizzle_migrations:
run: |
set -e
pnpm run generate_drizzle_migrations
git add ./drizzle_migrations
3_check_drizzle_migrations:
run: pnpm run check_drizzle_migrations
4_generate_graphql_sdl_file:
run: |
set -e
pnpm generate_graphql_sdl_file
git add ./schema.graphql
5_generate_gql_tada_files:
run: |
set -e
pnpm generate_gql_tada
git add ./test/graphql/types/gql.tada-cache.d.ts
6_check_gql_tada:
run: pnpm check_gql_tada
7_fix_code_quality:
run: |
set -e
pnpm format:fix
git add -- {staged_files}
git add docs/
7.5_check_tsdoc:
glob: "src/**/*.ts"
run: pnpm lint:tsdoc {staged_files}
8_validate_error_handling:
run: pnpm run validate:error-handling
9_check_type_errors:
run: pnpm typecheck
10_check_mock_isolation:
glob: "test/**/*.{test,spec}.{ts,tsx}"
run: pnpm run check_mock_isolation {staged_files}
9.5_check_install_test_traps:
glob: "tests/install/**/*.test.sh"
run: bash tests/install/check-traps.sh
11_check_disable_statements:
glob: "**/*.{ts,tsx}"
run: |
set -e
# Configuration
SCRIPT_URL="https://raw.githubusercontent.com/PalisadoesFoundation/.github/main/.github/workflows/scripts/disable_statements_check.py"
SCRIPT_DIR=".github-central-scripts"
SCRIPT_PATH="$SCRIPT_DIR/disable_statements_check.py"
CACHE_MAX_AGE_HOURS=24
# Create directory for cached scripts
mkdir -p "$SCRIPT_DIR"
# Check if cached script exists and is fresh (< 24 hours old)
NEEDS_DOWNLOAD=true
if [ -f "$SCRIPT_PATH" ]; then
# Get file modification time in seconds since epoch
if [ "$(uname)" = "Darwin" ]; then
# macOS
FILE_MOD_TIME=$(stat -f %m "$SCRIPT_PATH")
else
# Linux
FILE_MOD_TIME=$(stat -c %Y "$SCRIPT_PATH")
fi
CURRENT_TIME=$(date +%s)
AGE_SECONDS=$((CURRENT_TIME - FILE_MOD_TIME))
AGE_HOURS=$((AGE_SECONDS / 3600))
if [ $AGE_HOURS -lt $CACHE_MAX_AGE_HOURS ]; then
echo "✅ Using cached script (${AGE_HOURS}h old, cache valid for ${CACHE_MAX_AGE_HOURS}h)"
NEEDS_DOWNLOAD=false
else
echo "⏰ Cache is ${AGE_HOURS}h old (max: ${CACHE_MAX_AGE_HOURS}h), attempting fresh download..."
fi
else
echo "📥 No cached script found, downloading..."
fi
# Download if needed (cache missing or stale)
if [ "$NEEDS_DOWNLOAD" = true ]; then
DOWNLOAD_SUCCESS=false
# Try curl first
if command -v curl &> /dev/null; then
if curl -sSfL "$SCRIPT_URL" -o "$SCRIPT_PATH" 2>/dev/null; then
DOWNLOAD_SUCCESS=true
echo "✅ Script downloaded successfully"
fi
fi
# Try wget as fallback
if [ "$DOWNLOAD_SUCCESS" = false ] && command -v wget &> /dev/null; then
if wget -q -O "$SCRIPT_PATH" "$SCRIPT_URL" 2>/dev/null; then
DOWNLOAD_SUCCESS=true
echo "✅ Script downloaded successfully"
fi
fi
# Handle download failure with offline fallback
if [ "$DOWNLOAD_SUCCESS" = false ]; then
if [ -f "$SCRIPT_PATH" ]; then
# Stale cache exists, use it as fallback
echo "⚠️ Download failed (offline?), using stale cached version"
echo " (Script will work, but may be outdated)"
elif ! command -v curl &> /dev/null && ! command -v wget &> /dev/null; then
# No download tool available
echo "❌ Error: Neither curl nor wget is installed."
echo ""
echo "Please install curl or wget:"
echo " - macOS: curl is pre-installed"
echo " - Ubuntu/Debian: sudo apt install curl"
echo " - Fedora/RHEL: sudo dnf install curl"
echo " - Windows: curl is included in Windows 10+"
exit 1
else
# First-time setup while offline
echo "❌ Error: Cannot download script (offline?) and no cached version exists."
echo ""
echo "This is a first-time setup requiring internet access."
echo "Please connect to the internet and try again."
echo ""
echo "After first download, the script will work offline using the cache."
exit 1
fi
fi
fi
echo "🔍 Running disable statements check..."
# Run the script with the virtual environment Python
if [ -f .venv/bin/python3 ]; then
.venv/bin/python3 "$SCRIPT_PATH" --files {staged_files}
elif [ -f .venv/Scripts/python.exe ]; then
.venv/Scripts/python.exe "$SCRIPT_PATH" --files {staged_files}
else
echo "❌ Error: Python virtual environment not found."
echo ""
echo "Please set up your Python environment:"
echo " python3 -m venv .venv"
echo " source .venv/bin/activate # On Windows: .venv\\Scripts\\activate"
echo " pip install -r .github/workflows/requirements.txt"
exit 1
fi
11.6_check_python_docstrings:
glob: ".github/**/*.py"
run: |
set -e
if [ -f .venv/bin/python3 ]; then
.venv/bin/python3 .github/workflows/scripts/check_docstrings.py --directories .github
elif [ -f .venv/Scripts/python.exe ]; then
.venv/Scripts/python.exe .github/workflows/scripts/check_docstrings.py --directories .github
else
echo "Error: Python virtual environment not found."
echo "Please ensure Python 3.9+ is installed. If 'python3 -m venv' fails, you may need to install:"
echo " - Ubuntu/Debian: sudo apt install python3-venv"
echo " - Fedora/RHEL: sudo dnf install python3-venv"
echo " - macOS/Windows: venv is included with Python"
echo ""
echo "Then run: python3 -m venv .venv && source .venv/bin/activate && pip install -r .github/workflows/requirements.txt"
exit 1
fi
12_generate_docs:
run: |
set -e
pnpm generate-docs
git add ./docs/docs/auto-docs/
13_api_schema_docs:
run: |
set -e
cd docs
pnpm docusaurus graphql-to-doc
git add docs/auto-schema
piped: true