Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/_shared-docs-build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ on:
`https://server/path`.
required: false
type: string
squash-hierarchy:
description: |
If 'true', the collection documentation will be created at top-level and not in a subdirectory `namespace/collection_name/`.
Has no effect if init-dest-dir is supplied.
required: false
default: 'false'

outputs:
artifact-name:
Expand Down Expand Up @@ -242,6 +248,7 @@ jobs:
fail-on-error: false
provide-link-targets: ${{ inputs.provide-link-targets }}
intersphinx-links: ${{ inputs.intersphinx-links }}
squash-hierarchy: ${{ input.squash-hierarchy }}

- name: Build BASE
id: build-base
Expand Down Expand Up @@ -276,6 +283,7 @@ jobs:
fail-on-error: ${{ inputs.init-fail-on-error }}
provide-link-targets: ${{ inputs.provide-link-targets }}
intersphinx-links: ${{ inputs.intersphinx-links }}
squash-hierarchy: ${{ input.squash-hierarchy }}

- name: Build HEAD
id: build-head
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/_shared-docs-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ on:
`https://server/path`.
required: false
type: string
squash-hierarchy:
description: |
If 'true', the collection documentation will be created at top-level and not in a subdirectory `namespace/collection_name/`.
Has no effect if init-dest-dir is supplied.
required: false
default: 'false'

outputs:
artifact-name:
Expand Down Expand Up @@ -160,6 +166,7 @@ jobs:
fail-on-error: ${{ inputs.init-fail-on-error }}
provide-link-targets: ${{ inputs.provide-link-targets }}
intersphinx-links: ${{ inputs.intersphinx-links }}
squash-hierarchy: ${{ input.squash-hierarchy }}

- name: Build
id: build
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/test-action-build-init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:

jobs:
tests:
name: Init [ver=${{ matrix.antsibull-docs-version }}, skip=${{ matrix.skip-init }}, lenient=${{ matrix.lenient }}, fail-on-error=${{ matrix.fail-on-error }}, dest=${{ matrix.dest }}, collections=${{ matrix.collections }}, link-targets=${{ matrix.provide-link-targets != '' }}], intersphinx-links=${{ matrix.intersphinx-links }}
name: Init [ver=${{ matrix.antsibull-docs-version }}, skip=${{ matrix.skip-init }}, lenient=${{ matrix.lenient }}, fail-on-error=${{ matrix.fail-on-error }}, dest=${{ matrix.dest }}, collections=${{ matrix.collections }}, link-targets=${{ matrix.provide-link-targets != '' }}], intersphinx-links=${{ matrix.intersphinx-links }}, squash-hierarchy=${{ matrix.squash-hierarchy }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -44,19 +44,29 @@ jobs:
outside_reference_1
outside_reference_2
intersphinx-links: ['']
squash-hierarchy:
- false
include:
- skip-init: true
dest: .test/simple-build
lenient: false # unused but needs a value
fail-on-error: false # unused but needs a value
provide-link-targets: ''
squash-hierarchy: false
- skip-init: false
dest: ''
lenient: false
fail-on-error: true
intersphinx-links: |
amazon_aws:https://ansible-collections.github.io/amazon.aws/branch/main/
ansible_devel:https://docs.ansible.com/ansible-core/devel/
squash-hierarchy: false
- skip-init: false
collections: foo.bar
dest: ''
lenient: false
fail-on-error: true
squash-hierarchy: true

steps:
- name: Checkout
Expand All @@ -76,7 +86,7 @@ jobs:
id: init
uses: ./actions/ansible-docs-build-init
with:
collections: ${{ matrix.collection }}
collections: ${{ matrix.collections }}
# combining runner.temp and /docsbuild copies the default from the action
# please keep in sync!
dest-dir: ${{ matrix.dest || format('{0}/{1}', runner.temp, '/docsbuild') }}
Expand All @@ -85,12 +95,15 @@ jobs:
lenient: ${{ matrix.lenient }}
provide-link-targets: ${{ matrix.provide-link-targets }}
intersphinx-links: ${{ matrix.intersphinx-links }}
squash-hierarchy: ${{ matrix.squash-hierarchy }}

- name: assert
env:
output_build_script: ${{ steps.init.outputs.build-script }}
output_build_html: ${{ steps.init.outputs.build-html }}
run: |
set -x

# check that the build script exists
[ -f "$output_build_script" ] || exit 1

Expand Down Expand Up @@ -137,6 +150,9 @@ jobs:
${{ matrix.skip-init }} || ${{ matrix.intersphinx-links == '' }} || grep -q -- 'amazon_aws' conf.py || exit 1
${{ matrix.skip-init }} || ${{ matrix.intersphinx-links == '' }} || grep -q -- 'https://ansible-collections.github.io/amazon.aws/branch/main/' conf.py || exit 1

# Check that the squash hierarchy flag was added
${{ matrix.squash-hierarchy }} && (grep -q -- ' --squash-hierarchy ' build.sh || exit 1)

# check if provide-link-targets was not used when being empty
# short circuit if skip-init is 'true' or matrix.provide-link-targets is not empty
${{ matrix.skip-init }} || ${{ matrix.provide-link-targets != '' }} || ! test -e rst/_targets.rst || exit 1
8 changes: 7 additions & 1 deletion actions/ansible-docs-build-init/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ inputs:
`https://server/path`.
required: false
type: string
squash-hierarchy:
description: |
If 'true', the collection documentation will be created at top-level and not in a subdirectory `namespace/collection_name/`.
This is only possible if 'collections' contains exactly one collection.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the flag is used with more than one collection?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spinx-init will complain :) You can see it here: https://github.com/ansible-community/github-docs-build/actions/runs/3536149650/jobs/5934924344 - there was a bug in the tests that collections wasn't actually passed on, and thus squash-hierarchy was used with zero collections in that case.

required: false
default: 'false'
outputs:
build-script:
description: The path of the build script to execute.
Expand Down Expand Up @@ -94,7 +100,7 @@ runs:
fi

echo "::group::Initialize Sphinx"
antsibull-docs sphinx-init --use-current ${{ fromJSON(inputs.fail-on-error) && '--fail-on-error' || '' }} ${{ fromJSON(inputs.lenient) && '--lenient' || '' }} --dest-dir "${{ inputs.dest-dir }}" ${{ inputs.collections }} ${INTERSPHINX_ARGS[@]}
antsibull-docs sphinx-init --use-current ${{ fromJSON(inputs.fail-on-error) && '--fail-on-error' || '' }} ${{ fromJSON(inputs.lenient) && '--lenient' || '' }} ${{ fromJSON(inputs.squash-hierarchy) && '--squash-hierarchy' || '' }} --dest-dir "${{ inputs.dest-dir }}" ${{ inputs.collections }} ${INTERSPHINX_ARGS[@]}
echo "::endgroup::"
fi

Expand Down