Skip to content

Add CI for testing on PRs #19

Add CI for testing on PRs

Add CI for testing on PRs #19

name: Validate Pull Request
on: [pull_request]
concurrency:
group: ${{ github.ref }}-validate-pr-group
cancel-in-progress: true
jobs:
# Builds affected apps and runs unit tests
build_test:
name: Build and Test
runs-on: ubuntu-latest
environment: Testing
services:
redis:
image: redis:6-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
postgres:
image: timescale/timescaledb:latest-pg14
env:
POSTGRES_USER: maybe
POSTGRES_PASSWORD: maybe
POSTGRES_DB: maybe_local
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set NX commit SHAs for affected commands
uses: nrwl/nx-set-shas@v2 # derive appropriate SHAs for base and head for `nx affected` commands
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '18'
cache: 'yarn'
- name: Install node_modules
run: yarn install --frozen-lockfile
- name: Run unit tests
run: yarn nx affected --target=test --parallel=5 --testPathPattern='^(?!.*integration).*$'
- name: Build affected apps
run: yarn nx affected --target=build --parallel=5
- name: Setup env
run: |
cat << EOF > .env
NX_DATABASE_URL=${{ secrets.NX_DATABASE_URL }}
NX_DATABASE_SECRET=${{ secrets.NX_DATABASE_SECRET }}
NX_SESSION_SECRET=${{ secrets.NX_SESSION_SECRET }}
NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }}
NEXTAUTH_URL=http://localhost:4200
NX_NEXTAUTH_URL=http://localhost:4200
NX_PLAID_CLIENT_ID=${{ secrets.NX_PLAID_CLIENT_ID }}
NX_PLAID_SECRET=${{ secrets.NX_PLAID_SECRET }}
NX_PLAID_ENV=sandbox
NX_TELLER_SIGNING_SECRET=${{ secrets.NX_TELLER_SIGNING_SECRET }}
NEXT_PUBLIC_TELLER_APP_ID=${{ secrets.NEXT_PUBLIC_TELLER_APP_ID }}
NEXT_PUBLIC_TELLER_ENV=sandbox
NX_TELLER_ENV=sandbox
NX_EMAIL_PROVIDER=postmark
[email protected]
[email protected]
NX_EMAIL_PROVIDER_API_TOKEN=
NX_POLYGON_API_KEY=${{ secrets.NX_POLYGON_API_KEY }}
NX_POLYGON_TIER=${{ secrets.NX_POLYGON_TIER }}
NX_CORS_ORIGINS=http://localhost:4200
NX_API_URL=http://localhost:3333
NEXT_PUBLIC_API_URL=http://localhost:3333
NX_CLIENT_URL=http://localhost:4200
NX_REDIS_URL=redis://localhost:6379
EOF
- name: Run local DB migration for testing
run: yarn prisma:migrate:deploy
- name: Run integration tests
run: sudo yarn dev:ci:test --testPathPattern='^.*\.integration\.spec\.ts$'
- name: Start apps
run: yarn nx run-many --parallel --target=serve --projects=client,server,workers &
- name: Run end-to-end tests
if: "!contains(github.event.head_commit.message, 'skip-e2e')"
run: |
sudo yarn cypress install
yarn wait-on -t 120000 http://localhost:4200
sudo yarn dev:ci:e2e --configuration=ci --env.WEBHOOK_TYPE 'mock'
- name: Upload test artifacts
if: failure()
uses: actions/upload-artifact@v2
with:
name: cypress-artifacts
path: dist/cypress/apps/e2e