Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup unit tests for Enterprise. #2984

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/unit_tests_enterprise.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions ElementX/Sources/Application/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
3 changes: 1 addition & 2 deletions ci_scripts/ci_post_clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 10 additions & 8 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand Down
Loading