diff --git a/.github/actions/extract-memory-report/action.yml b/.github/actions/extract-memory-report/action.yml new file mode 100644 index 000000000..a6f4d6853 --- /dev/null +++ b/.github/actions/extract-memory-report/action.yml @@ -0,0 +1,48 @@ +name: 'Extract Memory Test Report' +description: 'Extracts and displays memory test report from a container' +inputs: + container-name: + description: 'Name of the container to extract logs from' + required: true + python-version: + description: 'Python version for artifact naming' + required: true + output-dir: + description: 'Directory to store output logs' + required: false + default: 'output-logs' + +runs: + using: "composite" + steps: + - name: Create output directory + shell: bash + run: | + mkdir -p ${{ inputs.output-dir }} + + - name: Dump container log + shell: bash + run: | + docker logs ${{ inputs.container-name }} > ${{ inputs.output-dir }}/${{ inputs.container-name }}-stdout-${{ inputs.python-version }}.txt 2>&1 || echo "Could not get stdout" + docker logs ${{ inputs.container-name }} 2> ${{ inputs.output-dir }}/${{ inputs.container-name }}-stderr-${{ inputs.python-version }}.txt || echo "Could not get stderr" + + - name: Extract and display memory test report + shell: bash + run: | + echo "Extracting test-memory.log from container..." + docker cp ${{ inputs.container-name }}:/app/changedetectionio/test-memory.log ${{ inputs.output-dir }}/test-memory-${{ inputs.python-version }}.log || echo "test-memory.log not found in container" + + echo "=== Top 10 Highest Peak Memory Tests ===" + if [ -f ${{ inputs.output-dir }}/test-memory-${{ inputs.python-version }}.log ]; then + grep "Peak memory:" ${{ inputs.output-dir }}/test-memory-${{ inputs.python-version }}.log | \ + sed 's/.*Peak memory: //' | \ + paste -d'|' - <(grep "Peak memory:" ${{ inputs.output-dir }}/test-memory-${{ inputs.python-version }}.log) | \ + sort -t'|' -k1 -nr | \ + cut -d'|' -f2 | \ + head -10 + echo "" + echo "=== Full Memory Test Report ===" + cat ${{ inputs.output-dir }}/test-memory-${{ inputs.python-version }}.log + else + echo "No memory log available" + fi diff --git a/.github/workflows/test-stack-reusable-workflow.yml b/.github/workflows/test-stack-reusable-workflow.yml index 6431e2c94..0a04ccfe3 100644 --- a/.github/workflows/test-stack-reusable-workflow.yml +++ b/.github/workflows/test-stack-reusable-workflow.yml @@ -98,33 +98,12 @@ jobs: run: | docker run --name test-cdio-basic-tests --network changedet-network test-changedetectionio bash -c 'cd changedetectionio && ./run_basic_tests.sh' - - name: Dump container log + - name: Extract memory report and logs if: always() - run: | - mkdir output-logs - docker logs test-cdio-basic-tests > output-logs/test-cdio-basic-tests-stdout-${{ env.PYTHON_VERSION }}.txt - docker logs test-cdio-basic-tests 2> output-logs/test-cdio-basic-tests-stderr-${{ env.PYTHON_VERSION }}.txt - - - name: Extract and display memory test report - if: always() - run: | - echo "Extracting test-memory.log from container..." - docker cp test-cdio-basic-tests:/app/changedetectionio/test-memory.log output-logs/test-memory-${{ env.PYTHON_VERSION }}.log || echo "test-memory.log not found in container" - - echo "=== Top 10 Highest Peak Memory Tests ===" - if [ -f output-logs/test-memory-${{ env.PYTHON_VERSION }}.log ]; then - grep "Peak memory:" output-logs/test-memory-${{ env.PYTHON_VERSION }}.log | \ - sed 's/.*Peak memory: //' | \ - paste -d'|' - <(grep "Peak memory:" output-logs/test-memory-${{ env.PYTHON_VERSION }}.log) | \ - sort -t'|' -k1 -nr | \ - cut -d'|' -f2 | \ - head -10 - echo "" - echo "=== Full Memory Test Report ===" - cat output-logs/test-memory-${{ env.PYTHON_VERSION }}.log - else - echo "No memory log available" - fi + uses: ./.github/actions/extract-memory-report + with: + container-name: test-cdio-basic-tests + python-version: ${{ env.PYTHON_VERSION }} - name: Store test artifacts if: always()