-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_github_actions_locally.sh
More file actions
executable file
·40 lines (34 loc) · 1.55 KB
/
test_github_actions_locally.sh
File metadata and controls
executable file
·40 lines (34 loc) · 1.55 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
#!/bin/bash
# Test GitHub Actions locally to catch errors before pushing
echo "=== Testing Docker Build Workflow ==="
echo "1. Building Docker image..."
docker build -t efdata:test . || { echo "❌ Docker build failed"; exit 1; }
echo -e "\n2. Testing Docker Compose config..."
cp .env.example .env.test
docker-compose --env-file .env.test config > /dev/null || { echo "❌ Docker compose config failed"; exit 1; }
rm .env.test
echo -e "\n3. Checking for secrets in code..."
if grep -r -E "(password|api_key|secret)\s*=\s*['\"][^'\"]{3,}['\"]" --include="*.py" --exclude-dir=".venv" --exclude-dir=".git" . | grep -v -E "(getenv|environ|example|\.env|input\(|st\.text_input|settings\.get)"; then
echo "❌ WARNING: Possible hardcoded secrets found!"
exit 1
fi
echo "✅ No hardcoded secrets detected"
echo -e "\n=== Testing Data Validation Workflow ==="
echo "4. Testing Python syntax..."
find src/econdata/econdata/spiders -name "*.py" -type f -exec python -m py_compile {} \; || { echo "❌ Python syntax check failed"; exit 1; }
echo -e "\n5. Testing RBA endpoint..."
cat << 'EOF' > test_rba.py
import requests
try:
response = requests.get('https://api.rba.gov.au/statistics/tables', timeout=10)
if response.status_code != 200:
print(f'❌ ERROR: RBA API returned {response.status_code}')
exit(1)
print('✅ RBA API accessible')
except Exception as e:
print(f'❌ ERROR: {e}')
exit(1)
EOF
python test_rba.py || { echo "❌ RBA endpoint test failed"; exit 1; }
rm test_rba.py
echo -e "\n✅ All tests passed! Safe to push to GitHub"