Skip to content

Commit 1d18b40

Browse files
committed
Add workflow for linting docs for PR submissions
Signed-off-by: Webster Mudge <wmudge@cloudera.com>
1 parent 2f363ea commit 1d18b40

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

.github/workflows/lint_docs.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
3+
name: Lint documentation
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
antsibull-log-upload:
9+
description: |
10+
If 'true', the antsibull-doc log will be uploaded as an artifact.
11+
required: false
12+
type: boolean
13+
default: false
14+
15+
jobs:
16+
lint-ansible-docs:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
steps:
21+
- name: Configure environment
22+
id: vars
23+
uses: actions/github-script@v6
24+
with:
25+
script: |
26+
name = process.env.GITHUB_REPOSITORY.split('/')[1]
27+
path = name.replace('.', '/')
28+
29+
core.exportVariable('ANSIBLE_COLLECTIONS_PATHS', process.env.GITHUB_WORKSPACE)
30+
31+
const checkoutPath = `ansible_collections/${path}`
32+
core.setOutput('checkout-path', checkoutPath)
33+
34+
- name: Set up Python
35+
uses: actions/setup-python@v4
36+
with:
37+
python-version: 3.11
38+
39+
- name: Install Ansible
40+
run: pip install ansible-core
41+
42+
- name: Display Ansible details
43+
run: ansible --version
44+
45+
- name: Checkout project
46+
uses: actions/checkout@v3
47+
with:
48+
path: ${{ steps.vars.outputs.checkout-path }}
49+
50+
- name: Install Python requirements
51+
run: pip install -r ${{ steps.vars.outputs.checkout-path }}/docsbuild/requirements.txt
52+
53+
- name: Execute antsibull-docs with --fail-on-error
54+
run: |
55+
mkdir -p ${{ steps.vars.outputs.checkout-path }}/docsbuild/temp-rst
56+
chmod og-w ${{ steps.vars.outputs.checkout-path }}/docsbuild/temp-rst
57+
antsibull-docs \
58+
--config-file ${{ steps.vars.outputs.checkout-path }}/docsbuild/antsibull-docs.cfg \
59+
collection \
60+
--use-current \
61+
--squash-hierarchy \
62+
--dest-dir temp-rst \
63+
--fail-on-error \
64+
cloudera.cloud
65+
continue-on-error: true
66+
67+
- name: Upload antsibull-doc log artifact
68+
if: fromJSON(inputs.antsibull-log-upload)
69+
uses: actions/upload-artifact@v3
70+
with:
71+
path: ${{ steps.vars.outputs.checkout-path }}/docsbuild/antsibull.log
72+
name: antsibull-${{ github.sha }}.log
73+
retention-days: 7
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
3+
name: Validate Pull Request documentation
4+
5+
on:
6+
pull_request:
7+
branches:
8+
- 'release/**'
9+
- 'devel'
10+
11+
workflow_dispatch:
12+
13+
jobs:
14+
validate-docs:
15+
name: Validate Ansible Docs
16+
uses: ./.github/workflows/lint_docs.yml
17+
with:
18+
antsibull-log-upload: true
19+

0 commit comments

Comments
 (0)