Files
standardnotes-server/.github/workflows/pr.yml
2023-02-06 14:59:24 +01:00

194 lines
4.6 KiB
YAML

name: Pull Request
on:
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache build
id: cache-build
uses: actions/cache@v3
with:
path: |
packages/**/dist
key: ${{ runner.os }}-build-${{ github.sha }}
- name: Set up Node
uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
node-version-file: '.nvmrc'
- name: Build
run: yarn build
lint:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Cache build
id: cache-build
uses: actions/cache@v3
with:
path: |
packages/**/dist
${{ needs.build.outputs.temp_dir }}
key: ${{ runner.os }}-build-${{ github.sha }}
- name: Set up Node
uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
node-version-file: '.nvmrc'
- name: Build
if: steps.cache-build.outputs.cache-hit != 'true'
run: yarn build
- name: Lint
run: yarn lint
test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Cache build
id: cache-build
uses: actions/cache@v3
with:
path: |
packages/**/dist
${{ needs.build.outputs.temp_dir }}
key: ${{ runner.os }}-build-${{ github.sha }}
- name: Set up Node
uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
node-version-file: '.nvmrc'
- name: Build
if: steps.cache-build.outputs.cache-hit != 'true'
run: yarn build
- name: Test
run: yarn test
e2e:
runs-on: ubuntu-latest
needs: build
services:
snjs:
image: standardnotes/snjs
ports:
- 9001:9001
db:
image: mysql:8
env:
MYSQL_DATABASE: standard_notes_db
MYSQL_USER: std_notes_user
MYSQL_PASSWORD: changeme123
MYSQL_ROOT_PASSWORD: changeme123
ports:
- 3306:3306
cache:
image: redis:6.0-alpine
ports:
- 6379:6379
mock-event-publisher:
image: standardnotes/mock-event-publisher
ports:
- 3124:3000
env:
LOG_LEVEL: debug
NODE_ENV: production
VERSION: snjs-test
SNS_TOPIC_ARN: arn:aws:sns:us-east-1:000000000000:payments-local-topic
SNS_ENDPOINT: http://localstack:4566
SNS_DISABLE_SSL: true
SNS_SECRET_ACCESS_KEY: x
SNS_ACCESS_KEY_ID: x
SNS_AWS_REGION: us-east-1
NEW_RELIC_ENABLED: false
options: >-
--name "mock-event-publisher"
steps:
- uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
node-version-file: '.nvmrc'
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Build Docker image for E2E testing
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: false
tags: standardnotes/server:${{ github.sha }}
- name: Run Server
run: docker run -d standardnotes/server:${{ github.sha }}
env:
EXPOSED_PORT: 3123
EXPOSED_FILES_SERVER_PORT: 3125
PUBLIC_FILES_SERVER_URL: http://localhost:3125
DB_HOST: localhost
DB_PORT: 3306
DB_USERNAME: std_notes_user
DB_PASSWORD: changeme123
DB_DATABASE: standard_notes_db
REDIS_PORT: 6379
REDIS_HOST: localhost
AUTH_SERVER_ACCESS_TOKEN_AGE: 4
AUTH_SERVER_REFRESH_TOKEN_AGE: 10
AUTH_SERVER_EPHEMERAL_SESSION_AGE: 300
SYNCING_SERVER_REVISIONS_FREQUENCY: 5
AUTH_SERVER_LOG_LEVEL: debug
SYNCING_SERVER_LOG_LEVEL: debug
FILES_SERVER_LOG_LEVEL: debug
REVISIONS_SERVER_LOG_LEVEL: debug
API_GATEWAY_LOG_LEVEL: debug
- name: Wait for server to start
run: docker/wait-for.sh localhost 3123
- name: Run E2E Test Suite
run: yarn dlx mocha-headless-chrome --timeout 1200000 -f http://localhost:9001/mocha/test.html