From acc4fc57107f627c9b8c64ca93677a93fba010bb Mon Sep 17 00:00:00 2001 From: Maxime Cannoodt Date: Wed, 3 Aug 2022 23:20:13 +0200 Subject: [PATCH] ci: :construction_worker: Add server test CI script --- .github/workflows/deploy.yaml | 27 +++++++++++++++++++++++++ .github/workflows/test.yaml | 38 +++++++++++++++++++++++++++++++++++ server/.env.test | 1 + 3 files changed, 66 insertions(+) create mode 100644 .github/workflows/deploy.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..af26144 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -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 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..9210dbe --- /dev/null +++ b/.github/workflows/test.yaml @@ -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 diff --git a/server/.env.test b/server/.env.test index 3c20cee..e75f7f5 100644 --- a/server/.env.test +++ b/server/.env.test @@ -1,4 +1,5 @@ DATABASE_URL="file:./test.sqlite" +FRONTEND_URL=https://example.com POST_LIMIT=50 POST_LIMIT_WINDOW_SECONDS=0.1