From 35f0efb1b8cc2da7b474fa921a0f512e56c9ac0c Mon Sep 17 00:00:00 2001 From: aoife cassidy Date: Sun, 15 Dec 2024 12:49:31 +0200 Subject: [PATCH] test: run conditional tests only for changed files run all tests if tests or agents are changed, otherwise run only relevant plugin tests. --- .github/workflows/test.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b0cc509..677d2d8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,4 +34,19 @@ jobs: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} ELEVEN_API_KEY: ${{ secrets.ELEVEN_API_KEY }} DEEPGRAM_API_KEY: ${{ secrets.DEEPGRAM_API_KEY }} - run: pnpm test + run: | + agents=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q '^agents.*\.ts$' && echo 1 || echo 0) + tests=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q '^plugins/test.*\.ts$' && echo 1 || echo 0) + plugins=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^plugins.*\.ts$' | cut -d/ -f2 | sort -u | tr '\n' ' ') + + if [[ "$agents" -eq 1 || "$tests" -eq 1 ]]; then + pnpm test + elif [[ -n "$plugins" ]]; then + read -ra plugins <<< "$plugins" + for plugin in "${plugins[@]}"; do + pnpm test $plugin + done + else + echo "::notice::no testable changes detected" + exit 0 + fi