Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
gh Action
Browse files Browse the repository at this point in the history
  • Loading branch information
heyAyushh committed Oct 25, 2024
1 parent f35aa0c commit 7e5c749
Showing 1 changed file with 21 additions and 42 deletions.
63 changes: 21 additions & 42 deletions .github/workflows/code:test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,51 +59,30 @@ jobs:
exit 0
fi
# Convert the space-separated list to an array
readarray -t test_files <<< "$CHANGED_FILES"
# Print the files we're going to test
echo "Running tests for the following files:"
printf '%s\n' "${test_files[@]}"
# Run all test files in a single command
node --import tsx --test "${test_files[@]}" || exit 1
# Create array for test files
declare -a test_files=()
# Collect only .test.ts files
for file in $CHANGED_FILES; do
if [[ $file == *.test.ts ]]; then
test_files+=("$file")
echo "Added test file: $file"
fi
done
# If we found test files, run them together
if [ ${#test_files[@]} -gt 0 ]; then
echo "Running tests for the following files:"
printf '%s\n' "${test_files[@]}"
# Run all test files in a single command
node --import tsx --test "${test_files[@]}" || exit 1
else
echo "No test files to run"
fi
- name: Run all tests
if: github.event_name == 'schedule'
run: |
echo "Running all tests in code directory"
pnpm turbo test
- name: Report test results
if: always() && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const { context, github } = require('@actions/github');
const testStatus = process.env.TEST_SUCCESS === 'true' ? '✅' : '❌';
const summary = [];
summary.push(`# Test Results ${testStatus}`);
summary.push('');
const changedFiles = '${{ steps.changed-files.outputs.all_changed_files }}'.split(' ');
if (changedFiles.length > 0 && changedFiles[0] !== '') {
summary.push('## Changed Test Files:');
changedFiles.forEach(file => {
summary.push(`- \`${file}\``);
});
} else {
summary.push('No test files were changed in this PR.');
}
const body = summary.join('\n');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});

0 comments on commit 7e5c749

Please sign in to comment.