ci: 👷 Add server test CI script

This commit is contained in:
Maxime Cannoodt 2022-08-03 23:20:13 +02:00
parent 51ac5e2f14
commit acc4fc5710
3 changed files with 66 additions and 0 deletions

27
.github/workflows/deploy.yaml vendored Normal file
View File

@ -0,0 +1,27 @@
name: Test and deploy server and webapp
on:
push:
branches: [master]
jobs:
# test:
# name: Run tests
# uses: mcndt/noteshare.space/.github/workflows/test.yaml@master
deploy:
name: Deploy
# needs: [test]
runs-on: ubuntu-latest
steps:
- name: Deploy using ssh
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
port: 22
script: |
cd /home/noteshare/noteshare.space
git pull origin master
docker compose -f docker-compose.server.yml build
docker compose -f docker-compose.server.yml up -d

38
.github/workflows/test.yaml vendored Normal file
View File

@ -0,0 +1,38 @@
name: Test server and webapp
on:
workflow_call:
# inputs:
# secrets:
pull_request:
branches: [master]
jobs:
test-server:
name: Server tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./server
steps:
- uses: actions/checkout@v3
- name: Unit and integration tests
uses: actions/setup-node@v3
with:
node-version: 16.x
- run: npm ci
- run: npm run test
test-webapp:
name: Webapp tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./webapp
steps:
- uses: actions/checkout@v3
- name: Unit and integration tests
uses: actions/setup-node@v3
with:
node-version: 16.x
- run: npm ci
- run: npm run test

View File

@ -1,4 +1,5 @@
DATABASE_URL="file:./test.sqlite"
FRONTEND_URL=https://example.com
POST_LIMIT=50
POST_LIMIT_WINDOW_SECONDS=0.1