Skip to content

Commit a0060e6

Browse files
committed
feat: Implement FEATURE_BUNDLE_1 RFC 0004
Signed-off-by: Mark <399551+mwiebe@users.noreply.github.com>
1 parent 057e686 commit a0060e6

10 files changed

+150
-3
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ classifiers = [
2929
"Intended Audience :: End Users/Desktop"
3030
]
3131
dependencies = [
32-
"openjd-sessions >= 0.10.3,< 0.11",
33-
"openjd-model >= 0.8,< 0.9"
32+
"openjd-sessions >= 0.10.7,< 0.11",
33+
"openjd-model >= 0.9,< 0.10"
3434
]
3535

3636
[project.urls]

src/openjd/cli/_common/_extensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Optional
55

66
# This is the list of Open Job Description extensions with implemented support
7-
SUPPORTED_EXTENSIONS = ["TASK_CHUNKING", "REDACTED_ENV_VARS"]
7+
SUPPORTED_EXTENSIONS = ["TASK_CHUNKING", "REDACTED_ENV_VARS", "FEATURE_BUNDLE_1"]
88

99

1010
def add_extensions_argument(run_parser: ArgumentParser):
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
specificationVersion: jobtemplate-2023-09
2+
name: FB1 Bash Syntax Sugar
3+
extensions:
4+
- FEATURE_BUNDLE_1
5+
steps:
6+
- name: BashStep
7+
bash:
8+
script: |
9+
echo "Hello from Bash!"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
specificationVersion: jobtemplate-2023-09
2+
name: FB1 Cmd Syntax Sugar
3+
extensions:
4+
- FEATURE_BUNDLE_1
5+
steps:
6+
- name: CmdStep
7+
cmd:
8+
script: |
9+
echo Hello from Cmd!
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
specificationVersion: jobtemplate-2023-09
2+
name: FB1 EndOfLine LF
3+
extensions:
4+
- FEATURE_BUNDLE_1
5+
steps:
6+
- name: EOLStep
7+
script:
8+
embeddedFiles:
9+
- name: TestFile
10+
type: TEXT
11+
filename: test_eol.txt
12+
data: "line1\nline2\nline3"
13+
endOfLine: LF
14+
actions:
15+
onRun:
16+
command: bash
17+
args: ["-c", "cat '{{Task.File.TestFile}}' | od -c | head -1"]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
specificationVersion: jobtemplate-2023-09
2+
name: FB1 Extended Step Name
3+
extensions:
4+
- FEATURE_BUNDLE_1
5+
steps:
6+
- name: ThisIsAVeryLongStepNameThatExceedsTheSixtyFourCharacterLimitButIsAllowedWithFeatureBundle1Extension
7+
script:
8+
actions:
9+
onRun:
10+
command: bash
11+
args: ["-c", "echo 'Long step name works!'"]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
specificationVersion: jobtemplate-2023-09
2+
name: FB1 PowerShell Syntax Sugar
3+
extensions:
4+
- FEATURE_BUNDLE_1
5+
steps:
6+
- name: PowerShellStep
7+
powershell:
8+
script: |
9+
Write-Host "Hello from PowerShell!"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
specificationVersion: jobtemplate-2023-09
2+
name: FB1 Python Syntax Sugar
3+
extensions:
4+
- FEATURE_BUNDLE_1
5+
steps:
6+
- name: PythonStep
7+
python:
8+
script: |
9+
print("Hello from Python!")
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
specificationVersion: jobtemplate-2023-09
2+
name: FB1 Format String Timeout
3+
extensions:
4+
- FEATURE_BUNDLE_1
5+
parameterDefinitions:
6+
- name: Timeout
7+
type: INT
8+
default: 5
9+
steps:
10+
- name: TimeoutStep
11+
script:
12+
actions:
13+
onRun:
14+
command: bash
15+
args: ["-c", "echo Running with timeout {{Param.Timeout}}s; sleep 1"]
16+
timeout: "{{Param.Timeout}}"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
3+
"""Tests for FEATURE_BUNDLE_1 extension support in the CLI."""
4+
5+
import os
6+
from pathlib import Path
7+
8+
import pytest
9+
10+
from . import run_openjd_cli_main
11+
12+
TEMPLATES_DIR = Path(__file__).parent / "templates"
13+
14+
15+
class TestFeatureBundle1:
16+
"""Tests for FEATURE_BUNDLE_1 extension features."""
17+
18+
def test_python_syntax_sugar(self, capsys) -> None:
19+
"""Test that Python syntax sugar works."""
20+
template = TEMPLATES_DIR / "feature_bundle_1_python.yaml"
21+
outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0)
22+
assert "Hello from Python!" in outerr.out
23+
24+
def test_bash_syntax_sugar(self, capsys) -> None:
25+
"""Test that Bash syntax sugar works."""
26+
template = TEMPLATES_DIR / "feature_bundle_1_bash.yaml"
27+
outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0)
28+
assert "Hello from Bash!" in outerr.out
29+
30+
@pytest.mark.skipif(os.name != "nt", reason="PowerShell only available on Windows")
31+
def test_powershell_syntax_sugar(self, capsys) -> None:
32+
"""Test that PowerShell syntax sugar works."""
33+
template = TEMPLATES_DIR / "feature_bundle_1_powershell.yaml"
34+
outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0)
35+
assert "Hello from PowerShell!" in outerr.out
36+
37+
@pytest.mark.skipif(os.name != "nt", reason="cmd only available on Windows")
38+
def test_cmd_syntax_sugar(self, capsys) -> None:
39+
"""Test that cmd syntax sugar works."""
40+
template = TEMPLATES_DIR / "feature_bundle_1_cmd.yaml"
41+
outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0)
42+
assert "Hello from Cmd!" in outerr.out
43+
44+
def test_format_string_timeout(self, capsys) -> None:
45+
"""Test that format string timeout is resolved."""
46+
template = TEMPLATES_DIR / "feature_bundle_1_timeout.yaml"
47+
outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0)
48+
assert "Running with timeout 5s" in outerr.out
49+
50+
def test_extended_step_name(self, capsys) -> None:
51+
"""Test that extended step names (>64 chars) work with extension."""
52+
template = TEMPLATES_DIR / "feature_bundle_1_long_name.yaml"
53+
outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0)
54+
assert "Long step name works!" in outerr.out
55+
56+
def test_end_of_line_lf(self, capsys) -> None:
57+
"""Test that endOfLine: LF produces LF-only line endings."""
58+
template = TEMPLATES_DIR / "feature_bundle_1_eol.yaml"
59+
outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0)
60+
# od -c output should show \n without \r
61+
assert "\\n" in outerr.out or "l i n e" in outerr.out
62+
63+
def test_check_validates_extension(self, capsys) -> None:
64+
"""Test that check command validates templates with extension."""
65+
template = TEMPLATES_DIR / "feature_bundle_1_python.yaml"
66+
outerr = run_openjd_cli_main(capsys, args=["check", str(template)], expected_exit_code=0)
67+
assert "passes validation checks" in outerr.out

0 commit comments

Comments
 (0)