Skip to content

Commit df99c4e

Browse files
authored
ci: set up ccache for macOS builds (#841)
1 parent 3ff863f commit df99c4e

File tree

4 files changed

+40
-16
lines changed

4 files changed

+40
-16
lines changed

.ccache/ccache.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
depend_mode = true
2+
direct_mode = true
3+
hard_link = true
4+
run_second_cpp = true
5+
sloppiness = file_stat_matches,include_file_ctime,include_file_mtime,ivfsoverlay,modules,system_headers,time_macros

.github/workflows/ci.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ jobs:
99
name: 'macOS'
1010
runs-on: macos-latest
1111
steps:
12-
- name: Set up Node.js
13-
uses: actions/[email protected]
14-
with:
15-
node-version: 16
1612
- name: Checkout
1713
uses: actions/checkout@v3
18-
- name: Cache /.cache/yarn
14+
- name: Cache /.ccache
1915
uses: actions/cache@v3
2016
with:
21-
path: .cache/yarn
22-
key: ${{ hashFiles('yarn.lock') }}
17+
path: .ccache
18+
key: ${{ runner.os }}-ccache-${{ hashFiles('yarn.lock') }}
19+
restore-keys: ${{ runner.os }}-ccache-
20+
- name: Set up Node.js
21+
uses: actions/[email protected]
22+
with:
23+
node-version: 16
24+
cache: 'yarn'
2325
- name: Install JS dependencies
2426
run: |
2527
yarn ci
@@ -41,17 +43,13 @@ jobs:
4143
uses: microsoft/[email protected]
4244
- name: Setup VSTest.console.exe
4345
uses: darenm/Setup-VSTest@v1
44-
- name: Set up Node.js
45-
uses: actions/[email protected]
46-
with:
47-
node-version: 16
4846
- name: Checkout
4947
uses: actions/checkout@v3
50-
- name: Cache /.cache/yarn
51-
uses: actions/cache@v3
48+
- name: Set up Node.js
49+
uses: actions/setup-node@v3.4.1
5250
with:
53-
path: .cache/yarn
54-
key: ${{ hashFiles('yarn.lock') }}
51+
node-version: 16
52+
cache: 'yarn'
5553
- name: Install JS dependencies
5654
run: |
5755
yarn ci

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"url": "https://github.com/react-native-async-storage/async-storage.git"
3838
},
3939
"scripts": {
40-
"ci": "yarn --pure-lockfile --non-interactive --cache-folder .cache/yarn",
40+
"ci": "yarn --pure-lockfile --non-interactive",
4141
"format": "concurrently yarn:format:*",
4242
"format:c": "clang-format -i $(git ls-files '*.cpp' '*.h' '*.m' '*.mm')",
4343
"format:js": "prettier --write $(git ls-files '*.js' '*.json' '*.md' '*.ts' '*.tsx' '*.yml')",

scripts/macos_e2e.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
BUILD_ACTIONS="$@"
44

5+
if [[ "$CCACHE_DISABLE" != "1" ]]; then
6+
if ! command -v ccache 1> /dev/null; then
7+
brew install ccache
8+
fi
9+
10+
CCACHE_HOME=$(dirname $(dirname $(which ccache)))/opt/ccache
11+
12+
export CCACHE_DIR="$(git rev-parse --show-toplevel)/.ccache"
13+
14+
export CC="${CCACHE_HOME}/libexec/clang"
15+
export CXX="${CCACHE_HOME}/libexec/clang++"
16+
export CMAKE_C_COMPILER_LAUNCHER=$(which ccache)
17+
export CMAKE_CXX_COMPILER_LAUNCHER=$(which ccache)
18+
19+
ccache --zero-stats 1> /dev/null
20+
fi
21+
522
# Workaround for `Element StaticText, {{163.0, 836.0}, {156.0, 21.0}}, value: Set native delegate is not hittable`.
623
# This occurs when a button is not visible in the window. We resize the window
724
# here to ensure that it is.
@@ -15,4 +32,8 @@ xcodebuild \
1532
-derivedDataPath example/macos/build \
1633
$BUILD_ACTIONS
1734

35+
if [[ "$CCACHE_DISABLE" != "1" ]]; then
36+
ccache --show-stats --verbose
37+
fi
38+
1839
exit $?

0 commit comments

Comments
 (0)