-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
74 lines (62 loc) · 2.17 KB
/
entrypoint.sh
File metadata and controls
74 lines (62 loc) · 2.17 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
#!/bin/bash
set -e
# Get arguments
MEASUREMENTS_DIR="${1:-measurements}"
EXPECTATIONS_DIR="${2:-expectations}"
OUTPUT_PATH="${3:-output}"
CAFFEINE_VERSION="${4:-5.6.0}"
echo "Caffeine Language Compiler"
echo "=========================="
# Install the requested (pinned) Caffeine release. Default lives in action.yml.
TAG="v${CAFFEINE_VERSION#v}"
VERSION="${TAG#v}"
DOWNLOAD_URL="https://github.com/Brickell-Research/caffeine/releases/download/${TAG}/caffeine-${VERSION}-linux-x64.tar.gz"
echo "Installing Caffeine ${TAG} from ${DOWNLOAD_URL}"
cd /tmp
curl -fLo caffeine.tar.gz "$DOWNLOAD_URL"
tar -xzf caffeine.tar.gz
mv caffeine-*-linux-x64 /usr/local/bin/caffeine
chmod +x /usr/local/bin/caffeine
rm caffeine.tar.gz
cd - >/dev/null
# The repository files are mounted at /github/workspace
WORKSPACE="/github/workspace"
# Convert relative paths to absolute paths within the workspace
MEASUREMENTS_PATH="$WORKSPACE/$MEASUREMENTS_DIR"
EXPECTATIONS_PATH="$WORKSPACE/$EXPECTATIONS_DIR"
OUTPUT_FULL_PATH="$WORKSPACE/$OUTPUT_PATH"
echo "Measurements directory: $MEASUREMENTS_PATH"
echo "Expectations directory: $EXPECTATIONS_PATH"
echo "Output path: $OUTPUT_FULL_PATH"
# Check if measurements directory exists
if [ ! -d "$MEASUREMENTS_PATH" ]; then
echo "Error: Measurements directory not found: $MEASUREMENTS_PATH"
exit 1
fi
# Check if expectations directory exists
if [ ! -d "$EXPECTATIONS_PATH" ]; then
echo "Error: Expectations directory not found: $EXPECTATIONS_PATH"
exit 1
fi
echo "Found measurements and expectations directories"
echo ""
# Show Caffeine version
echo "Caffeine version:"
caffeine --version || echo "caffeine binary not found"
echo ""
# Create output directory if it doesn't exist and output_path looks like a directory
if [[ "$OUTPUT_PATH" != *.tf ]] && [[ "$OUTPUT_PATH" != *.json ]]; then
mkdir -p "$OUTPUT_FULL_PATH"
fi
# Run Caffeine compiler
echo "Running Caffeine compiler..."
if caffeine compile "$MEASUREMENTS_PATH" "$EXPECTATIONS_PATH" "$OUTPUT_FULL_PATH"; then
echo ""
echo "Caffeine compilation SUCCESSFUL!"
exit 0
else
echo ""
echo "Caffeine compilation FAILED!"
echo "Check your measurement and expectation files for errors."
exit 1
fi