Skip to content

Commit

Permalink
chore(datastore): run integ tests in CI (#2182)
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Sheppard authored Oct 3, 2022
1 parent 4839c47 commit 7307233
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .github/composite_actions/fetch_backends/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ runs:
melos exec --scope=${{ inputs.scope }} ./tool/pull_test_backend.sh
shell: bash

- name: Undo any codegen changes from amplify pull
run: |
melos exec --scope=${{ inputs.scope }} "[ -d "lib/models" ] && git checkout lib/models/ || exit 0"
shell: bash

- name: Delete AWS profile
run: rm -rf ~/.aws
shell: bash
Expand Down
3 changes: 2 additions & 1 deletion .github/composite_actions/install_dependencies/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ runs:
channel: 'stable'
architecture: x64 # needed to prevent "Bad CPU type" error

# retry once to reduce flakiness
- name: Run Melos bootstrap
run: |
flutter pub global activate melos 2.4.0
melos bootstrap
melos bs || melos bs
shell: bash
18 changes: 13 additions & 5 deletions .github/workflows/amplify_integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ jobs:
strategy:
fail-fast: false
matrix:
scope: ["amplify_api_example", "amplify_storage_s3_example", "amplify_auth_cognito_example"]
scope:
- "amplify_api_example"
- "amplify_auth_cognito_example"
- "amplify_datastore_example"
- "amplify_storage_s3_example"
steps:
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
with:
Expand Down Expand Up @@ -52,11 +56,11 @@ jobs:
- name: Run Android integration tests
uses: reactivecircus/android-emulator-runner@e790971012b979513b4e2fe70d4079bc0ca8a1ae # 2.24.0
timeout-minutes: 25
timeout-minutes: 45
with:
# API levels 30+ too slow https://github.com/ReactiveCircus/android-emulator-runner/issues/222
api-level: 29
script: melos exec -c 1 --scope ${{ matrix.scope }} -- "deviceId=emulator-5554 retries=1 \$MELOS_ROOT_PATH/build-support/integ_test_android.sh"
script: melos exec -c 1 --scope ${{ matrix.scope }} -- "deviceId=emulator-5554 retries=1 small=true \$MELOS_ROOT_PATH/build-support/integ_test_android.sh"

ios:
runs-on: macos-latest
Expand All @@ -67,7 +71,11 @@ jobs:
strategy:
fail-fast: false
matrix:
scope: ["amplify_api_example", "amplify_storage_s3_example", "amplify_auth_cognito_example"]
scope:
- "amplify_api_example"
- "amplify_auth_cognito_example"
- "amplify_datastore_example"
- "amplify_storage_s3_example"
steps:
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # 2.4.0
with:
Expand Down Expand Up @@ -97,4 +105,4 @@ jobs:
- name: Run integration tests
run: |
melos exec -c 1 --scope ${{ matrix.scope }} -- "retries=1 \$MELOS_ROOT_PATH/build-support/integ_test_ios.sh"
melos exec -c 1 --scope ${{ matrix.scope }} -- "retries=1 small=true \$MELOS_ROOT_PATH/build-support/integ_test_ios.sh"
8 changes: 8 additions & 0 deletions build-support/integ_test_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ fi
DEFAULT_DEVICE_ID="sdk"
DEFAULT_ENABLE_CLOUD_SYNC="true"
DEFAULT_RETRIES=0
DEFAULT_SMALL="false"

while [ $# -gt 0 ]; do
case "$1" in
Expand Down Expand Up @@ -35,6 +36,7 @@ done
deviceId=${deviceId:-$DEFAULT_DEVICE_ID}
enableCloudSync=${enableCloudSync:-$DEFAULT_ENABLE_CLOUD_SYNC}
retries=${retries:-$DEFAULT_RETRIES}
small=${small:-$DEFAULT_SMALL}

declare -a testsList
declare -a resultsList
Expand Down Expand Up @@ -70,6 +72,12 @@ do
done

TEST_ENTRIES="integration_test/separate_integration_tests/*.dart"
# For small option (summarized) just test basic cloud operation.
if [ $small == "true" ]
then
TEST_ENTRIES="integration_test/separate_integration_tests/basic_model_operation_test.dart"
fi

for ENTRY in $TEST_ENTRIES; do
if [ ! -f "${ENTRY}" ]; then
continue
Expand Down
8 changes: 8 additions & 0 deletions build-support/integ_test_ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ fi
DEFAULT_DEVICE_ID="iPhone"
DEFAULT_ENABLE_CLOUD_SYNC="true"
DEFAULT_RETRIES=0
DEFAULT_SMALL="false"

while [ $# -gt 0 ]; do
case "$1" in
Expand Down Expand Up @@ -37,6 +38,7 @@ done
deviceId=${deviceId:-$DEFAULT_DEVICE_ID}
enableCloudSync=${enableCloudSync:-$DEFAULT_ENABLE_CLOUD_SYNC}
retries=${retries:-$DEFAULT_RETRIES}
small=${small:-$DEFAULT_SMALL}

declare -a testsList
declare -a resultsList
Expand Down Expand Up @@ -86,6 +88,12 @@ else
fi

TEST_ENTRIES="integration_test/separate_integration_tests/*.dart"
# For small option (summarized) just test basic cloud operation.
if [ $small == "true" ]
then
TEST_ENTRIES="integration_test/separate_integration_tests/basic_model_operation_test.dart"
fi

for ENTRY in $TEST_ENTRIES; do
if [ ! -f "${ENTRY}" ]; then
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void main() {
DateTime(0000, 01, 01, 00, 00, 00),
DateTime(1970, 01, 01, 00, 00, 00),
DateTime(2020, 01, 01, 00, 00, 00),
DateTime(2020, 01, 01, 23, 59, 59),
DateTime(2020, 01, 02, 23, 59, 59),
DateTime(2999, 12, 31, 23, 59, 59, 999, 999),
];
var models = values
Expand Down
4 changes: 4 additions & 0 deletions packages/amplify_datastore/example/tool/pull_test_backend.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -e

APP_ID=$DATASTORE_APP_ID ../../../build-support/pull_backend_by_app_id.sh

0 comments on commit 7307233

Please sign in to comment.