diff --git a/.github/workflows/generate-docs.yml b/.github/workflows/generate-docs.yml new file mode 100644 index 0000000000..5b7bfe2127 --- /dev/null +++ b/.github/workflows/generate-docs.yml @@ -0,0 +1,81 @@ +name: Generate Documentation + +on: push +# on: +# schedule: +# - cron: '0 0 * * *' + +jobs: + generate: + if: github.repository == 'zeek/zeek' + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v2 + + - name: Update Submodules + shell: bash + run: | + auth_header="$(git config --local --get http.https://github.com/.extraheader)" + git submodule sync --recursive + git -c "http.extraheader=$auth_header" -c protocol.version=2 \ + submodule update --init --force --recursive --depth=1 + ( cd doc && git checkout master ) + + - name: Fetch Dependencies + run: | + sudo apt-get update + sudo apt-get -y install \ + git \ + cmake \ + make \ + gcc \ + g++ \ + flex \ + bison \ + libpcap-dev \ + libssl-dev \ + python3 \ + python3-dev \ + python3-pip\ + swig \ + zlib1g-dev \ + libkrb5-dev \ + bsdmainutils \ + sqlite3 + # Many distros adhere to PEP 394's recommendation for `python` = + # `python2` so this is a simple workaround until we drop Python 2 + # support and explicitly use `python3` for all invocations. + sudo ln -sf /usr/bin/python3 /usr/local/bin/python + + - name: Build + run: | + ( cd build && make -j 3 ) + + - name: Generate Docs + shell: bash + run: | + git config --global user.name zeek-bot + git config --global user.email info@zeek.org + + echo "*** Generating Zeekygen Docs ***" + ./ci/update-zeekygen-docs.sh || exit 1 + cd doc + echo "*** Generating Sphinx Docs ***" + make > make.out 2>&1 + make_status=$? + cat make.out + test ${make_status} -ne 0 && exit 1 + grep -q WARNING make.out && exit 1 + rm make.out + echo "*** Pushing zeek-docs Changes ***" + git remote set-url origin "https://zeek-bot:${{ secrets.ZEEK_BOT_TOKEN }}@github.com/zeek/zeek-docs" + git add scripts/ + git commit -m "Generate docs" + git push + cd .. + + echo "*** Update zeek/doc Submodule ***" + git add doc + git commit -m 'Update doc submodule [nomail] [skip ci]' + git push diff --git a/testing/scripts/update-zeekygen-docs.sh b/ci/update-zeekygen-docs.sh similarity index 97% rename from testing/scripts/update-zeekygen-docs.sh rename to ci/update-zeekygen-docs.sh index 99462b39dc..807e6c698a 100755 --- a/testing/scripts/update-zeekygen-docs.sh +++ b/ci/update-zeekygen-docs.sh @@ -9,7 +9,7 @@ unset ZEEK_DEFAULT_LISTEN_RETRY; unset ZEEK_DEFAULT_CONNECT_RETRY; dir="$( cd "$( dirname "$0" )" && pwd )" -source_dir="$( cd $dir/../.. && pwd )" +source_dir="$( cd $dir/.. && pwd )" build_dir=$source_dir/build conf_file=$build_dir/zeekygen-test.conf output_dir=$source_dir/doc diff --git a/testing/btest/coverage/sphinx-zeekygen-docs.sh b/testing/btest/coverage/sphinx-zeekygen-docs.sh deleted file mode 100644 index 20e18c2364..0000000000 --- a/testing/btest/coverage/sphinx-zeekygen-docs.sh +++ /dev/null @@ -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