Setup unit tests for Enterprise. (#2984)

* Fix Analytics on Enterprise.
This commit is contained in:
Doug 2024-07-01 12:34:47 +01:00 committed by GitHub
parent 5086cd089b
commit 1178561853
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 77 additions and 12 deletions

View File

@ -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

View File

@ -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"))

View File

@ -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

View File

@ -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