Skip to content

Commit 5ab856f

Browse files
committed
e2e tests use load script
1 parent f964744 commit 5ab856f

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

.github/workflows/e2e-tests.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ jobs:
1919
playwright: true
2020

2121
- name: Load Local D1 Database
22-
working-directory: ./workers-api
22+
# working-directory: ./workers-api
2323
env:
2424
WRANGLER_LOG: error # yarn run wrangler d1 prints out too much information so only log errors
2525
run: |
2626
yarn run build # Creates ../data/data/db.sql
27-
yarn run wrangler d1 execute DB --file ../data/data/db.sql --local --config wrangler.local.toml
27+
# NOTE: revert this line if wrangler ever gets fixed. Also change back the working directory above
28+
# yarn run wrangler d1 execute DB --file ../data/data/db.sql --local --config wrangler.local.toml
29+
./bin/load_entities.sh .
2830
2931
- name: Run e2e Tests
3032
working-directory: ./dashboard
@@ -38,4 +40,5 @@ jobs:
3840
export FOLDER=playwright_$(date +"%Y-%m-%d_%H:%M:%S")_${GITHUB_RUN_ID}_${GITHUB_RUN_NUMBER}
3941
mv test-results ${FOLDER}
4042
gsutil -m cp -R ${FOLDER} gs://${{ secrets.TEST_ARTIFACT_BUCKET_NAME }}/e2e-tests/${FOLDER}
41-
shell: bash
43+
shell: bash
44+

bin/load_entities.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#!/usr/bin/env bash
22

3+
# This loads all of the entities into the D1 database.
4+
# This script shouldn't be necessary, but wrangler is extremely unstable and complains when processing
5+
# too much data at once.
6+
# So instead, we split the sql file into batches of 250 statements and load them one at a time.
7+
# If wrangler ever gets fixed, we can remote this script.
8+
# - Keegan Smith 09/25
9+
310
if [ "$#" -ne 1 ]; then
411
echo "Usage: $0 <root_directory>"
512
exit 1
@@ -34,13 +41,13 @@ for ((i=0; i<TOTAL; i+=BATCH_SIZE)); do
3441
npx wrangler d1 execute DB --command="$stmt" --local --config "${WORKER_DIR}/wrangler.local.toml"
3542
EXIT_CODE=$?
3643
if [ $EXIT_CODE -ne 0 ]; then
37-
echo "Statement failed:"
44+
echo "Statement failed to load:"
3845
echo "$stmt"
3946
exit $EXIT_CODE
4047
fi
4148
done
4249
fi
4350
done
44-
echo "All statements executed successfully."
51+
echo "All statements executed successfully."
4552

4653

0 commit comments

Comments
 (0)