-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (88 loc) · 2.92 KB
/
pull-requests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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