diff --git a/.github/workflows/unit_tests_enterprise.yml b/.github/workflows/unit_tests_enterprise.yml new file mode 100644 index 0000000000..8c195bf915 --- /dev/null +++ b/.github/workflows/unit_tests_enterprise.yml @@ -0,0 +1,64 @@ +name: Unit Tests (Enterprise) + +on: + workflow_dispatch: + + push: + branches: [ develop ] + + pull_request: + +jobs: + tests: + name: Tests (Enterprise) + runs-on: macos-14 + + # Skip in forks + if: github.repository == 'element-hq/element-x-ios' + + concurrency: + # Only allow a single run of this workflow on each branch, automatically cancelling older runs. + group: ${{ format('unit-tests-enterprise{0}', github.ref) }} + cancel-in-progress: true + + steps: + - uses: nschloe/action-cached-lfs-checkout@v1 + with: + submodules: recursive + token: ${{ secrets.ELEMENT_BOT_TOKEN }} + + - uses: actions/cache@v4 + with: + path: vendor/bundle + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gems- + + - name: Setup environment + run: source ci_scripts/ci_common.sh && setup_github_actions_environment + + - name: Configure Enterprise + run: bundle exec fastlane config_enterprise + env: + MAPLIBRE_API_KEY: WeDontNeedOneForUnitTests + + - name: SwiftFormat + run: swiftformat --lint . + + - name: Run tests + run: bundle exec fastlane unit_tests skip_previews:true + + - name: Zip results # for faster upload + if: failure() + working-directory: fastlane/test_output + run: zip -r UnitTests.zip UnitTests.xcresult + + - name: Archive artifacts + uses: actions/upload-artifact@v4 + # We only care about artefacts if the tests fail + if: failure() + with: + name: Results + path: fastlane/test_output/UnitTests.zip + retention-days: 1 + if-no-files-found: ignore diff --git a/ElementX/Sources/Application/AppSettings.swift b/ElementX/Sources/Application/AppSettings.swift index 2bc5a9d6f6..d97bbfdba1 100644 --- a/ElementX/Sources/Application/AppSettings.swift +++ b/ElementX/Sources/Application/AppSettings.swift @@ -214,14 +214,14 @@ final class AppSettings { #if DEBUG /// The configuration to use for analytics during development. Set `isEnabled` to false to disable analytics in debug builds. /// **Note:** Analytics are disabled by default for forks. If you are maintaining a fork, set custom configurations. - let analyticsConfiguration = AnalyticsConfiguration(isEnabled: InfoPlistReader.main.bundleIdentifier.starts(with: "io.element.elementx"), + let analyticsConfiguration = AnalyticsConfiguration(isEnabled: InfoPlistReader.main.bundleIdentifier.starts(with: "io.element."), host: "https://posthog.element.dev", apiKey: "phc_VtA1L35nw3aeAtHIx1ayrGdzGkss7k1xINeXcoIQzXN", termsURL: "https://element.io/cookie-policy") #else /// The configuration to use for analytics. Set `isEnabled` to false to disable analytics. /// **Note:** Analytics are disabled by default for forks. If you are maintaining a fork, set custom configurations. - let analyticsConfiguration = AnalyticsConfiguration(isEnabled: InfoPlistReader.main.bundleIdentifier.starts(with: "io.element.elementx"), + let analyticsConfiguration = AnalyticsConfiguration(isEnabled: InfoPlistReader.main.bundleIdentifier.starts(with: "io.element."), host: "https://posthog.element.io", apiKey: "phc_Jzsm6DTm6V2705zeU5dcNvQDlonOR68XvX2sh1sEOHO", termsURL: URL("https://element.io/cookie-policy")) diff --git a/ci_scripts/ci_post_clone.sh b/ci_scripts/ci_post_clone.sh index 9d6ce0a7ad..8be0e58cfb 100755 --- a/ci_scripts/ci_post_clone.sh +++ b/ci_scripts/ci_post_clone.sh @@ -9,8 +9,7 @@ install_xcode_cloud_brew_dependencies if [ "$CI_WORKFLOW" = "Nightly" ]; then bundle exec fastlane config_nightly build_number:"$CI_BUILD_NUMBER" elif [ "$CI_WORKFLOW" = "Enterprise" ]; then - # Not sure what Xcode Cloud does, might need to also - # git submodule update --init --recursive + # Xcode Cloud automatically fetches the submodule. bundle exec fastlane config_enterprise else bundle exec fastlane config_production diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 2018f86105..048c5447ce 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -79,7 +79,7 @@ lane :alpha do upload_to_browserstack() end -lane :unit_tests do +lane :unit_tests do |options| run_tests( scheme: "UnitTests", device: 'iPhone 15', @@ -88,13 +88,15 @@ lane :unit_tests do number_of_retries: 3, ) - run_tests( - scheme: "PreviewTests", - device: 'iPhone 15', - result_bundle: true, - number_of_retries: 3, - xcargs: '-skipPackagePluginValidation', - ) + if !options[:skip_previews] + run_tests( + scheme: "PreviewTests", + device: 'iPhone 15', + result_bundle: true, + number_of_retries: 3, + xcargs: '-skipPackagePluginValidation', + ) + end # We use xcresultparser in the workflow to collect coverage from both result bundles. end