Skip to content

Commit

Permalink
test: run conditional tests only for changed files
Browse files Browse the repository at this point in the history
run all tests if tests or agents are changed, otherwise run only
relevant plugin tests.
  • Loading branch information
nbsp committed Dec 15, 2024
1 parent 428b62e commit 35f0efb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 35f0efb

Please sign in to comment.