diff --git a/.github/actions/test-adoc/action.yml b/.github/actions/test-adoc/action.yml new file mode 100644 index 000000000..7a0a4d6a3 --- /dev/null +++ b/.github/actions/test-adoc/action.yml @@ -0,0 +1,54 @@ +name: Test asciidoctor files + +env: + # Not possible to set this as a default + # https://github.com/orgs/community/discussions/46670 + shell: bash + +runs: + using: composite + + steps: + - name: Install asciidoctor + shell: ${{ env.shell }} + run: | + sudo apt-get update + sudo apt-get install -y asciidoctor + + - name: Check for errors + shell: ${{ env.shell }} + run: | + set -o errexit ${RUNNER_DEBUG:+-x} + + # Builds the adoc file using asciidoctor, discarding the output + # This logs any warnings etc + + # asciidoc doesn't handle "include::partial" (this is supported by Antora on top), so we ignore any of those errors + # We can't use Antora directly because if built in isolation, none of the links between documentation repos resolve + # To address this would require comingling PR and upstream repos + + output=$( \ + asciidoctor \ + --out-file /dev/null \ + "**/*.adoc" \ + 2>&1 | \ + grep \ + -v \ + "include file not found" \ + ) + + # Fail the action if there was any output from the build + if [[ ${output} ]]; then + while IFS= read -r line; do + if [[ "${line}" == *"INFO"* ]]; then + severity=info + elif [[ "${line}" == *"WARNING"* ]]; then + severity=warning + else + severity=error + fi + + echo "::${severity}::${line}" + done <<< "${output}" + exit 1 + fi diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index a936a1c7a..12a15d626 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -9,7 +9,6 @@ on: jobs: check-links: - runs-on: ubuntu-latest steps: @@ -17,3 +16,10 @@ jobs: uses: actions/checkout@v4 - name: Check dead links uses: hazelcast/hazelcast-docs/.github/actions/validate@main + + test-adoc: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/test-adoc \ No newline at end of file