Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarbuzzi committed Sep 28, 2024
1 parent 5f66987 commit 0d4e4d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 29 deletions.
29 changes: 13 additions & 16 deletions actions/testmo-create-resources/action.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
---
name: create testmo resources
description: create a TestMo resource .json file
description: create a Testmo resource .json file

inputs:
testmo_token:
description: testmo token
required: true
resources_file:
description: file name where the resources will be stored
required: true
resources_json:
description: stringified JSON associative array of resource fields to add. Each field's
key is the name of the field, and it's value is the value of the field.
key is the name of the field, and its value is the value of the field.
default: ''
required: false

Expand All @@ -22,17 +19,17 @@ runs:
shell: bash
run: echo "${{ github.action_path }}" >> $GITHUB_PATH

- name: compose TESTMO resources file
- name: compose Testmo resources file
run: |
echo "composing TESTMO resources file ${{ inputs.resources_file }} ..."
echo "shell CWD: $(pwd)"
ls -A
echo "composing Testmo resources file '$RESOURCES_FILE'"
compose_testmo_resources_file.py \
--resources_json '${{ inputs.resources_json }}' \
--destination "${{ inputs.resources_file }}"
ls -A
echo "resource file ${{ inputs.resources_json }} contents:"
cat "${{ inputs.resources_file }}"
env:
TESTMO_TOKEN: ${{ inputs.testmo_token }}
--resources_json "$RESOURCES_JSON" \
--destination "$RESOURCES_FILE"
echo "resources file contents:"
cat "$RESOURCES_FILE"
shell: bash
env:
RESOURCES_FILE: ${{ inputs.resources_file }}
RESOURCES_JSON: ${{ inputs.resources_json }}
14 changes: 1 addition & 13 deletions actions/testmo-create-resources/compose_testmo_resources_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import argparse
import json
import pathlib
import shlex
import subprocess

if __name__ == "__main__":
Expand All @@ -31,7 +29,6 @@
help="absolute path for where to generate the file,",
type=str)

print(f"cwd: {pathlib.Path.cwd()}") # noqa: T201
args = args_parser.parse_args()
fields = json.loads(args.resources_json)

Expand All @@ -44,15 +41,6 @@
]
testmo_command = ["npx", "testmo", "automation:resources:add-field"]
full_command = testmo_command + testmo_args
print(f"running command: {shlex.join(full_command)}") # noqa: T201

# run the command and raise any exceptions
subprocess.run( # noqa: S602
full_command,
check=True,
cwd=pathlib.Path.cwd(),
shell=True
)

print(f"destination: {args.destination}") # noqa: T201
print(f"exists: {pathlib.Path(args.destination).exists()}") # noqa: T201
subprocess.run(full_command, check=True)

0 comments on commit 0d4e4d2

Please sign in to comment.