Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't run tests if the environment is not correct #801

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,21 @@ We generally include test for coding guidelines:

Remember: Code is generally read much more often than written.

### Local testing of roles in this collection

We are using Molecule to test our roles.
If you want to execute the tests on your machine you need Docker and Molecule.
You will also need to set the `MOLECULE_DISTRO` environment variable to execute the tests.
To find valid values for the variable you can take a look at our GitHub Action workflows in `.github/workflows/`.

Example for executing tests locally:

```bash
pip install -r requirements.txt
export MOLECULE_DISTRO="debian12"
molecule test -s os_hardening
```

### Use Markdown

Wherever possible, please refrain from any other formats and stick to simple markdown.
2 changes: 2 additions & 0 deletions molecule/mysql_hardening/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ scenario:
- prepare
check_sequence:
- dependency
- verify ../shared/prerequisites.yml
- destroy
- create
- prepare
Expand All @@ -48,6 +49,7 @@ scenario:
- destroy
test_sequence:
- dependency
- verify ../shared/prerequisites.yml
- destroy
- syntax
- create
Expand Down
2 changes: 2 additions & 0 deletions molecule/nginx_hardening/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ scenario:
- prepare
check_sequence:
- dependency
- verify ../shared/prerequisites.yml
- destroy
- create
- prepare
Expand All @@ -47,6 +48,7 @@ scenario:
- destroy
test_sequence:
- dependency
- verify ../shared/prerequisites.yml
- destroy
- syntax
- create
Expand Down
2 changes: 2 additions & 0 deletions molecule/os_hardening/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ scenario:
- prepare
check_sequence:
- dependency
- verify ../shared/prerequisites.yml
- destroy
- create
- prepare
Expand All @@ -43,6 +44,7 @@ scenario:
- destroy
test_sequence:
- dependency
- verify ../shared/prerequisites.yml
- destroy
- syntax
- create
Expand Down
2 changes: 2 additions & 0 deletions molecule/os_hardening_vm/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ scenario:
- prepare
check_sequence:
- dependency
- verify ../shared/prerequisites.yml
- destroy
- create
- prepare
Expand All @@ -52,6 +53,7 @@ scenario:
- destroy
test_sequence:
- dependency
- verify ../shared/prerequisites.yml
- destroy
- syntax
- create
Expand Down
9 changes: 9 additions & 0 deletions molecule/shared/prerequisites.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Verify prerequisites
hosts: localhost
tasks:
- name: Make sure environment variable for MOLECULE_DISTRO is set
ansible.builtin.assert:
that:
- "lookup('env','MOLECULE_DISTRO')"
fail_msg: "You need to set MOLECULE_DISTRO to a supported image name. See CONTRIBUTING.md"
2 changes: 2 additions & 0 deletions molecule/ssh_hardening/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ scenario:
- prepare
check_sequence:
- dependency
- verify ../shared/prerequisites.yml
- destroy
- create
- prepare
Expand All @@ -49,6 +50,7 @@ scenario:
- destroy
test_sequence:
- dependency
- verify ../shared/prerequisites.yml
- destroy
- syntax
- create
Expand Down
2 changes: 2 additions & 0 deletions molecule/ssh_hardening_bsd/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ scenario:
- prepare
check_sequence:
- dependency
- verify ../shared/prerequisites.yml
- destroy
- create
- prepare
Expand All @@ -48,6 +49,7 @@ scenario:
- destroy
test_sequence:
- dependency
- verify ../shared/prerequisites.yml
- destroy
- syntax
- create
Expand Down
2 changes: 2 additions & 0 deletions molecule/ssh_hardening_custom_tests/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ scenario:
- prepare
check_sequence:
- dependency
- verify ../shared/prerequisites.yml
- destroy
- create
- prepare
Expand All @@ -43,6 +44,7 @@ scenario:
- destroy
test_sequence:
- dependency
- verify ../shared/prerequisites.yml
- destroy
- syntax
- create
Expand Down
Loading