Merge pull request #94 from Cedarich/feature/user-donation-history-en… #38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [main, master, develop] | |
| pull_request: | |
| branches: [main, master, develop] | |
| jobs: | |
| build: | |
| name: Build Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build project | |
| run: npm run build | |
| test: | |
| name: Test Check | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests | |
| run: npm test | |
| - name: Check for new test files | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| echo "Checking for new test files in PR..." | |
| git fetch origin ${{ github.base_ref }} --depth=1 | |
| NEW_TEST_FILES=$(git diff --name-only --diff-filter=A origin/${{ github.base_ref }} | grep -E '\.(spec|test)\.(ts|js)$' || true) | |
| if [ -n "$NEW_TEST_FILES" ]; then | |
| echo "New test files detected:" | |
| echo "$NEW_TEST_FILES" | |
| echo "" | |
| echo "Running tests to ensure new test files pass..." | |
| npm test -- --findRelatedTests $NEW_TEST_FILES --passWithNoTests | |
| else | |
| echo "No new test files added in this PR." | |
| fi |