Skip to content

Commit

Permalink
fix: Add test for argument_specs matching
Browse files Browse the repository at this point in the history
Compare contents of `meta/arguments_spec.yml` against `defaults/main.yml` on
each role to make sure keys match.

Signed-off-by: SuperQ <[email protected]>
  • Loading branch information
SuperQ committed Jul 29, 2023
1 parent 603aa0c commit e2425db
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/scripts/lint_arguments_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
#
# Description: Lint the defaults/main.yml against the meta/arguments_spec.yml

lint_diff() {
diff -u \
<(yq 'keys | .[]' "${role}/defaults/main.yml" | sort -u) \
<(yq '.argument_specs.main.options | keys | .[] ' "${role}/meta/argument_specs.yml" | sort -u)
return $?
}

error=0

for role in roles/* ; do
echo "Checking ${role}"
if ! lint_diff ; then
echo "ERROR: ${role}: meta/argument_specs.yml doesn't match defaults/main.yml"
error=1
fi
done

exit "${error}"
9 changes: 9 additions & 0 deletions .github/workflows/ansible-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ jobs:
- name: Lint collection
uses: ansible/ansible-lint-action@main

arguments-spec-lint:
runs-on: ubuntu-latest
container:
image: quay.io/prometheus/golang-builder:base
steps:
- uses: actions/checkout@v3
- name: Lint arguments spec
run: ./.github/scripts/lint_arguments_spec.sh

discover-ansible-versions:
runs-on: ubuntu-latest
outputs:
Expand Down

0 comments on commit e2425db

Please sign in to comment.