2022-08-19 17:42:03 +03:00
|
|
|
name: Unit Tests
|
2022-04-28 09:31:29 +03:00
|
|
|
|
|
|
|
on:
|
2022-08-19 17:42:03 +03:00
|
|
|
workflow_dispatch:
|
|
|
|
|
2022-04-28 09:31:29 +03:00
|
|
|
push:
|
|
|
|
branches: [ develop ]
|
2022-08-19 17:42:03 +03:00
|
|
|
|
2022-04-28 09:31:29 +03:00
|
|
|
pull_request:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
tests:
|
|
|
|
name: Tests
|
2024-03-12 13:08:54 +02:00
|
|
|
runs-on: macos-14
|
2022-04-28 09:31:29 +03:00
|
|
|
|
|
|
|
concurrency:
|
2024-03-22 15:56:00 +02:00
|
|
|
# Only allow a single run of this workflow on each branch, automatically cancelling older runs.
|
|
|
|
group: ${{ format('unit-tests-{0}', github.ref) }}
|
2022-04-28 09:31:29 +03:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
steps:
|
2024-03-25 11:23:58 +02:00
|
|
|
- uses: nschloe/action-cached-lfs-checkout@v1
|
2022-08-19 17:42:03 +03:00
|
|
|
|
2024-05-17 21:23:02 +00:00
|
|
|
- uses: actions/cache@v4
|
2022-04-28 09:31:29 +03:00
|
|
|
with:
|
|
|
|
path: vendor/bundle
|
|
|
|
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-gems-
|
|
|
|
|
2023-02-13 14:53:01 +02:00
|
|
|
- name: Setup environment
|
|
|
|
run:
|
|
|
|
source ci_scripts/ci_common.sh && setup_github_actions_environment
|
2022-04-28 09:31:29 +03:00
|
|
|
|
2023-02-13 14:53:01 +02:00
|
|
|
- name: SwiftFormat
|
|
|
|
run:
|
|
|
|
swiftformat --lint .
|
2023-11-21 16:25:18 +00:00
|
|
|
|
2022-05-05 09:28:28 +03:00
|
|
|
- name: Run tests
|
2022-08-19 17:42:03 +03:00
|
|
|
run: bundle exec fastlane unit_tests
|
2023-09-20 14:07:18 +02:00
|
|
|
|
2024-03-07 18:55:02 +00:00
|
|
|
- name: Zip results # for faster upload
|
|
|
|
if: failure()
|
|
|
|
working-directory: fastlane/test_output
|
|
|
|
run: zip -r UnitTests.zip UnitTests.xcresult PreviewTests.xcresult
|
|
|
|
|
2023-09-20 14:07:18 +02:00
|
|
|
- name: Archive artifacts
|
2024-05-20 10:17:57 +00:00
|
|
|
uses: actions/upload-artifact@v4
|
2024-03-07 18:55:02 +00:00
|
|
|
# We only care about artefacts if the tests fail
|
2023-09-20 14:07:18 +02:00
|
|
|
if: failure()
|
|
|
|
with:
|
2024-03-07 18:55:02 +00:00
|
|
|
name: Results
|
|
|
|
path: fastlane/test_output/UnitTests.zip
|
2023-09-20 14:07:18 +02:00
|
|
|
retention-days: 1
|
|
|
|
if-no-files-found: ignore
|
2022-08-11 15:02:47 +03:00
|
|
|
|
2024-02-22 15:13:52 +00:00
|
|
|
- name: Collect coverage
|
|
|
|
run: |
|
2024-02-28 18:01:20 +00:00
|
|
|
xcresultparser -q -o cobertura -t ElementX -p $(pwd) fastlane/test_output/UnitTests.xcresult > fastlane/test_output/unit-cobertura.xml
|
|
|
|
xcresultparser -q -o cobertura -t ElementX -p $(pwd) fastlane/test_output/PreviewTests.xcresult > fastlane/test_output/preview-cobertura.xml
|
2024-02-22 15:13:52 +00:00
|
|
|
|
2022-05-09 10:03:23 +03:00
|
|
|
- name: Upload coverage to Codecov
|
2024-09-03 15:15:28 +00:00
|
|
|
uses: codecov/codecov-action@v4
|
2022-10-14 16:21:31 +03:00
|
|
|
with:
|
2024-04-22 14:59:51 +02:00
|
|
|
fail_ci_if_error: true
|
|
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
2022-10-14 16:21:31 +03:00
|
|
|
flags: unittests
|