-
Notifications
You must be signed in to change notification settings - Fork 17
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
Pipeline generator steps #32
Changes from 10 commits
717b163
e3aac9c
49043e5
72f1fd2
3cdd2b3
ab323d9
231cd2f
df69376
6bea5dc
5a086b9
3c45849
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from pydantic import BaseModel, Field | ||
from typing import List, Dict, Any, Optional | ||
|
||
from .utils import AgentQueue | ||
|
||
|
||
class BuildkiteBlockStep(BaseModel): | ||
"""This class represents a block step in Buildkite format.""" | ||
block: str | ||
depends_on: Optional[str] = "build" | ||
key: str | ||
|
||
|
||
def get_step_key(step_label: str) -> str: | ||
step_label = step_label.replace(", ", ",") | ||
step_key = "" | ||
skip_chars = "()%" | ||
for char in step_label.lower(): | ||
if char in ", ": | ||
step_key += "-" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe this should be like "if the last char was There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
elif char not in skip_chars: | ||
step_key += char | ||
|
||
return step_key | ||
|
||
|
||
def get_block_step(step_label: str) -> BuildkiteBlockStep: | ||
return BuildkiteBlockStep(block=f"Run {step_label}", key=f"block-{get_step_key(step_label)}") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pytest | ||
import sys | ||
|
||
|
||
from scripts.pipeline_generator.step import get_step_key, get_block_step, BuildkiteBlockStep | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("step_label", "expected_result"), | ||
[ | ||
("Test Step", "test-step"), | ||
("Test Step 2", "test-step-2"), | ||
("Test (Step)", "test-step"), | ||
("Test A, B, C", "test-a-b-c"), | ||
], | ||
) | ||
def test_get_step_key(step_label: str, expected_result: str): | ||
assert get_step_key(step_label) == expected_result | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("step_label", "expected_result"), | ||
[ | ||
("Test Step", BuildkiteBlockStep(block="Run Test Step", key="block-test-step")), | ||
("Test Step 2", BuildkiteBlockStep(block="Run Test Step 2", key="block-test-step-2")), | ||
("Test (Step)", BuildkiteBlockStep(block="Run Test (Step)", key="block-test-step")), | ||
("Test A, B, C", BuildkiteBlockStep(block="Run Test A, B, C", key="block-test-a-b-c")), | ||
], | ||
) | ||
def test_get_block_step(step_label: str, expected_result: BuildkiteBlockStep): | ||
assert get_block_step(step_label) == expected_result | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(pytest.main(["-v", __file__])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe declare a global constant for
"build"
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done