From d9bccb964b5e44414ff6d72aba4be68482bbc726 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 22 Nov 2024 23:41:55 +0000 Subject: [PATCH 1/3] Create adoc PR builder [DOC-243] --- .github/actions/test-adoc/action.yml | 56 ++++++++++++++++++++++++++++ .github/workflows/test-adoc.yml | 12 ++++++ 2 files changed, 68 insertions(+) create mode 100644 .github/actions/test-adoc/action.yml create mode 100644 .github/workflows/test-adoc.yml diff --git a/.github/actions/test-adoc/action.yml b/.github/actions/test-adoc/action.yml new file mode 100644 index 000000000..4bc948684 --- /dev/null +++ b/.github/actions/test-adoc/action.yml @@ -0,0 +1,56 @@ +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: | + # 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" \ + ) + + result=$? + + # Fail the action if there was an unexpected error code, or any output from the build + if [[ ${result} != 0 ]]; then + exit ${result} + elif [[ ${output} ]]; then + while IFS= read -r line; do + if [[ "${line}" == *"ERROR"* ]]; then + severity=error + elif [[ "${line}" == *"WARNING"* ]]; then + severity=warning + else + severity=notice + fi + + echo "::${severity}::${line}" + done <<< "${output}" + exit 1 + fi diff --git a/.github/workflows/test-adoc.yml b/.github/workflows/test-adoc.yml new file mode 100644 index 000000000..c6f4e87e1 --- /dev/null +++ b/.github/workflows/test-adoc.yml @@ -0,0 +1,12 @@ +name: Test asciidoctor files + +on: + pull_request: + +jobs: + test-adoc: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/test-adoc From 4e3f0512d76e547046851f9a15e2724f02db756c Mon Sep 17 00:00:00 2001 From: Jack Green Date: Sat, 23 Nov 2024 09:09:40 +0000 Subject: [PATCH 2/3] Update action.yml --- .github/actions/test-adoc/action.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/actions/test-adoc/action.yml b/.github/actions/test-adoc/action.yml index 4bc948684..7a0a4d6a3 100644 --- a/.github/actions/test-adoc/action.yml +++ b/.github/actions/test-adoc/action.yml @@ -18,6 +18,8 @@ runs: - 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 @@ -35,19 +37,15 @@ runs: "include file not found" \ ) - result=$? - - # Fail the action if there was an unexpected error code, or any output from the build - if [[ ${result} != 0 ]]; then - exit ${result} - elif [[ ${output} ]]; then + # Fail the action if there was any output from the build + if [[ ${output} ]]; then while IFS= read -r line; do - if [[ "${line}" == *"ERROR"* ]]; then - severity=error + if [[ "${line}" == *"INFO"* ]]; then + severity=info elif [[ "${line}" == *"WARNING"* ]]; then severity=warning else - severity=notice + severity=error fi echo "::${severity}::${line}" From a0ec81f9349b0ea65f222bbf1b8fc77a2e0479af Mon Sep 17 00:00:00 2001 From: Jack Green Date: Mon, 25 Nov 2024 14:45:44 +0000 Subject: [PATCH 3/3] Merge into `validate` --- .github/workflows/test-adoc.yml | 12 ------------ .github/workflows/validate.yml | 8 +++++++- 2 files changed, 7 insertions(+), 13 deletions(-) delete mode 100644 .github/workflows/test-adoc.yml diff --git a/.github/workflows/test-adoc.yml b/.github/workflows/test-adoc.yml deleted file mode 100644 index c6f4e87e1..000000000 --- a/.github/workflows/test-adoc.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Test asciidoctor files - -on: - pull_request: - -jobs: - test-adoc: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/test-adoc 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