Skip to content

Commit

Permalink
feat: enhance CI workflows with storage path configuration and cachin…
Browse files Browse the repository at this point in the history
…g improvements
  • Loading branch information
absternator committed Dec 6, 2024
1 parent cc6778b commit 0473946
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 25 deletions.
23 changes: 8 additions & 15 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,27 +68,18 @@ jobs:
run: |
pwd
cp ./src/resources/config.json.in.development ./src/resources/config.json
- name: Restore DB Cache
- name: Restore storage cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/storage/dbs
key: db-cache-${{ runner.os }}
path: ${{ env.STORAGE_PATH }}
key: dbs-cache-${{ runner.os }}
restore-keys: |
db-cache-
- name: run dependencies
dbs-cache-
- name: run all components
working-directory: .
run: ./scripts/run_dependencies ${{ github.workspace }}/storage/dbs
- name: run server
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: Save DB Cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/storage/dbs
key: db-cache-${{ runner.os }}
- name: stop all components
working-directory: .
run: ./scripts/stop_test server-only
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*

## 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
28 changes: 19 additions & 9 deletions scripts/run_dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@ set -ex
HERE=$(realpath "$(dirname $0)")
. $HERE/common

docker volume create $VOLUME

if [ -z "$1" ]; then
echo "No mount path provided, using default: $VOLUME"
BIND_MOUNT=$VOLUME
else
BIND_MOUNT=$1
while [ $# -gt 0 ]; do
case "$1" in
-mount)
MOUNT="$2"
shift 2
;;
*)
shift
;;
esac
done
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 $BIND_MOUNT:/beebop/storage \
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
Expand All @@ -23,14 +33,14 @@ 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 $BIND_MOUNT:/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 $BIND_MOUNT:/beebop/storage \
-v $MOUNT:/beebop/storage \
-p $PORT:5000 \
ghcr.io/bacpop/beebop-py:$API_IMAGE
15 changes: 15 additions & 0 deletions scripts/run_test
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ set -e

HERE=$(realpath "$(dirname $0)")

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
npm install pm2

Expand Down

0 comments on commit 0473946

Please sign in to comment.