name: PR Validation
on:
pull_request:
branches:
- main
- master
types: [opened, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
validate:
name: Validate Pull Request
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Fetch more history for better analysis
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
# Enable Corepack for Yarn support
- name: Enable Corepack
run: corepack enable
- name: Install dependencies
run: yarn install --immutable
- name: Lint code
run: |
echo "π Running lint checks..."
yarn lint
- name: Build packages
run: |
echo "ποΈ Building all packages..."
yarn build
- name: Run tests
run: |
echo "π§ͺ Running test suite..."
yarn test
- name: Validate package integrity
run: |
echo "π¦ Validating package configurations..."
# Check that all packages have valid package.json files
for package_dir in packages/*/; do
if [ -f "${package_dir}package.json" ]; then
echo "β
Validating ${package_dir}package.json"
node -e "
try {
const pkg = require('./${package_dir}package.json');
console.log('Package:', pkg.name, 'Version:', pkg.version);
} catch(e) {
console.error('Invalid package.json in ${package_dir}:', e.message);
process.exit(1);
}
"
fi
done
# Summary job that other jobs can depend on
pr-validation-complete:
name: PR Validation Complete
runs-on: ubuntu-latest
needs: [validate]
if: always()
steps:
- name: Check validation results
run: |
if [ "${{ needs.validate.result }}" == "success" ]; then
echo "β
All validation checks passed!"
echo "π This PR is ready for review and merge."
else
echo "β Validation checks failed!"
echo "π This PR cannot be merged until all checks pass."
exit 1
fi
- name: Post validation summary
if: always()
run: |
echo "## π PR Validation Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Status:** ${{ needs.validate.result == 'success' && 'β
Passed' || 'β Failed' }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Checks Performed:" >> $GITHUB_STEP_SUMMARY
echo "- π **Lint:** Code style and quality checks" >> $GITHUB_STEP_SUMMARY
echo "- ποΈ **Build:** Package compilation and bundling" >> $GITHUB_STEP_SUMMARY
echo "- π§ͺ **Tests:** Unit and integration test suite" >> $GITHUB_STEP_SUMMARY
echo "- π¦ **Package Integrity:** Validate package.json files" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.validate.result }}" == "success" ]; then
echo "π **All checks passed!** This PR is ready for review." >> $GITHUB_STEP_SUMMARY
else
echo "β οΈ **Some checks failed.** Please fix the issues before merging." >> $GITHUB_STEP_SUMMARY
fi