chore(ci): handle inputs vars safely in python script

This commit is contained in:
David Testé
2025-11-21 15:33:17 +01:00
committed by David Testé
parent b0393c0acb
commit 0b98ef98fc
3 changed files with 61 additions and 24 deletions

View File

@@ -71,21 +71,34 @@ jobs:
steps:
- name: Parse user inputs
shell: python
run: | # zizmor: ignore[template-injection] these env variables are safe
split_command = "${{ inputs.command }}".replace(" ", "").split(",")
split_op_flavor = "${{ inputs.op_flavor }}".replace(" ", "").split(",")
env:
INPUTS_COMMAND: ${{ inputs.command }}
INPUTS_OP_FLAVOR: ${{ inputs.op_flavor }}
INPUTS_BENCH_TYPE: ${{ inputs.bench_type }}
INPUTS_PARAMS_TYPE: ${{ inputs.params_type }}
run: |
import os
if "${{ inputs.bench_type }}" == "both":
inputs_command = os.environ["INPUTS_COMMAND"]
inputs_op_flavor = os.environ["INPUTS_OP_FLAVOR"]
inputs_bench_type = os.environ["INPUTS_BENCH_TYPE"]
inputs_params_type = os.environ["INPUTS_PARAMS_TYPE"]
env_file = os.environ["GITHUB_ENV"]
split_command = inputs_command.replace(" ", "").split(",")
split_op_flavor = inputs_op_flavor.replace(" ", "").split(",")
if inputs_bench_type == "both":
bench_type = ["latency", "throughput"]
else:
bench_type = ["${{ inputs.bench_type }}", ]
bench_type = [inputs_bench_type, ]
if "+" in "${{ inputs.params_type }}":
split_params_type= "${{ inputs.params_type }}".replace(" ", "").split("+")
if "+" in inputs_params_type:
split_params_type= inputs_params_type.replace(" ", "").split("+")
else:
split_params_type = ["${{ inputs.params_type }}", ]
split_params_type = [inputs_params_type, ]
with open("${{ github.env }}", "a") as f:
with open(env_file, "a") as f:
for env_name, values_to_join in [
("COMMAND", split_command),
("OP_FLAVOR", split_op_flavor),

View File

@@ -73,21 +73,34 @@ jobs:
steps:
- name: Parse user inputs
shell: python
run: | # zizmor: ignore[template-injection] these env variables are safe
split_command = "${{ inputs.command }}".replace(" ", "").split(",")
split_op_flavor = "${{ inputs.op_flavor }}".replace(" ", "").split(",")
env:
INPUTS_COMMAND: ${{ inputs.command }}
INPUTS_OP_FLAVOR: ${{ inputs.op_flavor }}
INPUTS_BENCH_TYPE: ${{ inputs.bench_type }}
INPUTS_PARAMS_TYPE: ${{ inputs.params_type }}
run: |
import os
if "${{ inputs.bench_type }}" == "both":
inputs_command = os.environ["INPUTS_COMMAND"]
inputs_op_flavor = os.environ["INPUTS_OP_FLAVOR"]
inputs_bench_type = os.environ["INPUTS_BENCH_TYPE"]
inputs_params_type = os.environ["INPUTS_PARAMS_TYPE"]
env_file = os.environ["GITHUB_ENV"]
split_command = inputs_command.replace(" ", "").split(",")
split_op_flavor = inputs_op_flavor.replace(" ", "").split(",")
if inputs_bench_type == "both":
bench_type = ["latency", "throughput"]
else:
bench_type = ["${{ inputs.bench_type }}", ]
bench_type = [inputs_bench_type, ]
if "+" in "${{ inputs.params_type }}":
split_params_type= "${{ inputs.params_type }}".replace(" ", "").split("+")
if "+" in inputs_params_type:
split_params_type= inputs_params_type.replace(" ", "").split("+")
else:
split_params_type = ["${{ inputs.params_type }}", ]
split_params_type = [inputs_params_type, ]
with open("${{ github.env }}", "a") as f:
with open(env_file, "a") as f:
for env_name, values_to_join in [
("COMMAND", split_command),
("OP_FLAVOR", split_op_flavor),

View File

@@ -67,16 +67,27 @@ jobs:
steps:
- name: Parse user inputs
shell: python
run: | # zizmor: ignore[template-injection] these env variables are safe
split_command = "${{ inputs.command }}".replace(" ", "").split(",")
split_op_flavor = "${{ inputs.op_flavor }}".replace(" ", "").split(",")
env:
INPUTS_COMMAND: ${{ inputs.command }}
INPUTS_OP_FLAVOR: ${{ inputs.op_flavor }}
INPUTS_BENCH_TYPE: ${{ inputs.bench_type }}
run: |
import os
if "${{ inputs.bench_type }}" == "both":
inputs_command = os.environ["INPUTS_COMMAND"]
inputs_op_flavor = os.environ["INPUTS_OP_FLAVOR"]
inputs_bench_type = os.environ["INPUTS_BENCH_TYPE"]
env_file = os.environ["GITHUB_ENV"]
split_command = inputs_command.replace(" ", "").split(",")
split_op_flavor = inputs_op_flavor.replace(" ", "").split(",")
if inputs_bench_type == "both":
bench_type = ["latency", "throughput"]
else:
bench_type = ["${{ inputs.bench_type }}", ]
bench_type = [inputs_bench_type, ]
with open("${{ github.env }}", "a") as f:
with open(env_file, "a") as f:
for env_name, values_to_join in [
("COMMAND", split_command),
("OP_FLAVOR", split_op_flavor),