Skip to content

Commit

Permalink
Revert "Use Python for tmt_context (#49)"
Browse files Browse the repository at this point in the history
This reverts commit 9d7f622.
  • Loading branch information
zmiklank committed Sep 8, 2022
1 parent 0021d13 commit 70144f4
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 25 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
tests/copr_artifacts
tests/secrets
tests/variables
tests/tmt_context
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ runs:
- name: Generate tmt context
id: generate_context
run: |
python generate_tmt_vars.py "tmt_context"
python -c 'import json; print({} if not "${{ inputs.tmt_context }}".strip() else json.dumps({key: value for key, value in [s.split("=", 1) for s in "${{ inputs.tmt_context }}".split(";")]}))' > tmt_context
echo "::set-output name=TMT_CONTEXT::$(cat tmt_context)"
shell: bash

Expand Down
2 changes: 1 addition & 1 deletion generate_tmt_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
output_name = ""
if len(sys.argv) == 2:
output_name = sys.argv[1]
if output_name != "variables" and output_name != "secrets" and output_name != "tmt_context":
if output_name != "variables" and output_name != "secrets":
sys.exit(1)

if len(sys.argv) > 2:
Expand Down
22 changes: 0 additions & 22 deletions tests/test_tmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,6 @@ def test_tmt_variables_missing_second_parameter():
assert json_string == expected


def test_tmt_context_missing_second_parameter():
expected = {}
output_name = "tmt_context"
ret_val = subprocess.call(f"python3 {TESTDIR}/../generate_tmt_vars.py \"{output_name}\"", shell=True)
assert ret_val == 0
with open(output_name, "r") as f:
data = f.read()
json_string = json.loads(data)
assert json_string == expected


def test_tmt_variables_one_parameter():
expected = {"data": "123"}
output_name = "variables"
Expand All @@ -75,17 +64,6 @@ def test_tmt_variables_one_parameter():
assert json_string == expected


def test_tmt_context_one_parameter():
expected = {"data": "123"}
output_name = "tmt_context"
ret_val = subprocess.call(f"python3 {TESTDIR}/../generate_tmt_vars.py \"{output_name}\" \"data=123\"", shell=True)
assert ret_val == 0
with open(output_name, "r") as f:
data = f.read()
json_string = json.loads(data)
assert json_string == expected


def test_tmt_variables_two_variable():
expected = {"data": "123", "second": "987"}
output_name = "variables"
Expand Down

0 comments on commit 70144f4

Please sign in to comment.