Skip to content

Commit

Permalink
test: autodiscover roles in local and ci tests (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxhoesel authored Mar 21, 2021
1 parent 9f34fa1 commit 7d7bb39
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 11 deletions.
25 changes: 22 additions & 3 deletions .github/workflows/ci-roles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,34 @@ defaults:
working-directory: "smallstep"

jobs:
discover-roles:
runs-on: ubuntu-latest
outputs:
roles: ${{ steps.set-roles.outputs.roles }}
steps:
- name: Check out codebase
uses: actions/checkout@v2
with:
path: "smallstep"
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: "3.6"
- name: Discover roles
id: set-roles
run: |
export roles=$(python3 -c "import os; import json; print(json.dumps(os.listdir('roles')));")
echo "::set-output name=roles::$roles"
molecule:
name: "${{ matrix.role }} ${{ matrix.ansible-version }}"
needs: discover-roles
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 10
matrix:
role:
- step_ca
- step_cli
role: ${{ fromJson(needs.discover-roles.outputs.roles) }}
ansible-version:
- stable-2.9
- stable-2.10
Expand All @@ -49,6 +67,7 @@ jobs:
- name: Run ansible-lint
run: ansible-lint -vv

- name: Run Molecule tests
run: molecule test
working-directory: "smallstep/roles/${{ matrix.role }}"
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Example: `fix(step_ca): clean up files on EL8`

#### Hints for role development

- If you are adding a new role, make sure to add its molecule tests to both the hacking script and the CI job
None so far

### Update Tests and Documentation

Expand Down
10 changes: 8 additions & 2 deletions hacking/test_modules.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/usr/bin/env bash

set -eu

cleanup() {
./hacking/cleanup.sh
}

trap cleanup err exit

./hacking/build.sh

ansible-galaxy collection install maxhoesel-smallstep-*.tar.gz -p .
Expand All @@ -8,5 +16,3 @@ ansible-galaxy collection install maxhoesel-smallstep-*.tar.gz -p .
&& ansible-test sanity --docker --requirements -v --color --python 3.6 plugins/ \
&& ansible-test integration --docker --requirements -v --coverage --color --python 3.6 \
)

./hacking/cleanup.sh
17 changes: 12 additions & 5 deletions hacking/test_roles.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#!/usr/bin/env bash

(ansible-lint -v \
&& (cd roles/step_cli && molecule test) \
&& (cd roles/step_ca && molecule test) \
)
set -eu

./hacking/cleanup.sh
cleanup() {
./hacking/cleanup.sh
}

trap cleanup err exit

ansible-lint -v

for role in roles/*; do
(cd "$role" && molecule test)
done

0 comments on commit 7d7bb39

Please sign in to comment.