Skip to content

Commit ae35177

Browse files
cj-zhukovSergey Zhukov
andauthored
Add CI check to ensure examples are documented in README (#19371)
#19294) ## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - part of ##19294. ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> --------- Co-authored-by: Sergey Zhukov <[email protected]>
1 parent 8532731 commit ae35177

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

.github/workflows/rust.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,23 @@ jobs:
709709
./dev/update_function_docs.sh
710710
git diff --exit-code
711711
712+
examples-docs-check:
713+
name: check example README is up-to-date
714+
needs: linux-build-lib
715+
runs-on: ubuntu-latest
716+
container:
717+
image: amd64/rust
718+
719+
steps:
720+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
721+
with:
722+
submodules: true
723+
fetch-depth: 1
724+
725+
- name: Run examples docs check script
726+
run: |
727+
bash ci/scripts/check_examples_docs.sh
728+
712729
# Verify MSRV for the crates which are directly used by other projects:
713730
# - datafusion
714731
# - datafusion-substrait

ci/scripts/check_examples_docs.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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 the 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+
set -euo pipefail
21+
22+
EXAMPLES_DIR="datafusion-examples/examples"
23+
README="datafusion-examples/README.md"
24+
25+
# ffi examples are skipped because they were not part of the recent example
26+
# consolidation work and do not follow the new grouping and execution pattern.
27+
# They are not documented in the README using the new structure, so including
28+
# them here would cause false CI failures.
29+
SKIP_LIST=("ffi")
30+
31+
missing=0
32+
33+
skip() {
34+
local value="$1"
35+
for item in "${SKIP_LIST[@]}"; do
36+
if [[ "$item" == "$value" ]]; then
37+
return 0
38+
fi
39+
done
40+
return 1
41+
}
42+
43+
# collect folder names
44+
folders=$(find "$EXAMPLES_DIR" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
45+
46+
# collect group names from README headers
47+
groups=$(grep "^### Group:" "$README" | sed -E 's/^### Group: `([^`]+)`.*/\1/')
48+
49+
for folder in $folders; do
50+
if skip "$folder"; then
51+
echo "Skipped group: $folder"
52+
continue
53+
fi
54+
55+
if ! echo "$groups" | grep -qx "$folder"; then
56+
echo "Missing README entry for example group: $folder"
57+
missing=1
58+
fi
59+
done
60+
61+
if [[ $missing -eq 1 ]]; then
62+
echo "README is out of sync with examples"
63+
exit 1
64+
fi

0 commit comments

Comments
 (0)