Skip to content

Commit

Permalink
Add test check for changelog of the latest stable version
Browse files Browse the repository at this point in the history
  • Loading branch information
ia committed Nov 18, 2024
1 parent 9d1f835 commit 06bc1af
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,5 +221,5 @@ jobs:
with:
submodules: true

- name: Check autogenerated Documentation/README.md
run: /bin/sh ./scripts/deploy.sh docs_readme
- name: Check and verify documentation
run: /bin/sh ./scripts/deploy.sh docs
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ docs: $(MKDOCS_YML) Documentation/* Documentation/Flashing/* Documentation/im
docs-deploy: $(MKDOCS_YML) Documentation/* Documentation/Flashing/* Documentation/images/*
$(MKDOCS) gh-deploy -f $(MKDOCS_YML) -d ../site

# routine check for autogenerated Documentation/README.md
# routine check to verify documentation
test-md:
@echo ""
@echo "---- Checking REAMDE.md... ----"
@echo "---- Checking documentation... ----"
@echo ""
@/bin/sh ./scripts/deploy.sh docs_readme
@/bin/sh ./scripts/deploy.sh docs

# shell style & linter check (github CI version of shellcheck is more recent than alpine one so the latter may not catch some policies)
test-sh:
Expand Down
39 changes: 39 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ usage()
echo -e "\tbuild - compile builds of IronOS inside docker container for supported hardware"
echo -e "\tclean - delete created docker image for IronOS & its build cache objects\n"
echo "CMD (helper routines):"
echo -e "\tdocs - high level target to run docs_readme and docs_history (see below)\n"
echo -e "\tdocs_readme - generate & OVERWRITE(!) README.md inside Documentation/ based on nav section from mkdocs.yml if it changed\n"
echo -e "\tdocs_history - check if History.md has the changelog for the latest stable release\n"
echo -e "\tcheck_style_file SRC - run code style checks based on clang-format & custom parsers for source code file SRC\n"
echo -e "\tcheck_style_log - run clang-format using source/Makefile and generate gcc-compatible error log in source/check-style.log\n"
echo -e "STORAGE NOTICE: for \"shell\" and \"build\" commands extra files will be downloaded so make sure that you have ~5GB of free space.\n"
Expand Down Expand Up @@ -71,6 +73,21 @@ EOF
return "${ret}"
}

# Documentation/History.md automagical changelog routine
docs_readme()
{
md="Documentation/History.md"
ver_md="`sed -ne 's/^## //1p' "${md}" | head -1`"
echo "Latest changelog: ${ver_md}"
ver_git="`git tag -l | sort | grep -e "^v" | grep -v "rc" | tail -1`"
echo "Latest release tag: ${ver_git}"
ret=0
if [ "${ver_md}" != "${ver_git}" ]; then
ret=1
fi;
return "${ret}"
}

# Helper function to check code style using clang-format & grep/sed custom parsers:
# - basic logic moved from source/Makefile : `check-style` target for better maintainance since a lot of sh script involved;
# - output goes in gcc-like error compatible format for IDEs/editors.
Expand Down Expand Up @@ -147,13 +164,35 @@ fi;

cmd="${1}"

# meta target to verify markdown documents

if [ "docs" = "${cmd}" ]; then
docs_readme
readme="${?}"
docs_history
hist="${?}"
if [ "${readme}" -eq 0 && "${hist}" -eq 0 ]; then
ret=0
else
ret=1
fi;
exit ${ret}
fi;

# if only README.md for Documentation update is required then run it & exit

if [ "docs_readme" = "${cmd}" ]; then
docs_readme
exit "${?}"
fi;

# if only History.md for Documentation update is required then run it & exit

if [ "docs_history" = "${cmd}" ]; then
docs_history
exit "${?}"
fi;

if [ "check_style_file" = "${cmd}" ]; then
check_style_file "${2}"
exit "${?}"
Expand Down

0 comments on commit 06bc1af

Please sign in to comment.