Skip to content

Commit

Permalink
Merge pull request #4908 from realm/iamer/ios-test-ccache
Browse files Browse the repository at this point in the history
use ccache in test job to speed up test app builds
  • Loading branch information
iamer authored Nov 8, 2022
2 parents ca6a035 + 8794ac4 commit c513666
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 13 deletions.
40 changes: 33 additions & 7 deletions .github/workflows/pr-realm-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ jobs:
run: |
echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
# in CI file timestamps change with every run so instead rely on file content hashing
# https://reactnative.dev/docs/build-speed#using-this-approach-on-a-ci
- name: Configure ccache
if: ${{ runner.os != 'Windows' }}
run: ccache --set-config="compiler_check=content"
Expand Down Expand Up @@ -167,7 +169,7 @@ jobs:
MOCHA_REMOTE_EXIT_ON_ERROR: true
SPAWN_LOGCAT: true
# Pin the Xcode version
DEVELOPER_DIR: /Applications/Xcode_12.5.1.app
DEVELOPER_DIR: /Applications/Xcode_13.1.app
runs-on: ${{ matrix.variant.runner }}
strategy:
fail-fast: false
Expand All @@ -179,12 +181,12 @@ jobs:
#- { os: windows, target: test, runner: windows-latest, environment: node}
#- { os: windows, target: "test:main", runner: windows-latest, environment: electron }
#- { os: windows, target: "test:renderer", runner: windows-latest, environment: electron }
- { os: darwin, target: "test:main", runner: macos-11, environment: electron }
- { os: darwin, target: "test:renderer", runner: macos-11, environment: electron }
- { os: darwin, target: test, runner: macos-11, environment: node }
- { os: android, target: "test:android", runner: macos-11, environment: react-native }
- { os: ios, target: "test:ios", runner: macos-11, environment: react-native }
#- { os: ios, target: "test:catalyst", runner: macos-11, environment: react-native }
- { os: darwin, target: "test:main", runner: macos-latest, environment: electron }
- { os: darwin, target: "test:renderer", runner: macos-latest, environment: electron }
- { os: darwin, target: test, runner: macos-latest, environment: node }
- { os: android, target: "test:android", runner: macos-latest, environment: react-native, arch: "armeabi-v7a" }
- { os: ios, target: "test:ios", runner: macos-latest, environment: react-native, arch: "apple" }
#- { os: ios, target: "test:catalyst", runner: macos-latest, environment: react-native, arch: "apple" }
timeout-minutes: 60
steps:
- name: Generate Cluster Differentiator
Expand Down Expand Up @@ -240,6 +242,19 @@ jobs:
if: ${{ runner.os == 'Windows' }}
uses: ilammy/msvc-dev-cmd@v1

- name: ccache
uses: hendrikmuhs/ccache-action@v1
if: ${{ matrix.variant.environment == 'react-native' }}
with:
key: ${{ runner.os }}-${{ matrix.variant.os }}-${{ matrix.variant.arch }}
max-size: '2.0G'

# in CI file timestamps change with every run so instead rely on file content hashing
# https://reactnative.dev/docs/build-speed#using-this-approach-on-a-ci
- name: Configure ccache
if: ${{ matrix.variant.environment == 'react-native' }}
run: ccache --set-config="compiler_check=content"

- name: Install IOS tools
if: ${{ (matrix.variant.os == 'ios') }}
run: |
Expand Down Expand Up @@ -295,6 +310,17 @@ jobs:
timeout-minutes: 45
run: ${{ env.wrapper }} npm run ${{ matrix.variant.target}} --prefix integration-tests/environments/${{ matrix.variant.environment }}

- name: Setup Java Gradle cache for android test app
if: ${{ (matrix.variant.os == 'android') }}
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup Android Emulator cache
if: ${{ (matrix.variant.os == 'android') }}
uses: actions/[email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=false
newArchEnabled=false

# Gradle will try to reuse outputs from previous builds for all builds
# https://docs.gradle.org/current/userguide/build_cache.html#sec:build_cache_enable
org.gradle.caching=true
8 changes: 5 additions & 3 deletions integration-tests/environments/react-native/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ target 'RealmReactNativeTests' do
config.build_settings['CODE_SIGN_IDENTITY[sdk=macosx*]'] = '-'
end
end
# Applying https://github.com/facebook/folly/issues/1470#issuecomment-943123653
if target.name == "RCT-Folly"
target.build_configurations.each do |config|
target.build_configurations.each do |config|
if target.name == "RCT-Folly"
# Applying https://github.com/facebook/folly/issues/1470#issuecomment-943123653
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'FOLLY_HAVE_CLOCK_GETTIME=1']
end
config.build_settings['CC'] = "../../../../../scripts/ccache-clang.sh"
config.build_settings['CXX'] = "../../../../../scripts/ccache-clang++.sh"
end
end
end
Expand Down
9 changes: 8 additions & 1 deletion scripts/ccache-clang++.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#!/bin/sh
if command -v ccache &> /dev/null; then
# reference for xcode specific cacche settings: reactnative docs and ccache manpage
# https://reactnative.dev/docs/build-speed#xcode-specific-setup
# https://ccache.dev/manual/4.3.html
export CCACHE_MAXSIZE=10G
export CCACHE_CPP2=true
export CCACHE_DIRECT=true
export CCACHE_DEPEND=true
export CCACHE_HARDLINK=true
export CCACHE_SLOPPINESS=file_macro,time_macros,include_file_mtime,include_file_ctime,file_stat_matches
export CCACHE_FILECLONE=true
export CCACHE_INODECACHE=true
export CCACHE_SLOPPINESS=file_macro,time_macros,include_file_mtime,include_file_ctime,file_stat_matches,modules,ivfsoverlay,pch_defines,system_headers
exec ccache clang++ "$@"
else
exec clang++ "$@"
Expand Down
9 changes: 8 additions & 1 deletion scripts/ccache-clang.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#!/bin/sh
if command -v ccache &> /dev/null; then
# reference for xcode specific cacche settings: reactnative docs and ccache manpage
# https://reactnative.dev/docs/build-speed#xcode-specific-setup
# https://ccache.dev/manual/4.3.html
export CCACHE_MAXSIZE=10G
export CCACHE_CPP2=true
export CCACHE_DIRECT=true
export CCACHE_DEPEND=true
export CCACHE_HARDLINK=true
export CCACHE_SLOPPINESS=file_macro,time_macros,include_file_mtime,include_file_ctime,file_stat_matches
export CCACHE_FILECLONE=true
export CCACHE_INODECACHE=true
export CCACHE_SLOPPINESS=file_macro,time_macros,include_file_mtime,include_file_ctime,file_stat_matches,modules,ivfsoverlay,pch_defines,system_headers
exec ccache clang "$@"
else
exec clang "$@"
Expand Down

0 comments on commit c513666

Please sign in to comment.