From 7adbd9fd24f4b34de08629f73bf6c49685fda778 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 28 May 2024 09:06:25 -0400 Subject: [PATCH] ci: fix test-python test_durations and its caches (#3820) The previous workflow file has several bugs. ## Summary by CodeRabbit - **Chores** - Updated paths and keys for caching test durations in the Python test workflow. - Adjusted pytest command for improved test duration handling. --------- Signed-off-by: Jinzhe Zeng --- .github/workflows/test_python.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test_python.yml b/.github/workflows/test_python.yml index 8b78f4cd0b..0f9fc61acd 100644 --- a/.github/workflows/test_python.yml +++ b/.github/workflows/test_python.yml @@ -42,17 +42,18 @@ jobs: - name: Get durations from cache uses: actions/cache@v4 with: - path: test_durations + path: .test_durations # the key must never match, even when restarting workflows, as that # will cause durations to get out of sync between groups, the # combined durations will be loaded if available - key: test-durations-split-${{ github.run_id }}-${{ github.run_number}}-${{ matrix.python }}-${{ matrix.group }} + key: test2-durations-split-${{ github.run_id }}-${{ github.run_number}}-${{ matrix.python }}-${{ matrix.group }} restore-keys: | - test-durations-combined-${{ matrix.python }}-${{ github.sha }} - test-durations-combined-${{ matrix.python }} - - run: pytest --cov=deepmd source/tests --durations=0 --splits 6 --group ${{ matrix.group }} --store-durations --durations-path=.test_durations_${{ matrix.group }} --splitting-algorithm least_duration + test2-durations-combined-${{ matrix.python }}-${{ github.sha }} + test2-durations-combined-${{ matrix.python }} + - run: pytest --cov=deepmd source/tests --durations=0 --splits 6 --group ${{ matrix.group }} --store-durations --durations-path=.test_durations --splitting-algorithm least_duration env: NUM_WORKERS: 0 + - run: mv .test_durations .test_durations_${{ matrix.group }} - name: Upload partial durations uses: actions/upload-artifact@v4 with: @@ -77,15 +78,15 @@ jobs: # key won't match during the first run for the given commit, but # restore-key will if there's a previous stored durations file, # so cache will both be loaded and stored - key: test-durations-combined-${{ matrix.python }}-${{ github.sha }} - restore-keys: test-durations-combined-${{ matrix.python }} + key: test2-durations-combined-${{ matrix.python }}-${{ github.sha }} + restore-keys: test2-durations-combined-${{ matrix.python }} - name: Download artifacts uses: actions/download-artifact@v4 with: pattern: split-${{ matrix.python }}-* merge-multiple: true - name: Combine test durations - run: jq '. + input' .test_durations_* > .test_durations + run: jq -s add .test_durations_* > .test_durations pass: name: Pass testing Python needs: [testpython, update_durations]