forked from omnivore-app/omnivore
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (113 loc) · 3.77 KB
/
run-tests.yaml
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Run tests
on:
push:
branches:
- main
paths-ignore:
- 'apple/**'
- 'android/**'
pull_request:
branches:
- main
paths-ignore:
- 'apple/**'
- 'android/**'
env:
NEXT_PUBLIC_APP_ENV: prod
NEXT_PUBLIC_BASE_URL: http://localhost:3000
NEXT_PUBLIC_SERVER_BASE_URL: http://localhost:4000
NEXT_PUBLIC_HIGHLIGHTS_BASE_URL: http://localhost:3000
jobs:
run-code-tests:
name: Run Codebase tests
runs-on: ${{ github.repository_owner == 'omnivore-app' && 'ubuntu-latest-m' || 'ubuntu-latest' }}
services:
postgres:
image: ankane/pgvector
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 6379
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Initialize the database
run: |
cp ./packages/api/.env.test ./packages/api/.env
psql --host localhost --port ${{ job.services.postgres.ports[5432] }} --user postgres --password -c "CREATE DATABASE omnivore_test;"
env:
PGPASSWORD: postgres
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: 18.16
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(source ~/.nvm/nvm.sh && yarn cache dir)"
- name: Install dependencies
run: |
source ~/.nvm/nvm.sh
yarn install --frozen-lockfile
- name: Database Migration
run: |
psql -h localhost -p ${{ job.services.postgres.ports[5432] }} -U postgres -c "CREATE USER app_user WITH ENCRYPTED PASSWORD 'app_pass';"
yarn workspace @omnivore/db migrate
psql -h localhost -p ${{ job.services.postgres.ports[5432] }} -U postgres -c "GRANT omnivore_user to app_user;"
env:
PG_HOST: localhost
PG_PORT: ${{ job.services.postgres.ports[5432] }}
PG_USER: postgres
PG_PASSWORD: postgres
PG_DB: omnivore_test
PGPASSWORD: postgres # This is required for the psql command to work without a password prompt
PG_EXTRA_OPTIONS: '-c lock_timeout=2000'
- name: TypeScript Build and Lint
run: |
source ~/.nvm/nvm.sh
yarn build
yarn lint
- name: Tests
run: |
source ~/.nvm/nvm.sh
yarn test
timeout-minutes: 10
env:
PG_HOST: localhost
PG_PORT: ${{ job.services.postgres.ports[5432] }}
PG_USER: app_user
PG_PASSWORD: app_pass
PG_DB: omnivore_test
PG_LOGGER: debug
REDIS_URL: redis://localhost:${{ job.services.redis.ports[6379] }}
MQ_REDIS_URL: redis://localhost:${{ job.services.redis.ports[6379] }}
build-docker-images:
name: Build docker images
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build the API docker image
run: 'docker build --file packages/api/Dockerfile .'
- name: Build the content-fetch docker image
run: 'docker build --file packages/content-fetch/Dockerfile .'
- name: Build the inbound-email-handler docker image
run: 'docker build --file packages/inbound-email-handler/Dockerfile .'
- name: Build the tts docker image
run: 'docker build --file packages/text-to-speech/Dockerfile .'