mirror of
https://github.com/zeek/zeek.git
synced 2025-10-15 13:08:20 +00:00
GH-1149: Add GitHub Action to automate generation of zeek-docs
This commit is contained in:
parent
f6e48c3a18
commit
a7b905d389
3 changed files with 82 additions and 54 deletions
|
@ -1,53 +0,0 @@
|
|||
# This script checks whether the reST docs generated by zeekygen are stale.
|
||||
# If this test fails when testing the master branch, then simply run:
|
||||
#
|
||||
# testing/scripts/update-zeekygen-docs.sh
|
||||
#
|
||||
# and then commit the changes.
|
||||
#
|
||||
# @TEST-EXEC: bash $SCRIPTS/update-zeekygen-docs.sh ./doc
|
||||
# @TEST-EXEC: bash %INPUT
|
||||
|
||||
# This test isn't run on Travis or Cirrus CI for pull-requests. Instead,
|
||||
# the person merging to master will manually update zeek-docs.
|
||||
|
||||
if [ -n "$CIRRUS_PR" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n "$TRAVIS_PULL_REQUEST" ]; then
|
||||
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
function check_diff
|
||||
{
|
||||
local file=$1
|
||||
echo "Checking $file for differences"
|
||||
diff -Nru $DIST/$file $file 1>&2
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "============================" 1>&2
|
||||
echo "" 1>&2
|
||||
echo "$DIST/$file is outdated" 1>&2
|
||||
echo "" 1>&2
|
||||
echo "You can ignore this failure if testing changes that you will" 1>&2
|
||||
echo "submit in a pull-request." 1>&2
|
||||
echo "" 1>&2
|
||||
echo "If this fails in the master branch or when merging to master," 1>&2
|
||||
echo "re-run the following command:" 1>&2
|
||||
echo "" 1>&2
|
||||
echo " $SCRIPTS/update-zeekygen-docs.sh" 1>&2
|
||||
echo "" 1>&2
|
||||
echo "Then commit/push the changes in the zeek-docs repo" 1>&2
|
||||
echo "(the doc/ directory in the zeek repo)." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
for file in $(find ./doc -name autogenerated-*); do
|
||||
check_diff $file
|
||||
done
|
||||
|
||||
check_diff ./doc/scripts
|
|
@ -1,69 +0,0 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
unset ZEEK_DISABLE_ZEEKYGEN;
|
||||
|
||||
# If running this from btest, unset any of the environment
|
||||
# variables that alter default script values.
|
||||
unset ZEEK_DEFAULT_LISTEN_ADDRESS;
|
||||
unset ZEEK_DEFAULT_LISTEN_RETRY;
|
||||
unset ZEEK_DEFAULT_CONNECT_RETRY;
|
||||
|
||||
dir="$( cd "$( dirname "$0" )" && pwd )"
|
||||
source_dir="$( cd $dir/../.. && pwd )"
|
||||
build_dir=$source_dir/build
|
||||
conf_file=$build_dir/zeekygen-test.conf
|
||||
output_dir=$source_dir/doc
|
||||
zeek_error_file=$build_dir/zeekygen-test-stderr.txt
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
output_dir=$1
|
||||
fi
|
||||
|
||||
case $output_dir in
|
||||
/*) ;;
|
||||
*) output_dir=`pwd`/$output_dir ;;
|
||||
esac
|
||||
|
||||
cd $build_dir
|
||||
. zeek-path-dev.sh
|
||||
export ZEEK_SEED_FILE=$source_dir/testing/btest/random.seed
|
||||
|
||||
function run_zeek
|
||||
{
|
||||
ZEEK_ALLOW_INIT_ERRORS=1 zeek -X $conf_file zeekygen >/dev/null 2>$zeek_error_file
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed running zeek with zeekygen config file $conf_file"
|
||||
echo "See stderr in $zeek_error_file"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
scripts_output_dir=$output_dir/scripts
|
||||
rm -rf $scripts_output_dir
|
||||
printf "script\t*\t$scripts_output_dir/" > $conf_file
|
||||
echo "Generating $scripts_output_dir/"
|
||||
run_zeek
|
||||
|
||||
script_ref_dir=$output_dir/script-reference
|
||||
mkdir -p $script_ref_dir
|
||||
|
||||
function generate_index
|
||||
{
|
||||
echo "Generating $script_ref_dir/$2"
|
||||
printf "$1\t*\t$script_ref_dir/$2\n" > $conf_file
|
||||
run_zeek
|
||||
}
|
||||
|
||||
generate_index "script_index" "autogenerated-script-index.rst"
|
||||
generate_index "package_index" "autogenerated-package-index.rst"
|
||||
generate_index "file_analyzer" "autogenerated-file-analyzer-index.rst"
|
||||
generate_index "proto_analyzer" "autogenerated-protocol-analyzer-index.rst"
|
||||
|
||||
echo
|
||||
|
||||
if [ -n "$(cd $source_dir/doc && git status --porcelain)" ]; then
|
||||
echo "*** There are changes in zeek-docs that need a review, commit, and push ***"
|
||||
else
|
||||
echo "No changes or further action needed"
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue