Skip to content

Commit 26c622b

Browse files
committed
feat: add update metric docs step to rust lint
1 parent a0d14d8 commit 26c622b

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

ci/scripts/check_metric_docs.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under this License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
20+
SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
21+
22+
echo "$SCRIPT_PATH: Checking if metrics.md is up-to-date"
23+
24+
# Ensure we're in the project root
25+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
26+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
27+
cd "$PROJECT_ROOT"
28+
29+
METRICS_FILE="docs/source/user-guide/metrics.md"
30+
METRICS_BACKUP=$(mktemp)
31+
32+
if [ ! -f "$METRICS_FILE" ]; then
33+
echo "Warning: $METRICS_FILE not found, skipping check." >&2
34+
rm -f "$METRICS_BACKUP"
35+
exit 0
36+
fi
37+
38+
# Backup the current file
39+
cp "$METRICS_FILE" "$METRICS_BACKUP"
40+
41+
# Run the update script (this will modify the file)
42+
# Suppress output but capture exit code
43+
if ! ./dev/update_metric_docs.sh > /dev/null 2>&1; then
44+
echo "Error: Failed to run update_metric_docs.sh. Check permissions and try again." >&2
45+
# Restore the original file
46+
mv "$METRICS_BACKUP" "$METRICS_FILE"
47+
exit 1
48+
fi
49+
50+
# Compare the updated file with the backup
51+
if ! diff -q "$METRICS_BACKUP" "$METRICS_FILE" > /dev/null; then
52+
echo "Error: metrics.md is not up-to-date. Run './dev/update_metric_docs.sh' and commit the changes." >&2
53+
# Restore the original file
54+
mv "$METRICS_BACKUP" "$METRICS_FILE"
55+
exit 1
56+
fi
57+
58+
# Clean up the backup file
59+
rm -f "$METRICS_BACKUP"
60+
exit 0
61+

dev/rust_lint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ ci/scripts/rust_docs.sh
5050
ci/scripts/license_header.sh
5151
ci/scripts/typos_check.sh
5252
ci/scripts/doc_prettier_check.sh
53+
ci/scripts/check_metric_docs.sh

0 commit comments

Comments
 (0)