Skip to content

Commit

Permalink
Setup unit tests for Enterprise.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Jun 28, 2024
1 parent 3cc4145 commit 8e803e8
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 10 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/unit_tests_enterprise.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Unit Tests (Enterprise)

on:
workflow_dispatch:

push:
branches: [ develop ]

pull_request:

jobs:
tests:
name: Tests (Enterprise)
runs-on: macos-14

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: actions/checkout@v4

- 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

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

0 comments on commit 8e803e8

Please sign in to comment.