From 564aa19cf9af5afbf6ca8fb5f13f1e040ddec2ef Mon Sep 17 00:00:00 2001 From: Txema Ynzenga Date: Mon, 25 Dec 2023 22:09:22 +0100 Subject: [PATCH] Add check that includes are relative to Github Actions --- .github/workflows/code-checks.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/code-checks.yaml diff --git a/.github/workflows/code-checks.yaml b/.github/workflows/code-checks.yaml new file mode 100644 index 00000000..7b7b28a8 --- /dev/null +++ b/.github/workflows/code-checks.yaml @@ -0,0 +1,27 @@ +name: code-checks + +on: [ push, pull_request ] + +jobs: + check-includes-are-relative: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - shell : bash + run: | + cd include + errors=0 + for file in $(find . -name '*.hpp'); do + while read -r line; do + if [[ "$line" = "" ]]; then continue; fi + what=$(printf "$line" | sed -n 's/^.*"\(.*\)"\s*$/\1/p') + pushd $(dirname $(readlink -f "$file" )) > /dev/null + if ! [[ -e "$what" ]]; then + where=$(printf "$line" | grep -oP '^.*:[0-9]+') + echo Non-relative include of $what @ $where + ((errors++)) + fi + popd > /dev/null + done <<< $(grep -HnoP '#include ".*"' $file) + done + exit $errors