-
Notifications
You must be signed in to change notification settings - Fork 277
Expand file tree
/
Copy pathtest-setup-local.sh
More file actions
executable file
·88 lines (73 loc) · 2.32 KB
/
test-setup-local.sh
File metadata and controls
executable file
·88 lines (73 loc) · 2.32 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
#!/usr/bin/env bash
# Local test script for setup.sh
# This script tests the setup action locally to ensure it works correctly
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo "=== Testing setup.sh locally ==="
echo ""
# Step 1: Check if we're in the right directory
if [ ! -f "actions/setup/setup.sh" ]; then
echo -e "${RED}Error: Must run from repository root${NC}"
exit 1
fi
echo -e "${GREEN}✓${NC} Found actions/setup/setup.sh"
# Step 2: Build the actions if js/ directory doesn't exist
if [ ! -d "actions/setup/js" ]; then
echo ""
echo -e "${YELLOW}js/ directory not found. Running 'make actions-build'...${NC}"
if ! make actions-build; then
echo -e "${RED}Error: Failed to build actions${NC}"
exit 1
fi
echo -e "${GREEN}✓${NC} Built actions successfully"
else
echo -e "${GREEN}✓${NC} js/ directory already exists"
fi
# Step 3: Verify js/ directory has files
FILE_COUNT=$(ls -1 actions/setup/js/*.cjs 2>/dev/null | wc -l)
if [ "$FILE_COUNT" -eq 0 ]; then
echo -e "${RED}Error: No .cjs files found in actions/setup/js/${NC}"
exit 1
fi
echo -e "${GREEN}✓${NC} Found $FILE_COUNT .cjs files in actions/setup/js/"
# Step 4: Create a temporary destination directory
TEST_DEST=$(mktemp -d)
echo ""
echo "Test destination: $TEST_DEST"
# Step 5: Run setup.sh
echo ""
echo "Running setup.sh..."
export INPUT_DESTINATION="$TEST_DEST"
export GITHUB_OUTPUT="$TEST_DEST/output.txt"
if bash actions/setup/setup.sh; then
echo -e "${GREEN}✓${NC} setup.sh executed successfully"
else
echo -e "${RED}Error: setup.sh failed${NC}"
rm -rf "$TEST_DEST"
exit 1
fi
# Step 6: Verify files were copied
COPIED_COUNT=$(ls -1 "$TEST_DEST"/*.cjs 2>/dev/null | wc -l)
if [ "$COPIED_COUNT" -eq 0 ]; then
echo -e "${RED}Error: No files were copied to destination${NC}"
rm -rf "$TEST_DEST"
exit 1
fi
echo -e "${GREEN}✓${NC} Copied $COPIED_COUNT files to destination"
# Step 7: Check output file
if [ -f "$GITHUB_OUTPUT" ]; then
OUTPUT_VALUE=$(grep "files_copied=" "$GITHUB_OUTPUT" | cut -d'=' -f2)
echo -e "${GREEN}✓${NC} Output: files_copied=$OUTPUT_VALUE"
fi
# Step 8: List some of the copied files
echo ""
echo "Sample of copied files:"
ls -1 "$TEST_DEST"/*.cjs | head -5
# Step 9: Cleanup
rm -rf "$TEST_DEST"
echo ""
echo -e "${GREEN}=== All tests passed! ===${NC}"