Files
documentdb/scripts/validate_headers.sh
T
Vinod Sridharan b685862864 Merged PR 1552485: [OSS] Move most of helio_api out of OSS
### Does this PR have any customer impact?
No
### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc)
Refactor
### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes)
No
### Are you introducing any new config? If yes, do you have tests with and without them being set?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description
Move most of helio_api out of OSS into internal.
Keep internal/pg_helio_distributed/src/test/regress for now until we port distributed tests over.

----
#### AI description  (iteration 1)
#### PR Classification
Code reorganization to move most of `helio_api` out of the OSS directory.

#### PR Summary
This pull request reorganizes the project structure by moving the `helio_api` components out of the OSS directory to a new `helio_api` directory.
- Deleted files `diff-filter`, `diff`, `normalize.sed`, and `expect_normalize.sed` from `oss/internal/pg_helio_distributed/src/test/regress/bin`.
- Updated paths in `.pipelines/templates/oss_build.yml` and `.pipelines/templates/oss_documentdb_build.yml` to reflect the new `helio_api` directory structure.
- Modified `Makefile` and `oss/Makefile` to update paths and add new targets for `helio_api`.
- Moved `pg_helio_api`, `pg_helio_core`, and `pg_helio_distributed` directories from `oss` to `helio_api`.
- Added new `helio_api/Makefile` and `helio_api/Makefile.inc` to manage the build process for the moved components.
2025-01-17 15:14:59 +08:00

89 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
# fail if trying to reference a variable that is not set.
set -e
source="${BASH_SOURCE[0]}"
while [[ -h $source ]]; do
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
source="$(readlink "$source")"
# if $source was a relative symlink, we need to resolve it relative to the path where the
# symlink file was located
[[ $source != /* ]] && source="$scriptroot/$source"
done
repoScriptDir="$( cd -P "$( dirname "$source" )" && pwd )"
declare -A headerMap;
# Ensure unique headers between OSS extensions
echo "Checking pg_documentdb_core"
for f in `find $repoScriptDir/../pg_documentdb_core/include/ -name *.h`; do
subPath=${f#$repoScriptDir/../pg_documentdb_core/include/}
if [ "${headerMap[$subPath]}" != "" ]; then
echo "Duplicate header path found at $subPath. Header files must be unique across the extensions";
exit 1;
fi
headerMap[$subPath]=1;
done;
echo "Checking pg_documentdb"
for f in `find $repoScriptDir/../pg_documentdb/include/ -name *.h`; do
subPath=${f#$repoScriptDir/../pg_documentdb/include/}
if [ "${headerMap[$subPath]}" != "" ]; then
echo "Duplicate header path found at $subPath. Header files must be unique across the extensions";
exit 1;
fi
headerMap[$subPath]=1;
done;
echo "Checking pg_documentdb_distributed"
for f in `find $repoScriptDir/../internal/pg_documentdb_distributed/include/ -name *.h`; do
subPath=${f#$repoScriptDir/../internal/pg_documentdb_distributed/include/}
if [ "${headerMap[$subPath]}" != "" ]; then
echo "Duplicate header path found at $subPath. Header files must be unique across the extensions";
exit 1;
fi
headerMap[$subPath]=1;
done;
# Now check they don't duplicate with postgres's headers.
pg_include_dir=$(pg_config --includedir)
pg_include_dir_server=$(pg_config --includedir-server)
for f in ${!example_array[@]}
do
if [ -f "$pg_include_dir/$f"]; then
echo "Duplicate header path found at $f. Header files must not collide with postgres headers";
exit 1;
fi
if [ -f "$pg_include_dir_server/$f"]; then
echo "Duplicate header path found at $f. Header files must not collide with postgres server headers";
exit 1;
fi
done
hasInvalidHeaders="0"
for f in $(grep -R "include <server" --include \*.h --include \*.c oss)
do
echo "Invalid header file found $f do not reference header files via 'server'"
hasInvalidHeaders="1"
done
for f in $(grep -R "include \"server" --include \*.h --include \*.c oss)
do
echo "Invalid header file found $f do not reference header files via 'server'"
hasInvalidHeaders="1"
done
if [ "$hasInvalidHeaders" == "1" ]; then
exit 1;
fi
echo "Total headers checked ${#headerMap[@]}"