|
| 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