Skip to content

Commit c2e9397

Browse files
authored
build-init - lenient, fail-on-error, antsibull-version (#27)
* add antsibull-version option for build-init * use the option! * no really, use the option tho * add lenient mode * do not split param name and value * fix matrix, try better names * short circuit lenient test when skip-init * add fail-on-error * test fixes * show antsibull version * add new option pass-throughs to shared workflows
1 parent 5ad50fa commit c2e9397

File tree

4 files changed

+95
-4
lines changed

4 files changed

+95
-4
lines changed

.github/workflows/_shared-docs-build-pr.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ on:
2626
description: A directory relative to the checkout where the init process has already been run.
2727
required: false
2828
type: string
29+
init-lenient:
30+
description: Use the lenient option during build init. Has no effect if init-dest-dir is supplied.
31+
required: false
32+
type: boolean
33+
default: false
34+
init-fail-on-error:
35+
description: Use the fail-on-error option during build init. Has no effect if init-dest-dir is supplied.
36+
required: false
37+
type: boolean
38+
default: false
39+
init-antsibull-version:
40+
description: |
41+
The version of antsibull to use during build init. Has no effect if init-dest-dir is supplied.
42+
If not supplied, the latest version from PyPI is used. If supplied, must be a git ref from the antsibull repository.
43+
required: false
44+
type: string
2945
artifact-name:
3046
description: The name of the artifact to upload.
3147
required: false
@@ -193,6 +209,9 @@ jobs:
193209
collections: ${{ inputs.collection-name }}
194210
dest-dir: ${{ steps.vars.outputs.init-dir-base }}
195211
skip-init: ${{ steps.vars.outputs.skip-init }}
212+
antsibull-version: '${{ inputs.init-antsibull-version }}'
213+
lenient: ${{ inputs.init-lenient }}
214+
fail-on-error: ${{ inputs.init-fail-on-error }}
196215

197216
- name: Build BASE
198217
id: build-base
@@ -222,6 +241,9 @@ jobs:
222241
collections: ${{ inputs.collection-name }}
223242
dest-dir: ${{ steps.vars.outputs.init-dir-head }}
224243
skip-init: ${{ steps.vars.outputs.skip-init }}
244+
antsibull-version: '${{ inputs.init-antsibull-version }}'
245+
lenient: ${{ inputs.init-lenient }}
246+
fail-on-error: ${{ inputs.init-fail-on-error }}
225247

226248
- name: Build HEAD
227249
id: build-head

.github/workflows/_shared-docs-build-push.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ on:
2626
description: A directory relative to the checkout where the init process has already been run.
2727
required: false
2828
type: string
29+
init-lenient:
30+
description: Use the lenient option during build init. Has no effect if init-dest-dir is supplied.
31+
required: false
32+
type: boolean
33+
default: false
34+
init-fail-on-error:
35+
description: Use the fail-on-error option during build init. Has no effect if init-dest-dir is supplied.
36+
required: false
37+
type: boolean
38+
default: false
39+
init-antsibull-version:
40+
description: |
41+
The version of antsibull to use during build init. Has no effect if init-dest-dir is supplied.
42+
If not supplied, the latest version from PyPI is used. If supplied, must be a git ref from the antsibull repository.
43+
required: false
44+
type: string
2945
artifact-name:
3046
description: The name of the artifact to upload.
3147
required: false
@@ -105,6 +121,9 @@ jobs:
105121
collections: ${{ steps.vars.outputs.col-name }}
106122
dest-dir: ${{ steps.vars.outputs.init-dir }}
107123
skip-init: ${{ steps.vars.outputs.skip-init }}
124+
antsibull-version: '${{ inputs.init-antsibull-version }}'
125+
lenient: ${{ inputs.init-lenient }}
126+
fail-on-error: ${{ inputs.init-fail-on-error }}
108127

109128
- name: Build
110129
id: build

.github/workflows/test-action-build-init.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414

1515
jobs:
1616
tests:
17-
name: Init tests
17+
name: Init [ver=${{ matrix.antsibull-version }}, skip=${{ matrix.skip-init }}, lenient=${{ matrix.lenient }}, fail-on-error=${{ matrix.fail-on-error }}, dest=${{ matrix.dest }}, collections=${{ matrix.collections }}]
1818
runs-on: ubuntu-latest
1919
strategy:
2020
fail-fast: false
@@ -25,9 +25,20 @@ jobs:
2525
- 'fake.collection'
2626
- 'first.collection second.collection'
2727
dest: ['']
28+
antsibull-version:
29+
- '' # there is no default so this will be ok
30+
- main
31+
lenient:
32+
- true
33+
- false
34+
fail-on-error:
35+
- true
36+
- false
2837
include:
2938
- skip-init: true
3039
dest: .test/simple-build
40+
lenient: false # unused but needs a value
41+
fail-on-error: false # unused but needs a value
3142

3243
steps:
3344
- name: Checkout
@@ -52,6 +63,8 @@ jobs:
5263
# please keep in sync!
5364
dest-dir: ${{ matrix.dest || format('{0}/{1}', runner.temp, '/docsbuild') }}
5465
skip-init: ${{ matrix.skip-init }}
66+
antsibull-version: ${{ matrix.antsibull-version }}
67+
lenient: ${{ matrix.lenient }}
5568

5669
- name: assert
5770
env:
@@ -76,3 +89,15 @@ jobs:
7689
pip freeze > "${{ runner.temp }}/post-freeze.txt"
7790
7891
cmp "${{ runner.temp }}/pre-freeze.txt" "${{ runner.temp }}/post-freeze.txt" || exit 1
92+
93+
# check if lenient mode was used
94+
# if lenient == 'true', the grep should fail and end up running the true command
95+
# if lenient == 'false', the grep should succeed and never run the false command
96+
# short circuit if skip-init is 'true'
97+
${{ matrix.skip-init }} || grep -- '^nitpicky = True$' conf.py || ${{ matrix.lenient }} || exit 1
98+
99+
# check if fail-on-error mode was used
100+
# if fail-on-error == 'true', the grep should fail (!succeed) and end up running the true command
101+
# if fail-on-error == 'false', the grep should succeed (!fail) and never run the false command
102+
# short circuit if skip-init is 'true'
103+
${{ matrix.skip-init }} || ! grep -- '--fail-on-error' conf.py || ${{ matrix.fail-on-error }} || exit 1

actions/ansible-docs-build-init/action.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ inputs:
1818
antsibull and the contents of the requirements.txt file in dest-dir.
1919
required: false
2020
default: 'false'
21+
fail-on-error:
22+
description: |
23+
Corresponds to the --fail-on-error flag in antsibull. Fails if plugins cannot be parsed.
24+
Has no effect if skip-init is true.
25+
required: false
26+
default: 'false'
27+
lenient:
28+
description: |
29+
Corresponds to the --lenient flag for antsibull sphinx-init.
30+
By default, the build process will fail on warnings unless this is set to 'true'.
31+
Has no effect if skip-init is true.
32+
required: false
33+
default: 'false'
34+
antsibull-version:
35+
description: |
36+
The version of antsibull to install. When set, it refers to a git ref from which to install.
37+
If not set, the latest version from PyPI is installed.
38+
required: false
2139
outputs:
2240
build-script:
2341
description: The path of the build script to execute.
@@ -31,10 +49,17 @@ runs:
3149
steps:
3250
- name: Install Antsibull and Initialize Sphinx
3351
id: init
52+
env:
53+
PIP_DISABLE_PIP_VERSION_CHECK: '1'
3454
shell: bash
3555
run: |
3656
echo "::group::Installing Antsibull"
37-
pip install antsibull --disable-pip-version-check
57+
if [[ "${{ inputs.antsibull-version }}" != "" ]] ; then
58+
pip install https://github.com/ansible-community/antsibull/archive/${{ inputs.antsibull-version }}.tar.gz
59+
else
60+
pip install antsibull
61+
fi
62+
antsibull-docs --version
3863
echo "::endgroup::"
3964
4065
if [[ "${{ inputs.skip-init }}" != "true" ]] ; then
@@ -43,12 +68,12 @@ runs:
4368
echo "::endgroup::"
4469
4570
echo "::group::Initialize Sphinx"
46-
antsibull-docs sphinx-init --use-current --dest-dir "${{ inputs.dest-dir }}" ${{ inputs.collections }}
71+
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 }}
4772
echo "::endgroup::"
4873
fi
4974
5075
echo "::group::Install additional requirements"
51-
pip install -r "${{ inputs.dest-dir }}/requirements.txt" --disable-pip-version-check
76+
pip install -r "${{ inputs.dest-dir }}/requirements.txt"
5277
echo "::endgroup::"
5378
5479
echo "::set-output name=build-script::${{ inputs.dest-dir }}/build.sh"

0 commit comments

Comments
 (0)