Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEST: Add github workflow #209

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions .github/workflows/validate-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
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
env:
NX_DATABASE_URL=postgresql://maybe:maybe@localhost:5432/maybe_local?connection_limit=32&pool_timeout=20
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

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: 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 --env.WEBHOOK_TYPE 'mock'
- name: Upload test artifacts
if: failure()
uses: actions/upload-artifact@v2
with:
name: cypress-artifacts
path: dist/cypress/apps/e2e
Loading