89 lines
2.6 KiB
YAML
89 lines
2.6 KiB
YAML
name: Run tests
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths-ignore:
|
|
- 'apple/**'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
paths-ignore:
|
|
- 'apple/**'
|
|
|
|
jobs:
|
|
run-code-tests:
|
|
name: Run Codebase tests
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
postgres:
|
|
image: postgres
|
|
env:
|
|
POSTGRES_PASSWORD: postgres
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
ports:
|
|
- 5432
|
|
elastic:
|
|
image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
|
|
env:
|
|
discovery.type: single-node
|
|
http.cors.allow-origin: '*'
|
|
http.cors.enabled: true
|
|
http.cors.allow-headers: 'X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization'
|
|
http.cors.allow-credentials: true
|
|
options: >-
|
|
--health-cmd "curl http://0.0.0.0:9200/_cluster/health"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
ports:
|
|
- 9200
|
|
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: 14.18
|
|
- 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: TypeScript, Lint, Tests
|
|
run: |
|
|
source ~/.nvm/nvm.sh
|
|
yarn build
|
|
yarn lint
|
|
yarn test
|
|
env:
|
|
PG_HOST: localhost
|
|
PG_PORT: ${{ job.services.postgres.ports[5432] }}
|
|
PG_USER: postgres
|
|
PG_PASSWORD: postgres
|
|
PG_DB: omnivore_test
|
|
PG_POOL_MAX: 10
|
|
ELASTIC_URL: http://localhost:${{ job.services.elastic.ports[9200] }}/
|
|
build-docker-images:
|
|
name: Build docker images
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Build the API docker image
|
|
run: 'docker build --file packages/api/Dockerfile .'
|