Skip to content

Commit 3cb3e10

Browse files
committed
Add unit test and update README.md
1 parent a4f5f18 commit 3cb3e10

File tree

6 files changed

+135
-1
lines changed

6 files changed

+135
-1
lines changed
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1-
## This is a sample execution environment project to build and publish your EE.
1+
# Execution Environment Project
2+
3+
### This is a sample execution environment project to build and publish your EE.
4+
5+
## Included content/ Directory Structure
6+
7+
The directory structure follows best practices recommended by the Ansible community. Feel free to customize this template according to your specific project requirements.
8+
9+
```
10+
├── .github
11+
│ └── workflows
12+
│ └── ci.yml
13+
├── .gitignore
14+
├── README.md
15+
└── execution-environment.yml
16+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Combine workflow for pull-request, push-to-main and release events.
2+
3+
name: Execution environment build
4+
5+
on:
6+
pull_request_target:
7+
branches:
8+
- main
9+
types: [opened, reopened, synchronize]
10+
push:
11+
branches:
12+
- main
13+
release:
14+
types: [published]
15+
16+
jobs:
17+
ee-build:
18+
uses: ansible/ansible-content-actions/.github/workflows/ee-build.yml@main
19+
with:
20+
registry: ghcr.io
21+
secrets:
22+
registry_username: ${{ github.actor }}
23+
registry_password: ${{ secrets.GITHUB_TOKEN }}
24+
# Only needed if base image of execution-environment.yml file is from Red Hat (ee-minimal)
25+
# registry_redhat_username: ${{ secrets.registry_redhat_username }}
26+
# registry_redhat_password: ${{ secrets.registry_redhat_password }}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
context/
2+
.DS_Store
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Execution Environment Project
2+
3+
### This is a sample execution environment project to build and publish your EE.
4+
5+
## Included content/ Directory Structure
6+
7+
The directory structure follows best practices recommended by the Ansible community. Feel free to customize this template according to your specific project requirements.
8+
9+
```
10+
├── .github
11+
│ └── workflows
12+
│ └── ci.yml
13+
├── .gitignore
14+
├── README.md
15+
└── execution-environment.yml
16+
```
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
version: 3
3+
4+
images:
5+
base_image:
6+
name: quay.io/fedora/fedora:41
7+
8+
dependencies:
9+
# Use python3
10+
python_interpreter:
11+
package_system: python3
12+
python_path: /usr/bin/python3
13+
14+
ansible_core:
15+
package_pip: ansible-core
16+
17+
ansible_runner:
18+
package_pip: ansible-runner
19+
20+
system:
21+
- openssh-clients
22+
- sshpass
23+
24+
python:
25+
- ansible-navigator
26+
- boto3
27+
- requests
28+
29+
galaxy:
30+
collections:
31+
- name: ansible.posix
32+
- name: ansible.utils
33+
34+
additional_build_steps:
35+
append_base:
36+
- RUN $PYCMD -m pip install -U pip
37+
38+
options:
39+
tags:
40+
- ansible_sample_ee

tests/units/test_init.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,41 @@ def mock_unique_name_in_devfile(init: Init) -> str:
169169
assert re.search(r"Warning: re-initializing existing directory", result) is not None, result
170170

171171

172+
def test_run_success_ee_project(
173+
capsys: pytest.CaptureFixture[str],
174+
tmp_path: Path,
175+
cli_args: ConfigDict,
176+
) -> None:
177+
"""Test Init.run().
178+
179+
Successfully create new ee project
180+
181+
Args:
182+
capsys: Pytest fixture to capture stdout and stderr.
183+
tmp_path: Temporary directory path.
184+
cli_args: Dictionary, partial Init class object.
185+
"""
186+
cli_args["project"] = "execution_env"
187+
cli_args["init_path"] = str(tmp_path / "new_project")
188+
init = Init(
189+
Config(**cli_args),
190+
)
191+
192+
init.run()
193+
result = capsys.readouterr().out
194+
195+
# check stdout
196+
assert re.search(r"Note: execution_env project created", result) is not None
197+
198+
# recursively assert files created
199+
cmp = dircmp(
200+
str(tmp_path / "new_project"),
201+
str(FIXTURES_DIR / "project" / "ee_project"),
202+
)
203+
diff = has_differences(dcmp=cmp, errors=[])
204+
assert diff == [], diff
205+
206+
172207
def test_run_success_ansible_project(
173208
capsys: pytest.CaptureFixture[str],
174209
tmp_path: Path,

0 commit comments

Comments
 (0)