[WIP] Fix Docker #1273
This file contains 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 | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
env: | |
NODE_OPTIONS: '--max_old_space_size=4096' | |
LOG_LEVEL: warn | |
CONTENTFUL_HOST: cdn.contentful.com | |
CONTENTFUL_SPACE: wuv9tl5d77ll | |
CONTENTFUL_TOKEN: ${{ secrets.CONTENTFUL_TOKEN }} | |
NX_CLOUD_DISTRIBUTED_EXECUTION: false | |
NX_PUBLIC_AMPLITUDE_KEY: ${{ secrets.NX_PUBLIC_AMPLITUDE_KEY }} | |
NX_PUBLIC_ROLLBAR_KEY: ${{ secrets.NX_PUBLIC_ROLLBAR_KEY }} | |
NX_PUBLIC_CLIENT_URL: 'http://localhost:3333/app' | |
NX_PUBLIC_SERVER_URL: 'http://localhost:3333' | |
jobs: | |
# Build application | |
build-and-test: | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout [main] | |
with: | |
fetch-depth: 0 | |
- name: Setup branch tracking | |
if: success() && github.ref != 'refs/heads/main' | |
run: git branch --track main origin/main | |
- name: Derive appropriate SHAs for base and head for `nx affected` commands | |
uses: nrwl/nx-set-shas@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'yarn' | |
- name: install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Test all projects | |
run: yarn test:all | |
- name: Build | |
run: yarn build:ci | |
- name: Uploading artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist-artifacts | |
path: dist | |
test-docker-image: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout [main] | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'yarn' | |
# This is annoying since we have to run it here and in docker container | |
# it is used for the .env config - maybe there is a better way to do this? | |
- name: install dependencies | |
run: yarn install --frozen-lockfile | |
- name: generate .env file | |
run: yarn scripts:generate-env --silent | |
- name: Build Docker image | |
run: docker build -t jetstream-app . | |
- name: Start containers | |
run: docker compose -f docker-compose.yml up -d | |
- name: Wait for containers | |
run: | | |
echo "Waiting for containers to be healthy..." | |
timeout 30 bash -c 'until docker compose ps | grep -q "healthy"; do sleep 1; done' | |
- name: Check containers | |
run: docker compose ps | |
- name: Test API endpoints | |
run: | | |
echo "Testing API endpoints..." | |
curl --fail --retry 5 --retry-delay 2 http://localhost:3333/healthz | |
- name: Show logs on failure | |
if: failure() | |
run: docker compose logs | |
- name: Cleanup | |
if: always() | |
run: docker compose down -v | |
test-cron: | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
env: | |
PRISMA_TEST_DB_URI: postgres://postgres:postgres@localhost:5432/postgres | |
JETSTREAM_POSTGRES_DBURI: postgres://postgres:postgres@localhost:5432/postgres | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout [master] | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'yarn' | |
- name: install dependencies | |
run: yarn install --frozen-lockfile | |
# Run database migrations | |
- name: Generate database | |
run: yarn db:generate | |
- name: Run database migration | |
run: yarn db:migrate | |
- name: Test cron-tasks | |
run: yarn test:cron | |
e2e: | |
runs-on: ubuntu-latest | |
env: | |
NX_CLOUD_DISTRIBUTED_EXECUTION: false | |
AUTH_SFDC_CLIENT_ID: ${{ secrets.SFDC_CONSUMER_KEY }} | |
AUTH_SFDC_CLIENT_SECRET: ${{ secrets.SFDC_CONSUMER_SECRET }} | |
E2E_LOGIN_PASSWORD: ${{ secrets.E2E_LOGIN_PASSWORD }} | |
E2E_LOGIN_URL: 'https://jetstream-e2e-dev-ed.develop.my.salesforce.com' | |
E2E_LOGIN_USERNAME: '[email protected]' | |
EXAMPLE_USER_OVERRIDE: true | |
EXAMPLE_USER_PASSWORD: 'EXAMPLE_123!' | |
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }} | |
GOOGLE_APP_ID: ${{ secrets.GOOGLE_APP_ID }} | |
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }} | |
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }} | |
JETSTREAM_AUTH_OTP_SECRET: ${{ secrets.JETSTREAM_AUTH_OTP_SECRET }} | |
JETSTREAM_AUTH_SECRET: ${{ secrets.JETSTREAM_AUTH_SECRET }} | |
JETSTREAM_CLIENT_URL: http://localhost:3333/app | |
JETSTREAM_POSTGRES_DBURI: postgres://postgres:postgres@localhost:5432/postgres | |
JETSTREAM_SERVER_DOMAIN: localhost:3333 | |
JETSTREAM_SERVER_URL: http://localhost:3333 | |
JETSTREAM_SESSION_SECRET: ${{ secrets.JETSTREAM_SESSION_SECRET }} | |
SFDC_API_VERSION: '63.0' | |
SFDC_CALLBACK_URL: http://localhost:3333/oauth/sfdc/callback | |
SFDC_CONSUMER_KEY: ${{ secrets.SFDC_CONSUMER_KEY }} | |
SFDC_CONSUMER_SECRET: ${{ secrets.SFDC_CONSUMER_SECRET }} | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout [main] | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'yarn' | |
- name: install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Build | |
run: yarn build:ci | |
- name: Install Playwright dependencies | |
run: npx playwright install --with-deps | |
- name: Generate database | |
run: yarn db:generate | |
- name: Run database migration | |
run: yarn db:migrate | |
- name: Seed DB | |
run: yarn db:seed | |
env: | |
POSTGRES_HOST: localhost | |
PGHOST: localhost | |
PGPORT: 5432 | |
PGUSER: postgres | |
PGPASSWORD: postgres | |
PGDATABASE: postgres | |
- name: Run E2E tests | |
run: yarn playwright:test:with-server | |
- name: Upload test results | |
if: always() # This ensures step will always run even if prior steps fail | |
uses: actions/upload-artifact@v4 | |
with: | |
name: playwright-report | |
path: | | |
apps/jetstream-e2e/playwright-report | |
test-results |