Skip to content

Attempt to setup cockroachdb from github actions #13

Attempt to setup cockroachdb from github actions

Attempt to setup cockroachdb from github actions #13

Workflow file for this run

name: Pull Request CI
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
pull_request:
branches:
- main
jobs:
lint_and_test:
name: Lint and Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- run: yarn
- run: yarn lint
- run: yarn test:ci
database_setup:
name: Setup Preview Database
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- run: yarn
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Extract DB_URL
run: echo "db_url=postgresql://${{ secrets.COCKROACHDB_PREVIEW_USERNAME }}:${{ secrets.COCKROACHDB_PREVIEW_PASSWORD }}@${{ secrets.COCKROACHDB_PREVIEW_HOST }}:26257/panther_preview_${{ steps.extract_branch.outputs.branch }}?sslmode=verify-full" >> $GITHUB_OUTPUT
id: extract_db_url
- name: Setup database
env:
DB_URL: ${{steps.extract_db_url.outputs.db_url }}
run: yarn db:migrate:dev
- name: Setup Vercel CLI
run: yarn global add vercel@latest
- name: Setup Vercel database url in preview environment
run: |
echo ${{steps.extract_db_url.outputs.db_url }} > db_url.txt &
vercel env rm DB_URL preview ${{ steps.extract_branch.outputs.branch }} --token=${{ secrets.VERCEL_TOKEN }} -y
vercel env add DB_URL preview ${{ steps.extract_branch.outputs.branch }} --token=${{ secrets.VERCEL_TOKEN }} < db_url.txt
test_setup:
name: Test Setup
runs-on: ubuntu-latest
outputs:
preview_url: ${{ steps.waitForVercelPreviewDeployment.outputs.url }}
steps:
- name: Wait for Vercel preview deployment to be ready
uses: patrickedqvist/wait-for-vercel-preview@main
id: waitForVercelPreviewDeployment
with:
token: ${{ secrets.GITHUB_TOKEN }}
max_timeout: 300
test_e2e:
needs: [test_setup, database_setup]
name: E2E Tests
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Prepare testing env
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- run: yarn
- run: npx playwright install --with-deps
- name: Run tests
run: yarn test:e2e
env:
CI: false
PLAYWRIGHT_TEST_BASE_URL: ${{ needs.test_setup.outputs.preview_url }}
- uses: actions/upload-artifact@v3
if: always()
with:
name: test-results
path: test-results/
retention-days: 30