-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathpublish-results.sh
More file actions
executable file
·122 lines (108 loc) · 3.98 KB
/
publish-results.sh
File metadata and controls
executable file
·122 lines (108 loc) · 3.98 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
#!/bin/bash
#
# Copyright © 2016-2025 The LmdbJava Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -euo pipefail
# Publishes benchmark results to Cloudflare Pages
# Auto-detects type and mode from target/benchmark/index.html
RESULTS_DIR="target/benchmark"
INDEX_HTML="${RESULTS_DIR}/index.html"
# Check prerequisites
if [ ! -f "${INDEX_HTML}" ]; then
echo "ERROR: ${INDEX_HTML} not found"
echo "Please run ./run-libs.sh, ./run-vers.sh, or ./run-lmdb.sh first, followed by the corresponding report script"
exit 1
fi
# Check for required environment variables
if [ -z "${CLOUDFLARE_API_TOKEN:-}" ] || [ -z "${CLOUDFLARE_ACCOUNT_ID:-}" ]; then
echo "ERROR: Required environment variables not set"
echo ""
echo "Please set the following environment variables:"
echo " export CLOUDFLARE_API_TOKEN=\"your-token\""
echo " export CLOUDFLARE_ACCOUNT_ID=\"your-account-id\""
echo ""
echo "These should be set in your ~/.bashrc or ~/.zshrc for convenience"
exit 1
fi
# Check for wrangler
if ! command -v wrangler &> /dev/null; then
echo "ERROR: wrangler not found"
echo "Please install: npm install -g wrangler"
exit 1
fi
echo "Analyzing benchmark results..."
# Detect benchmark type from HTML title
if grep -q "<title>LmdbJava Library Comparison Benchmarks</title>" "${INDEX_HTML}"; then
BENCH_TYPE="libraries"
echo " Detected: Library comparison benchmarks"
elif grep -q "<title>LmdbJava Performance Regression Testing</title>" "${INDEX_HTML}"; then
BENCH_TYPE="versions"
echo " Detected: Version regression benchmarks"
elif grep -q "<title>LMDB Library Performance Analysis</title>" "${INDEX_HTML}"; then
BENCH_TYPE="lmdb"
echo " Detected: LMDB library benchmarks"
else
echo "ERROR: Could not determine benchmark type from ${INDEX_HTML}"
echo "Expected title: 'LmdbJava Library Comparison Benchmarks', 'LmdbJava Performance Regression Testing', or 'LMDB Library Performance Analysis'"
exit 1
fi
# Detect benchmark mode from smoketest warning
if grep -q "⚠️ SMOKETEST RESULTS" "${INDEX_HTML}"; then
BENCH_MODE="smoketest"
echo " Detected: Smoketest mode (fast verification)"
else
BENCH_MODE="benchmark"
echo " Detected: Benchmark mode (full 120s iterations)"
fi
# Determine Cloudflare Pages project and DNS name
PROJECT="lmdbjava-${BENCH_TYPE}-${BENCH_MODE}"
DNS_NAME="${BENCH_TYPE}-${BENCH_MODE}.lmdbjava.org"
echo ""
echo "Publishing to Cloudflare Pages..."
echo " Project: ${PROJECT}"
echo " DNS: https://${DNS_NAME}"
echo ""
# Check if project exists, create if needed
if ! wrangler pages project list 2>/dev/null | grep -q "│ ${PROJECT} "; then
echo "Creating new Cloudflare Pages project: ${PROJECT}"
if ! wrangler pages project create "${PROJECT}" --production-branch=main; then
echo ""
echo "ERROR: Failed to create project"
exit 1
fi
echo ""
fi
# Deploy using wrangler (environment variables are automatically used)
if ! wrangler pages deploy "${RESULTS_DIR}" \
--project-name="${PROJECT}" \
--branch=main \
--commit-dirty=true; then
echo ""
echo "ERROR: Deployment failed"
exit 1
fi
echo ""
echo "✓ Deployment successful!"
echo ""
echo "Your results are now available at:"
echo " https://${DNS_NAME}"
echo ""
echo "Note: If this is the first deployment, you'll need to set up the custom domain:"
echo " 1. Go to Cloudflare Dashboard → Workers & Pages"
echo " 2. Click on project: ${PROJECT}"
echo " 3. Go to Custom domains → Set up a custom domain"
echo " 4. Enter: ${DNS_NAME}"
echo " 5. Click Activate domain"
echo ""