From a5d9bb40380c598bf7d03cb16623026892844ed4 Mon Sep 17 00:00:00 2001 From: "L. R. Couto" <57910428+lrcouto@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:57:40 -0300 Subject: [PATCH] Add Github Actions workflow to trigger pipeline performance test (#4231) * Add Github Actions workflow to trigger pipeline performance test Signed-off-by: Laura Couto * Lint Signed-off-by: Laura Couto * Lint Signed-off-by: Laura Couto * Change trigger to PR label Signed-off-by: Laura Couto * Run workflow on kedro repo Signed-off-by: Laura Couto * Change setup-python version to 5 Signed-off-by: L. R. Couto <57910428+lrcouto@users.noreply.github.com> --------- Signed-off-by: Laura Couto Signed-off-by: L. R. Couto <57910428+lrcouto@users.noreply.github.com> --- .../workflows/pipeline-performance-test.yml | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/pipeline-performance-test.yml diff --git a/.github/workflows/pipeline-performance-test.yml b/.github/workflows/pipeline-performance-test.yml new file mode 100644 index 0000000000..58fb582213 --- /dev/null +++ b/.github/workflows/pipeline-performance-test.yml @@ -0,0 +1,79 @@ +name: Trigger and Run Pipeline Performance Test + +on: + pull_request: + types: [labeled] + +jobs: + performance-test: + runs-on: ubuntu-latest + + steps: + - name: Check if 'performance' label was added + if: github.event.action == 'labeled' && contains(github.event.label.name, 'performance') + run: echo "Performance label detected. Running performance test." + + - name: Clone test repo + if: github.event.action == 'labeled' && contains(github.event.label.name, 'performance') + run: | + git clone https://x-access-token:${{ secrets.GH_TAGGING_TOKEN }}@github.com/kedro-org/pipeline-performance-test.git + + - name: Set up Python 3.11 + if: github.event.action == 'labeled' && contains(github.event.label.name, 'performance') + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install dependencies + if: github.event.action == 'labeled' && contains(github.event.label.name, 'performance') + run: | + pip install kedro + pip install uv + cd pipeline-performance-test/performance-test + pip install -r requirements.txt + + - name: Run performance test and capture time for latest Kedro release + if: github.event.action == 'labeled' && contains(github.event.label.name, 'performance') + run: | + cd pipeline-performance-test/performance-test + total_time_release=0.0 + for i in {1..10}; do + { time kedro run; } 2> release_time_output.txt + real_time_release=$(grep real release_time_output.txt | awk '{print $2}' | sed 's/[^0-9.]//g') + total_time_release=$(echo "$total_time_release + $real_time_release" | bc) + done + average_time_release=$(echo "scale=3; $total_time_release / 10" | bc) + echo "average_time_release=${average_time_release}" >> $GITHUB_ENV + + - name: Pull specific branch from Kedro and install it + if: github.event.action == 'labeled' && contains(github.event.label.name, 'performance') + run: | + git clone --branch ${{ github.event.pull_request.head.ref }} https://github.com/kedro-org/kedro.git + cd kedro + make install + + - name: Run performance test and capture time for specific Kedro branch + if: github.event.action == 'labeled' && contains(github.event.label.name, 'performance') + run: | + cd pipeline-performance-test/performance-test + total_time_branch=0.0 + for i in {1..10}; do + { time kedro run --params=hook_delay=0,dataset_load_delay=0,file_save_delay=0; } 2> branch_time_output.txt + real_time_branch=$(grep real branch_time_output.txt | awk '{print $2}' | sed 's/[^0-9.]//g') + total_time_branch=$(echo "$total_time_branch + $real_time_branch" | bc) + done + average_time_branch=$(echo "scale=3; $total_time_branch / 10" | bc) + echo "average_time_branch=${average_time_branch}" >> $GITHUB_ENV + + - name: Extract and format real time from release version + if: github.event.action == 'labeled' && contains(github.event.label.name, 'performance') + run: echo "Average elapsed time for Kedro release version test was ${average_time_release} seconds" + + - name: Extract and format real time from specific branch + if: github.event.action == 'labeled' && contains(github.event.label.name, 'performance') + run: echo "Average elapsed time for specific branch test was ${average_time_branch} seconds" + + - name: Clean up time output files + if: github.event.action == 'labeled' && contains(github.event.label.name, 'performance') + run: | + rm pipeline-performance-test/performance-test/release_time_output.txt pipeline-performance-test/performance-test/branch_time_output.txt