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

[EMBR-4464] Hook Swift tests up to CI #84

Merged
merged 43 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e3f9815
(iOS unit test): adding schema for unit tests (packages/core/test-pro…
facostaembrace Aug 26, 2024
2086dfc
adding commands + changing config
facostaembrace Aug 26, 2024
15375bd
github workflow
facostaembrace Aug 26, 2024
0f1c878
corepack enabled
facostaembrace Aug 27, 2024
718414c
updating path
facostaembrace Aug 27, 2024
7a914f0
workflow test
facostaembrace Aug 27, 2024
6b21afb
yarn install
facostaembrace Aug 27, 2024
b6b5b29
installing global packages
facostaembrace Aug 28, 2024
e572288
improving with cache
facostaembrace Aug 29, 2024
639d8eb
using cache derived datta
facostaembrace Aug 29, 2024
42334d3
improving workflow
facostaembrace Aug 29, 2024
22823ba
revert podfile change
facostaembrace Aug 29, 2024
6cd2bcf
cache derived data
facostaembrace Aug 29, 2024
9661d3d
removing script phase
facostaembrace Aug 29, 2024
1be26ea
workflow test
facostaembrace Aug 29, 2024
98501e9
updating cache
facostaembrace Aug 30, 2024
54d0f6b
polishing workflow
facostaembrace Aug 30, 2024
88757cf
improving workflow
facostaembrace Aug 30, 2024
6ae4bea
fixing cache
facostaembrace Aug 30, 2024
698c5f7
yarn.lock instead of package.lock
facostaembrace Aug 30, 2024
8a1a812
cache invalidation
facostaembrace Aug 30, 2024
98beb31
ignoring build
facostaembrace Aug 30, 2024
ab0b39c
storing cache in another key
facostaembrace Aug 30, 2024
c778561
final cleanup + test
facostaembrace Aug 30, 2024
1c0a2a7
adding values to xcodebuild
facostaembrace Aug 30, 2024
1321368
removing
facostaembrace Aug 30, 2024
7a7893d
reverting changes
facostaembrace Sep 2, 2024
e05d71f
forcing install
facostaembrace Sep 2, 2024
882b155
testing codecoverage withouth derived data cached
facostaembrace Sep 2, 2024
c7be781
reintroding cache
facostaembrace Sep 2, 2024
4f32e0c
removing cache for node_modules + cocoapods
facostaembrace Sep 2, 2024
1260b0c
tweak for workflow + node script
facostaembrace Sep 4, 2024
3e2bb59
fix
facostaembrace Sep 4, 2024
162b043
fix
facostaembrace Sep 4, 2024
ac1c432
fix
facostaembrace Sep 4, 2024
48b183c
fix
facostaembrace Sep 4, 2024
77bc673
merge
facostaembrace Sep 4, 2024
d28002d
adding yarn intall
facostaembrace Sep 4, 2024
f436338
yarn.lock regenerated
facostaembrace Sep 4, 2024
332512b
fixing workflow
facostaembrace Sep 4, 2024
1c5ca52
yarn.lock
facostaembrace Sep 4, 2024
1b01ef8
DerivedData back to git ignore
facostaembrace Sep 4, 2024
e9f15ae
Update README.md
facostaembrace Sep 4, 2024
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
67 changes: 67 additions & 0 deletions .github/workflows/ios.unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: iOS Unit Tests

on:
push:
branches:
- master
- 5.0 # TBD remove particular branch
pull_request:
branches:
- 5.0 # TBD remove particular branch

jobs:
build:
strategy:
matrix:
node-version: [18.x]
os: [macos-latest]

runs-on: ${{ matrix.os }}
env:
IOS_TEST_OS: 17.5
IOS_TEST_PLATFORM: iOS Simulator
IOS_TEST_DEVICE: iPhone 15 Pro
IOS_TEST_SCHEME: RNEmbraceTests
IOS_TEST_SDK: iphonesimulator
IOS_TEST_PROJECT_PATH: packages/core/test-project
IOS_TEST_DERIVED_DATA_PATH: ~/Library/Developer/Xcode/DerivedData

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Node (${{ matrix.node-version }})
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"

- name: Enables corepack
run: corepack enable

- name: Cache Derived Data
uses: actions/cache@v3
with:
path: ${{ env.IOS_TEST_DERIVED_DATA_PATH }}
key: ${{env.IOS_TEST_SCHEME}}-Derived-Data-${{ runner.os }}-${{ hashFiles('**/*.xcodeproj/project.pbxproj, Podfile.lock') }}
restore-keys: |
${{env.IOS_TEST_SCHEME}}-Derived-Data-${{ runner.os }}

- name: Install Root Node Modules
run: yarn install

- name: Install Node Modules + CocoaPods Dependencies
run: |
cd ${{ env.IOS_TEST_PROJECT_PATH }}
yarn install
cd ios
pod install

- name: Run iOS Unit Tests
run: yarn run ios:test | xcbeautify

- name: Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
6 changes: 3 additions & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI
name: Js Unit Tests

on:
push:
Expand All @@ -14,12 +14,12 @@ jobs:

strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
node-version: [18.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Xcode
!**/*.xcodeproj
!**/*.pbxproj
!**/*.xcworkspacedata
!**/*.xcsettings
!**/*.xcscheme
*.pbxuser
!default.pbxuser
*.mode1v3
Expand Down
5 changes: 4 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@
"bug tracker"
],
"scripts": {
"build": "tsc"
"build": "tsc",
"ios:build:clean": "xcodebuild clean -workspace test-project/ios/RNEmbraceTestProject.xcworkspace -scheme RNEmbraceTests",
"ios:schemes": "xcodebuild -workspace test-project/ios/RNEmbraceTestProject.xcworkspace -list",
"ios:test": "xcodebuild test -workspace test-project/ios/RNEmbraceTestProject.xcworkspace -scheme RNEmbraceTests -sdk $IOS_TEST_SDK -enableCodeCoverage YES -destination \"platform=$IOS_TEST_PLATFORM,name=$IOS_TEST_DEVICE,OS=$IOS_TEST_OS\""
},
"devDependencies": {
"typescript": "^4.7.4"
Expand Down
28 changes: 26 additions & 2 deletions packages/core/test-project/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Usage
### Usage

From this directory (`packages/core/test-project`) install the required npm packages (`react-native`):

Expand Down Expand Up @@ -27,4 +27,28 @@ Once it's completed, open through `xcode` the `RNEmbraceTestProject.xcworkspace`

The goal here is to run the tests. From `xcode` go to `Product -> Test` or simple press `command + U` to start running the test suite.

NOTE: Simulator will be triggered but there is not such app there.
> Simulator will be triggered but there is not such app there.

Notice that you can run this suite using Node. The script placed in `packages/core/package.json` uses environment variables. These can be exported in your favorite terminal:

```bash
export IOS_TEST_PLATFORM="iOS Simulator"
export IOS_TEST_DEVICE="iPhone 15 Pro"
export IOS_TEST_OS="17.5"
export IOS_TEST_SDK="iphonesimulator"
```

Load those new environment variables to make sure they are correctly in place:

```bash
// depending on your terminal
source ~./bashrc
```

And now from the `packages/core` directory:

```bash
// back to the root `packages/core` directory
cd ..
yarn run ios:test
```
1 change: 0 additions & 1 deletion packages/core/test-project/ios/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace
.xcode.env.local

# Bundle artifacts
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test-project/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,7 @@ SPEC CHECKSUMS:
React-utils: 4476b7fcbbd95cfd002f3e778616155241d86e31
ReactCommon: ecad995f26e0d1e24061f60f4e5d74782f003f12
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: 2f71ecf38d934aecb366e686278102a51679c308
Yoga: ae3c32c514802d30f687a04a6a35b348506d411f

PODFILE CHECKSUM: 8a247e59201368a342e5530a540a10f61aa7e0f3

Expand Down
Loading
Loading