Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache Beebop databases in CI #86

Merged
merged 11 commits into from
Dec 9, 2024
12 changes: 10 additions & 2 deletions .github/workflows/jestCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:

unit_and_integration_backend:
runs-on: ubuntu-latest
env:
STORAGE_PATH: ${{ github.workspace }}/storage/dbs
defaults:
run:
working-directory: ./app/server
Expand Down Expand Up @@ -66,10 +68,16 @@ jobs:
run: |
pwd
cp ./src/resources/config.json.in.development ./src/resources/config.json
- name: Restore storage cache
uses: actions/cache@v3
with:
path: ${{ env.STORAGE_PATH }}
key: dbs-cache-${{ runner.os }}
restore-keys: |
dbs-cache-
- name: run all components
working-directory: .
run: ./scripts/run_test server-only

run: ./scripts/run_test server-only -mount ${{ env.STORAGE_PATH }}
- name: Run unit and integration tests
run: npm run test
- name: stop all components
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/playwrightCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
playwright-tests:
timeout-minutes: 60
runs-on: ubuntu-latest
env:
STORAGE_PATH: ${{ github.workspace }}/storage/dbs
strategy:
fail-fast: false
matrix:
Expand All @@ -26,6 +28,13 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Restore storage cache
uses: actions/cache@v3
with:
path: ${{ env.STORAGE_PATH }}
key: dbs-cache-${{ runner.os }}
restore-keys: |
dbs-cache-
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand All @@ -38,7 +47,7 @@ jobs:
cp ./app/server/src/resources/config.json.in.development ./app/server/src/resources/config.json
- name: Run all components
working-directory: .
run: ./scripts/run_test
run: ./scripts/run_test -mount ${{ env.STORAGE_PATH }}
- name: Install playwright
working-directory: ./app/client-v2
run: npx playwright install --with-deps
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ You can also run everything outside pm2, by separately running:
- `./scripts/run_server`
- `./scripts/run_client`

*Note: If you wish to override the volune with a custom bind mount pass in -mount {MOUNT_NAME} into `run_test` script*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*Note: If you wish to override the volune with a custom bind mount pass in -mount {MOUNT_NAME} into `run_test` script*
*Note: If you wish to override the storage volume with a custom bind mount pass in -mount {MOUNT_NAME} into `run_test` script*


## Config
Config for the front-end lives in `./app/client/src/settings` and by default webpack (via the vue-cli) will use the config
defined in `./app/client/src/settings/development`; this gets overriden by setting an env var called `BUILD_TARGET` - see `./proxy/Dockerfile`.
Expand Down
7 changes: 7 additions & 0 deletions scripts/common
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
#!/usr/bin/env bash
export API_IMAGE="main"

NETWORK=beebop_nw
VOLUME=beebop-storage
NAME_REDIS=beebop-redis
NAME_API=beebop-py-api
NAME_WORKER=beebop-py-worker
PORT=5000
33 changes: 22 additions & 11 deletions scripts/run_dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,43 @@ set -ex
HERE=$(realpath "$(dirname $0)")
. $HERE/common

NETWORK=beebop_nw
VOLUME=beebop-storage
NAME_REDIS=beebop-redis
NAME_API=beebop-py-api
NAME_WORKER=beebop-py-worker
PORT=5000

docker volume create $VOLUME
docker run --rm -v $VOLUME:/beebop/storage \
while [ $# -gt 0 ]; do
case "$1" in
-mount)
MOUNT="$2"
shift 2
;;
*)
shift
;;
esac
done
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is shared logic with run _test to find the mount arg - could pull this out into a shared script - or just use a positional arg if it's easier! But it's quite nice and clear to have a named arg.

if [ -z "$MOUNT" ]; then
echo "No mount path provided, using default: $VOLUME"
MOUNT=$VOLUME
docker volume create $VOLUME
fi

docker network create $NETWORK > /dev/null || /bin/true

docker run --rm -v $MOUNT:/beebop/storage \
--pull always \
ghcr.io/bacpop/beebop-py:$API_IMAGE \
./scripts/download_databases --refs # remove --refs to download all databases
docker network create $NETWORK > /dev/null || /bin/true

docker run -d --rm --name $NAME_REDIS --network=$NETWORK -p 6379:6379 redis:5.0
docker run -d --rm --name $NAME_WORKER --network=$NETWORK \
--pull always \
--env=REDIS_HOST="$NAME_REDIS" \
-v $VOLUME:/beebop/storage \
-v $MOUNT:/beebop/storage \
ghcr.io/bacpop/beebop-py:$API_IMAGE rqworker

docker run -d --rm --name $NAME_API --network=$NETWORK \
--pull always \
--env=REDIS_HOST="$NAME_REDIS" \
--env=STORAGE_LOCATION="./storage" \
--env=DBS_LOCATION="./storage/dbs" \
-v $VOLUME:/beebop/storage \
-v $MOUNT:/beebop/storage \
-p $PORT:5000 \
ghcr.io/bacpop/beebop-py:$API_IMAGE
15 changes: 14 additions & 1 deletion scripts/run_test
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
set -e

HERE=$(realpath "$(dirname $0)")
. $HERE/run_dependencies

while [ $# -gt 0 ]; do
case "$1" in
-mount)
MOUNT="$2"
shift 2
;;
*)
shift
;;
esac
done
. $HERE/run_dependencies -mount $MOUNT



npm --prefix app/server ci
Expand Down
Loading