-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (56 loc) · 2.13 KB
/
ansible-doc-validation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Ansible Doc Validation
on:
pull_request:
push:
branches:
- master
env:
COLLECTION_NAMESPACE: cisco
COLLECTION_NAME: catalystwan
permissions: read-all
jobs:
documentation-check:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Python
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: '3.10'
- name: Get collection namespace and name from galaxy.yml
id: collection-name
run: |
NAMESPACE=$(grep '^namespace:' galaxy.yml | awk '{print $2}' | tr -d "'\"")
NAME=$(grep '^name:' galaxy.yml | awk '{print $2}' | tr -d "'\"")
if [[ -z "$NAMESPACE" || -z "$NAME" ]]; then
echo "Error: Unable to find or parse namespace, and name in galaxy.yml"
exit 1
fi
echo "Collection namespace is $NAMESPACE"
echo "Collection name is $NAME"
echo "COLLECTION_NAMESPACE=$NAMESPACE" >> $GITHUB_ENV
echo "COLLECTION_NAME=$NAME" >> $GITHUB_ENV
- name: Install Ansible
run: pip install ansible==9.4.0
- name: Build and install the collection
run: |
ansible-galaxy collection build $GITHUB_WORKSPACE --force
ansible-galaxy collection install $GITHUB_WORKSPACE/*.tar.gz
- name: List modules in the collection
shell: bash
run: |
MODULES_PATH="$GITHUB_WORKSPACE/plugins/modules/"
MODULES=$(find "$MODULES_PATH" -name '*.py' -exec basename {} .py \; | xargs)
echo "Modules found: $MODULES"
echo "MODULES=$MODULES" >> $GITHUB_ENV
- name: Check documentation for each module
shell: bash
run: |
for MODULE in $MODULES; do
echo "Checking module: $MODULE documentation"
if ! ansible-doc --type=module --json "$COLLECTION_NAMESPACE.COLLECTION_NAME.$MODULE" > /dev/null; then
echo "Error in documentation for module $MODULE"
exit 1
fi
done