From 19b157f08ef1a7c6a25212864ee2d122ec886f51 Mon Sep 17 00:00:00 2001 From: Didi Hoffmann <39629+ribalba@users.noreply.github.com> Date: Wed, 7 Aug 2024 19:39:47 +0200 Subject: [PATCH] Fixes invalid labels --- .github/workflows/test.yml | 47 ++++++++++++++++++++++++++++++-------- action.yml | 5 +++- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 756b2022..389ddcde 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: test-action +name: test-action-test-file on: pull_request: @@ -26,10 +26,11 @@ jobs: fail-fast: true matrix: os: [ubuntu-22.04, ubuntu-24.04, ubuntu-20.04] + steps: - uses: actions/checkout@v4 with: - ref: ${{ github.ref }} + path: . - name: API Base Debug run: | @@ -59,7 +60,7 @@ jobs: uses: ./ with: task: get-measurement - label: "Sleep 3s" + label: "echo Hellos; $SHELL; \"" - name: Dump ECO-CI CPU Step actual processed run: | @@ -69,26 +70,52 @@ jobs: run: | cat /tmp/eco-ci/energy-step.txt - - - name: Filesystem - run: timeout 10s ls -alhR /usr/lib - continue-on-error: true + - name: Sleep 3 + run: sleep 3 - name: Test measurement 2 uses: ./ with: task: get-measurement - label: "ls -alhR /usr/lib" + label: "(Soo this is something); & ; echo $SHELL" - name: Sleep 3 run: sleep 3 - - name: Test measurement 2 + - name: Test measurement 3 uses: ./ with: task: get-measurement - label: "Sleep 3s" + label: 'Environment setup (OS ${{ matrix.os }}, lint)' + + # - name: Sleep 3 + # run: sleep 3 + + # There is currently no way of catching this IMHO + # - name: Test measurement 4 + # uses: ./ + # with: + # task: get-measurement + # label: without quotes'; echo + + - name: Sleep 3 + run: sleep 3 + + - name: Test measurement 5 + uses: ./ + with: + task: get-measurement + label: without quotes"; echo + + # - name: Sleep 3 + # run: sleep 3 + # There is currently no way of catching this IMHO + # - name: Test measurement 6 + # uses: ./ + # with: + # task: get-measurement + # label: 'without quotes''' - name: Dump ECO-CI CPU run: | diff --git a/action.yml b/action.yml index b4731221..acbc5179 100644 --- a/action.yml +++ b/action.yml @@ -99,7 +99,10 @@ runs: NAME: ${{ github.workflow }} shell: bash run: | - ${{github.action_path}}/scripts/make_measurement.sh make_measurement "${{inputs.label}}" + label='${{ contains(inputs.label, '"') && 'No quotes allowed in labels' || inputs.label }}' + label_cleaned=$(echo "$label" | tr -d "$&;\'") + echo "Cleaned label: $label_cleaned" + "${{ github.action_path }}/scripts/make_measurement.sh" make_measurement "$label_cleaned" data_file="/tmp/test.bash" lap_data_file="/tmp/eco-ci/lap-data.json" if [[ -e $lap_data_file ]]; then