Skip to content

Commit

Permalink
test: server end-to-end (#886)
Browse files Browse the repository at this point in the history
We couldn't add end-to-end tests for the server until `@comapeo/server`
was released (see [#952] for more details). Now that it's out, we can
add them!

[#952]: #952

Co-Authored-By: Gregor MacLennan <[email protected]>
  • Loading branch information
EvanHahn and gmaclennan authored Oct 31, 2024
1 parent a4dabd2 commit 398bfb9
Show file tree
Hide file tree
Showing 5 changed files with 845 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/fly-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Cleans up orphaned test apps on Fly

# TODO: check app creation date - could destroy an app during a test run
# See <https://github.com/digidem/comapeo-core/issues/914>.

name: Fly Cleanup
on:
workflow_dispatch:
schedule:
- cron: '0 5 * * *' # Every day at 5am UTC
jobs:
cleanup:
name: Cleanup Orphaned Apps
runs-on: ubuntu-latest
concurrency: deploy-group # optional: ensure only one action runs at a time
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
run: |
fly apps list -q -o digidem | while IFS= read -r name; do
# Trim leading and trailing whitespace from $name
name=$(echo "$name" | xargs)
# Check if the name starts with 'comapeo-cloud-test-'
if [[ $name == comapeo-cloud-test-* ]]; then
# Call the fly destroy command with the name
fly apps destroy -y "$name"
fi
done
26 changes: 26 additions & 0 deletions .github/workflows/server-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Server e2e cloud test

on:
push:
branches: [main]
pull_request:

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: npm ci
- run: npm run build --if-present
- run: node --test ./test-e2e/server.js
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
REMOTE_TEST_SERVER: true
Loading

0 comments on commit 398bfb9

Please sign in to comment.