Skip to content

Add docker services to build steps #9

Add docker services to build steps

Add docker services to build steps #9

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
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_AUTH0_CLIENT_SECRET=${{ secrets.NX_AUTH0_CLIENT_SECRET }}
NX_AUTH0_MGMT_CLIENT_SECRET=${{ secrets.NX_AUTH0_MGMT_CLIENT_SECRET }}
NX_DATABASE_SECRET=${{ secrets.NX_DATABASE_SECRET }}
NX_SESSION_SECRET=${{ secrets.NX_SESSION_SECRET }}
NX_PLAID_SECRET=${{ secrets.NX_PLAID_SECRET }}
NX_POLYGON_API_KEY=${{ secrets.NX_POLYGON_API_KEY }}
NX_FINICITY_APP_KEY=${{ secrets.NX_FINICITY_APP_KEY }}
NX_FINICITY_PARTNER_SECRET=${{ secrets.NX_FINICITY_PARTNER_SECRET }}
NX_STRIPE_SECRET_KEY=${{ secrets.NX_STRIPE_SECRET_KEY }}
NX_STRIPE_WEBHOOK_SECRET=${{ secrets.NX_STRIPE_WEBHOOK_SECRET }}
NX_PLAID_WEBHOOK_URL=none
NX_CONVERTKIT_SECRET=none
NX_DATABASE_URL=postgresql://maybe:maybe@localhost:5432/maybe_local?connection_limit=32&pool_timeout=20
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 --env.WEBHOOK_TYPE 'mock'
- name: Upload test artifacts
if: failure()
uses: actions/upload-artifact@v2
with:
name: cypress-artifacts
path: dist/cypress/apps/e2e