From 162e7300d579605d3c3677b65c43421aa9a3246b Mon Sep 17 00:00:00 2001 From: TheOneWithTheBraid Date: Mon, 28 Nov 2022 07:12:40 +0100 Subject: [PATCH] chore: use Famedly runners Signed-off-by: TheOneWithTheBraid --- .gitlab-ci.yml | 100 +++++++++--------- integration_test/app_test.dart | 4 +- integration_test/synapse/data/homeserver.yaml | 2 +- integration_test/users.dart | 18 +++- linux/flutter/generated_plugin_registrant.cc | 4 + linux/flutter/generated_plugins.cmake | 1 + pubspec.lock | 2 +- pubspec.yaml | 2 +- ...ntegration-create-environment-variables.sh | 6 ++ scripts/integration-prepare-homeserver.sh | 37 ++++++- scripts/integration-server-conduit.sh | 6 +- scripts/integration-server-dendrite.sh | 6 +- scripts/integration-server-synapse.sh | 7 +- 13 files changed, 118 insertions(+), 77 deletions(-) create mode 100755 scripts/integration-create-environment-variables.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 23cf22f3..218dd80a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,18 +20,30 @@ code_analyze: artifacts: reports: codequality: code-quality-report.json + tags: + - docker + - famedly widget_test: stage: test script: [flutter test] + tags: + - docker + - famedly # the basic integration test configuration testing FLOSS builds on Synapse -.integration_test: +integration_test: image: registry.gitlab.com/famedly/company/frontend/flutter-dockerimages/integration/stable:${FLUTTER_VERSION} stage: test services: - name: docker:dind alias: docker + parallel: + matrix: + - HOMESERVER_IMPLEMENTATION: + - synapse + - dendrite + - conduit variables: # activate container-to-container networking FF_NETWORK_PER_BUILD: "true" @@ -41,82 +53,65 @@ widget_test: DOCKER_DRIVER: overlay2 # Disable TLS since we're running inside local network. DOCKER_TLS_CERTDIR: "" + HOMESERVER: "docker" before_script: # start AVD and keep running in background - scripts/integration-start-avd.sh & - scripts/integration-prepare-alpine.sh + # create test user environment variables + - source scripts/integration-create-environment-variables.sh # create Synapse instance - - scripts/integration-server-synapse.sh + - scripts/integration-server-${HOMESERVER_IMPLEMENTATION}.sh # properly set the homeserver IP and create test users - scripts/integration-prepare-homeserver.sh - # ensure the homeserver works - - curl docker:8008/_matrix/static/ 2> /dev/null | grep "It works! Synapse is running" script: - flutter pub get - flutter test integration_test - allow_failure: true tags: - - android + - docker + - famedly timeout: 20m + +# integration tests for Linux builds +.integration_test_linux: + extends: integration_test + script: + - apk add cmake ninja gtk+3.0-dev clang pkgconf xz-dev libsecret-dev jsoncpp-dev + - flutter pub get + - flutter test integration_test -d linux + # extending the default tests to test the Google-flavored builds -.integration_test_google: - extends: .integration_test +integration_test_proprietary: + extends: integration_test script: - git apply ./scripts/enable-android-google-services.patch - flutter pub get - flutter test integration_test - allow_failure: true -# extending the default tests to use Conduit as local homeserver -.integration_test_conduit: - extends: .integration_test - before_script: - # start AVD and keep running in background - - scripts/integration-start-avd.sh & - - scripts/integration-prepare-alpine.sh - # create Conduit instance - - scripts/integration-server-conduit.sh - # properly set the homeserver IP and create test users - - scripts/integration-prepare-homeserver.sh - # ensure the homeserver works - - curl docker:8008/_matrix/static/ 2> /dev/null | grep "M_NOT_FOUND" 1> /dev/null && echo "Conduit is running!" - allow_failure: true - -# extending the default tests to use Dendrite as local homeserver -.integration_test_dendrite: - extends: .integration_test - before_script: - # start AVD and keep running in background - - scripts/integration-start-avd.sh & - - scripts/integration-prepare-alpine.sh - # create Dendrite instance - - scripts/integration-server-dendrite.sh - # properly set the homeserver IP and create test users - - scripts/integration-prepare-homeserver.sh - # ensure the homeserver works - - curl docker:8008/_matrix/static/ 2> /dev/null | grep "404 page not found" 1> /dev/null && echo "Dendrite is running!" - allow_failure: true - -.release_mode_launches: +release_mode_launches: + parallel: + matrix: + - FLAVOR: + - floss + - proprietary image: registry.gitlab.com/famedly/company/frontend/flutter-dockerimages/integration/stable:${FLUTTER_VERSION} stage: test + before_script: + - | + if [ "$FLAVOR" == "proprietary" ]; then + git apply ./scripts/enable-android-google-services.patch + fi script: # start AVD and keep running in background - scripts/integration-start-avd.sh & # generate temporary release build configuration and ensure app launches - scripts/integration-check-release-build.sh - allow_failure: true tags: - - android + - docker + - famedly timeout: 20m -.release_mode_launches_google: - extends: .release_mode_launches - before_script: - - git apply ./scripts/enable-android-google-services.patch - allow_failure: true - build_web: stage: build before_script: @@ -144,7 +139,8 @@ build_android_debug: stage: build script: [./scripts/build-android-debug.sh] tags: - - android + - docker + - famedly artifacts: when: on_success paths: @@ -160,7 +156,8 @@ build_android_apk: - ./scripts/prepare-android-release.sh script: [./scripts/build-android-apk.sh] tags: - - android + - docker + - famedly artifacts: when: on_success paths: @@ -176,7 +173,8 @@ deploy_playstore_internal: - ./scripts/prepare-android-release.sh script: [./scripts/release-playstore-beta.sh] tags: - - android + - docker + - famedly artifacts: when: on_success paths: diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index 41e60a3b..7690b874 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -41,8 +41,8 @@ void main() { final inputs = find.byType(TextField); - await tester.enterText(inputs.first, Users.alice.name); - await tester.enterText(inputs.last, Users.alice.password); + await tester.enterText(inputs.first, Users.user1.name); + await tester.enterText(inputs.last, Users.user1.password); await tester.testTextInput.receiveAction(TextInputAction.done); }); }); diff --git a/integration_test/synapse/data/homeserver.yaml b/integration_test/synapse/data/homeserver.yaml index 091aa63d..b6963fd4 100644 --- a/integration_test/synapse/data/homeserver.yaml +++ b/integration_test/synapse/data/homeserver.yaml @@ -297,7 +297,7 @@ listeners: # If you plan to use a reverse proxy, please see # https://matrix-org.github.io/synapse/latest/reverse_proxy.html. # - - port: 8008 + - port: 80 tls: false type: http x_forwarded: false diff --git a/integration_test/users.dart b/integration_test/users.dart index e3ec06a6..c79e3d0f 100644 --- a/integration_test/users.dart +++ b/integration_test/users.dart @@ -1,8 +1,16 @@ +import 'dart:io'; + abstract class Users { const Users._(); - static const alice = User('alice', 'AliceInWonderland'); - static const bob = User('bob', 'JoWirSchaffenDas'); - static const trudy = User('trudy', 'HaveIBeenPwned'); + + static final user1 = User( + Platform.environment['USER1_NAME'] ?? 'alice', + Platform.environment['USER1_PW'] ?? 'AliceInWonderland', + ); + static final user2 = User( + Platform.environment['USER2_NAME'] ?? 'bob', + Platform.environment['USER2_PW'] ?? 'JoWirSchaffenDas', + ); } class User { @@ -12,5 +20,5 @@ class User { const User(this.name, this.password); } -// https://stackoverflow.com/a/33088657 -const homeserver = 'http://10.0.2.2:8008'; +final homeserver = + 'http://${Platform.environment['HOMESERVER'] ?? 'localhost'}'; diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 14d91e18..6badfc51 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,9 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin"); flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar); + g_autoptr(FlPluginRegistrar) flutter_webrtc_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterWebRTCPlugin"); + flutter_web_r_t_c_plugin_register_with_registrar(flutter_webrtc_registrar); g_autoptr(FlPluginRegistrar) handy_window_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "HandyWindowPlugin"); handy_window_plugin_register_with_registrar(handy_window_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 820f9381..6ec24fd0 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -8,6 +8,7 @@ list(APPEND FLUTTER_PLUGIN_LIST emoji_picker_flutter file_selector_linux flutter_secure_storage_linux + flutter_webrtc handy_window record_linux url_launcher_linux diff --git a/pubspec.lock b/pubspec.lock index c54b48c4..7e766784 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -685,7 +685,7 @@ packages: name: flutter_webrtc url: "https://pub.dartlang.org" source: hosted - version: "0.9.14" + version: "0.9.17" fuchsia_remote_debug_protocol: dependency: transitive description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index 1dc8fd8f..ed9ea4b6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -47,7 +47,7 @@ dependencies: flutter_secure_storage: ^6.0.0 flutter_typeahead: ^4.0.0 flutter_web_auth: ^0.5.0 - flutter_webrtc: 0.9.14 # Pinned because >0.9.14 add Linux support which lets build fail + flutter_webrtc: ^0.9.17 future_loading_dialog: ^0.2.3 geolocator: ^7.6.2 handy_window: ^0.1.6 diff --git a/scripts/integration-create-environment-variables.sh b/scripts/integration-create-environment-variables.sh new file mode 100755 index 00000000..d2b3a8fe --- /dev/null +++ b/scripts/integration-create-environment-variables.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +export USER1_NAME="alice" +export USER1_PW="AliceInWonderland" +export USER2_NAME="bob" +export USER2_PW="JoWirSchaffenDas" diff --git a/scripts/integration-prepare-homeserver.sh b/scripts/integration-prepare-homeserver.sh index 70fcb2f7..4170294b 100755 --- a/scripts/integration-prepare-homeserver.sh +++ b/scripts/integration-prepare-homeserver.sh @@ -1,8 +1,35 @@ #!/usr/bin/env bash -IP_ADDRESS="$(drill docker | grep -m 1 -P "\d+\.\d+\.\d+.\d+" | awk -F ' ' '{print $NF}')" -sed -i "s/10.0.2.2/$IP_ADDRESS/g" integration_test/users.dart +if [ -z $HOMESERVER ]; then + echo "Please ensure HOMESERVER environment variable is set to the IP or hostname of the homeserver." + exit 1 +fi +if [ -z $USER1_NAME ]; then + echo "Please ensure USER1_NAME environment variable is set to first user name." + exit 1 +fi +if [ -z $USER1_PW ]; then + echo "Please ensure USER1_PW environment variable is set to first user password." + exit 1 +fi +if [ -z $USER2_NAME ]; then + echo "Please ensure USER2_NAME environment variable is set to second user name." + exit 1 +fi +if [ -z $USER2_PW ]; then + echo "Please ensure USER2_PW environment variable is set to second user password." + exit 1 +fi -curl -XPOST -d '{"username":"alice", "password":"AliceInWonderland", "inhibit_login":true, "auth": {"type":"m.login.dummy"}}' "http://$IP_ADDRESS:8008/_matrix/client/r0/register" -curl -XPOST -d '{"username":"bob", "password":"JoWirSchaffenDas", "inhibit_login":true, "auth": {"type":"m.login.dummy"}}' "http://$IP_ADDRESS:8008/_matrix/client/r0/register" -curl -XPOST -d '{"username":"trudy", "password":"HaveIBeenPwned", "inhibit_login":true, "auth": {"type":"m.login.dummy"}}' "http://$IP_ADDRESS:8008/_matrix/client/r0/register" \ No newline at end of file +echo "Waiting for homeserver to be available... (GET http://$HOMESERVER/_matrix/client/v3/login)" + +while ! curl -XGET "http://$HOMESERVER/_matrix/client/v3/login" >/dev/null 2>/dev/null; do + sleep 2 +done + +echo "Homeserver is up." + +# create users + +curl -fS --retry 3 -XPOST -d "{\"username\":\"$USER1_NAME\", \"password\":\"$USER1_PW\", \"inhibit_login\":true, \"auth\": {\"type\":\"m.login.dummy\"}}" "http://$HOMESERVER/_matrix/client/r0/register" +curl -fS --retry 3 -XPOST -d "{\"username\":\"$USER2_NAME\", \"password\":\"$USER2_PW\", \"inhibit_login\":true, \"auth\": {\"type\":\"m.login.dummy\"}}" "http://$HOMESERVER/_matrix/client/r0/register" diff --git a/scripts/integration-server-conduit.sh b/scripts/integration-server-conduit.sh index 7e8ab7c6..f4b031f5 100755 --- a/scripts/integration-server-conduit.sh +++ b/scripts/integration-server-conduit.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash - docker run -d \ +docker run -d \ -e CONDUIT_SERVER_NAME="localhost" \ -e CONDUIT_PORT="8008" \ -e CONDUIT_DATABASE_BACKEND="rocksdb" \ @@ -9,6 +9,4 @@ -e CONDUIT_TRUSTED_SERVERS="[\"conduit.rs\"]" \ -e CONDUIT_MAX_CONCURRENT_REQUESTS="100" \ -e CONDUIT_LOG="info,rocket=off,_=off,sled=off" \ - --name conduit -p 8008:8008 matrixconduit/matrix-conduit:latest - -sleep 20 \ No newline at end of file + --name conduit -p 80:8008 matrixconduit/matrix-conduit:latest diff --git a/scripts/integration-server-dendrite.sh b/scripts/integration-server-dendrite.sh index d7389141..ee23da19 100755 --- a/scripts/integration-server-dendrite.sh +++ b/scripts/integration-server-dendrite.sh @@ -10,7 +10,5 @@ docker run --rm --entrypoint="" \ -tls-cert /mnt/server.crt \ -tls-key /mnt/server.key - docker run -d --volume="$(pwd)/integration_test/dendrite/data":/etc/dendrite:rw \ - --name dendrite -p 8008:8008 matrixdotorg/dendrite-monolith:latest -really-enable-open-registration - -sleep 20 \ No newline at end of file +docker run -d --volume="$(pwd)/integration_test/dendrite/data":/etc/dendrite:rw \ + --name dendrite -p 80:8008 matrixdotorg/dendrite-monolith:latest -really-enable-open-registration diff --git a/scripts/integration-server-synapse.sh b/scripts/integration-server-synapse.sh index 46cbc4f9..03d21847 100755 --- a/scripts/integration-server-synapse.sh +++ b/scripts/integration-server-synapse.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash -chown -R 991:991 integration_test/synapse -docker run -d --name synapse --user 991:991 --volume="$(pwd)/integration_test/synapse/data":/data:rw -p 8008:8008 matrixdotorg/synapse:latest -sleep 20 \ No newline at end of file +docker run -d --name synapse --tmpfs /data \ + --volume="$(pwd)/integration_test/synapse/data/homeserver.yaml":/data/homeserver.yaml:rw \ + --volume="$(pwd)/integration_test/synapse/data/localhost.log.config":/data/localhost.log.config:rw \ + -p 80:80 matrixdotorg/synapse:latest