test-matrix.yml•3.24 kB
name: Test Matrix
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
env:
NODE_VERSION: '20'
PNPM_VERSION: '8'
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: ['18', '20', '21']
storage-type: [memory, file, postgres, aws]
exclude:
- os: windows-latest
storage-type: postgres
- os: macos-latest
storage-type: aws
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Get PNPM store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup PNPM cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint code
run: pnpm run lint
- name: Type check
run: pnpm run type-check
- name: Run unit tests
run: pnpm run test:unit
env:
STORAGE_TYPE: ${{ matrix.storage-type }}
- name: Run integration tests
run: pnpm run test:integration
env:
STORAGE_TYPE: ${{ matrix.storage-type }}
- name: Build project
run: pnpm run build
- name: Run build tests
run: pnpm run test:build
env:
STORAGE_TYPE: ${{ matrix.storage-type }}
- name: Upload test results
uses: actions/upload-artifact@v3
if: always()
with:
name: test-results-${{ matrix.os }}-node${{ matrix.node-version }}-${{ matrix.storage-type }}
path: |
coverage/
test-results/
retention-days: 30
coverage:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all test results
uses: actions/download-artifact@v3
- name: Combine coverage reports
run: |
# Combine coverage reports from all test runs
mkdir -p combined-coverage
find . -name "coverage" -type d -exec cp -r {} combined-coverage/ \;
# Generate combined coverage report
npx nyc merge combined-coverage coverage/coverage-final.json
npx nyc report --reporter=text-summary
npx nyc report --reporter=lcov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage/lcov.info
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
- name: Comment coverage on PR
uses: romeovs/lcov-reporter-action@v0.3.1
if: github.event_name == 'pull_request'
with:
lcov-file: ./coverage/lcov.info
github-token: ${{ secrets.GITHUB_TOKEN }}
delete-old-comments: true