From 459704d1839bbcd1207c3426819767f4f56d52eb Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Tue, 25 Jan 2022 08:58:06 -0500 Subject: [PATCH] Add small check to make sure readme.md files are in projects Signed-off-by: Robin Getz --- .../scripts/check_for_missing_readme_md.sh | 53 +++++++++++++++++++ .github/workflows/test_n_lint.yml | 13 +++++ 2 files changed, 66 insertions(+) create mode 100755 .github/scripts/check_for_missing_readme_md.sh create mode 100644 .github/workflows/test_n_lint.yml diff --git a/.github/scripts/check_for_missing_readme_md.sh b/.github/scripts/check_for_missing_readme_md.sh new file mode 100755 index 000000000..4d91af828 --- /dev/null +++ b/.github/scripts/check_for_missing_readme_md.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# +# Ensure there are Readme.md files in all the project directories +# +set -e +#set -x + +fail=0 + +check_string(){ + needle=$1 + if [ "$(grep "${needle}" $file | wc -l)" -eq "0" ] ; then + echo missing \"${needle}\" in $file + fail=1 + else + if [ "$(grep "${needle}" $file | sed -e "s/${needle}//g" -e "s/ //g" | wc -c)" -lt "8" ] ; then + echo missing link for \"${needle}\" in $file + fail=1 + fi + fi +} + +MISSING=$(find projects/ -mindepth 1 -maxdepth 1 \( -path projects/common -o -path projects/scripts \) -prune -o -type d '!' -exec test -e "{}/Readme.md" ';' -print) +if [ "$(echo ${MISSING} | wc -c)" -gt "1" ] ; then + echo Missing Readme.md files in the ${MISSING} + fail=1 +fi + +for file in $(find projects/ -mindepth 2 -maxdepth 2 -name Readme.md) +#for file in projects/ad5766_sdz/Readme.md +do + check_string "Board Product Page" + check_string "* Parts" + check_string "* Project Doc" + check_string "* HDL Doc" + check_string "* Linux Drivers" + if [ "$(grep "([[:space:]]*)" $file | wc -l)" -gt "0" ] ; then + echo "missing link [found ()] in $file" + fail=1 + fi + if [ "$(grep https://wiki.analog.com/resources/tools-software/linux-drivers-all $file | wc -l)" -gt "0" ] ; then + echo "Do not link to https://wiki.analog.com/resources/tools-software/linux-drivers-all in $file" + fail=1 + fi + if [ "$(grep https://wiki.analog.com/linux $file | wc -l)" -gt "0" ] ; then + echo "Do not link to https://wiki.analog.com/linux in $file" + fail=1 + fi +done + +if [ "${fail}" -eq "1" ] ; then + exit 1 +fi diff --git a/.github/workflows/test_n_lint.yml b/.github/workflows/test_n_lint.yml new file mode 100644 index 000000000..b9819829b --- /dev/null +++ b/.github/workflows/test_n_lint.yml @@ -0,0 +1,13 @@ +name: Lint + +on: [push, pull_request] + +jobs: + Lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Check Readmes + run: | + bash ./.github/scripts/check_for_missing_readme_md.sh