forked from CycodeLabs/raven
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added init tests. * Added init tests. * Changed workflow stracture. * Added pytest. * Added deeper tests.
- Loading branch information
1 parent
23e0767
commit 1d3a1a0
Showing
9 changed files
with
159 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Test PR | ||
|
||
|
||
on: [pull_request] | ||
|
||
|
||
jobs: | ||
test_build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build Containers | ||
run: make setup | ||
|
||
- name: Check Containers | ||
run: | | ||
docker run --rm --network host jwilder/dockerize@sha256:5712c481002a606fffa99a44526fbff2cd1c7f94ca34489f7b0d6bbaeeff4aa4 \ | ||
-wait tcp://localhost:7474 -timeout 10s | ||
# Wait for Redis | ||
docker run --rm --network host jwilder/dockerize@sha256:5712c481002a606fffa99a44526fbff2cd1c7f94ca34489f7b0d6bbaeeff4aa4 \ | ||
-wait tcp://localhost:6379 -timeout 10s | ||
test_raven: | ||
runs-on: ubuntu-latest | ||
needs: test_build | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build Containers | ||
run: make setup | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.11 | ||
|
||
- name: Create virtual environment | ||
run: python -m venv .venv | ||
|
||
- name: Activate virtual environment | ||
run: source .venv/bin/activate | ||
|
||
- name: Install requirements | ||
run: pip install -r requirements.txt | ||
|
||
- name: Test Organization | ||
run: | | ||
python main.py download --token ${{ secrets.GITHUB_TOKEN }} org --org-name RavenDemo | ||
python main.py index | ||
make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
|
||
setup: | ||
@echo "Building Services..." | ||
docker-compose --file deployment/docker-compose.yml up -d | ||
docker-compose --file deployment/docker-compose.yml up -d | ||
|
||
test: | ||
@echo "Running Tests..." | ||
@pytest -v tests/ | ||
@python test_raven.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
requests==2.28.1 | ||
pyyaml==6.0.0 | ||
argparse==1.4.0 | ||
py2neo==2021.2.3 | ||
py2neo==2021.2.3 | ||
pytest==7.4.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import utils | ||
from config import Config | ||
|
||
|
||
def get_nodes(node_type: str) -> (int, list): | ||
nodes = utils.get_all(node_type) | ||
indexed_nodes = 0 | ||
nodes_details = [] | ||
for node in nodes: | ||
if node.get('path').endswith('demo-workflow.yml'): | ||
indexed_nodes += 1 | ||
node = dict(node) | ||
nodes_details.append(node) | ||
|
||
return indexed_nodes, nodes_details | ||
|
||
def test_all_workflows() -> None: | ||
indexed_workflows, nodes_details = get_nodes('Workflow') | ||
|
||
for node in nodes_details: | ||
assert node.get('name') == 'run' | ||
assert node.get('trigger') == ['workflow_dispatch'] | ||
|
||
assert indexed_workflows == 4 | ||
|
||
def test_all_jobs() -> None: | ||
indexed_jobs, nodes_details = get_nodes('Job') | ||
|
||
for node in nodes_details: | ||
assert node.get('name') == 'demo_test' | ||
assert node.get('machine') == 'ubuntu-latest' | ||
|
||
assert indexed_jobs == 4 | ||
|
||
def test_all_composite_actions() -> None: | ||
indexed_composite_actions, _ = get_nodes('CompositeAction') | ||
|
||
assert indexed_composite_actions == 0 | ||
|
||
def test_all_steps() -> None: | ||
indexed_steps, nodes_details = get_nodes('Step') | ||
|
||
for node in nodes_details: | ||
assert node.get('name', 'PrintEnv') == 'PrintEnv' | ||
assert node.get('ref', 'v4') == 'v4' | ||
|
||
assert indexed_steps == 8 | ||
|
||
|
||
def test(): | ||
Config.load_default_index_config() | ||
for test in tests: | ||
test() | ||
|
||
|
||
if __name__ == "__main__": | ||
tests = [ | ||
test_all_workflows, | ||
test_all_jobs, | ||
test_all_composite_actions, | ||
test_all_steps | ||
] | ||
test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters