From 52ce48966886d2e62660eec7b042e092e81445ac Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Tue, 6 Sep 2022 11:29:45 +0200 Subject: [PATCH] ci: set up ccache for macOS builds --- .ccache/ccache.conf | 5 +++++ .github/workflows/ci.yml | 28 +++++++++++++--------------- package.json | 2 +- scripts/macos_e2e.sh | 21 +++++++++++++++++++++ 4 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 .ccache/ccache.conf diff --git a/.ccache/ccache.conf b/.ccache/ccache.conf new file mode 100644 index 00000000..dc0898d7 --- /dev/null +++ b/.ccache/ccache.conf @@ -0,0 +1,5 @@ +depend_mode = true +direct_mode = true +hard_link = true +run_second_cpp = true +sloppiness = file_stat_matches,include_file_ctime,include_file_mtime,ivfsoverlay,modules,system_headers,time_macros diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ace98ea..64d55740 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,17 +9,19 @@ jobs: name: 'macOS' runs-on: macos-latest steps: - - name: Set up Node.js - uses: actions/setup-node@v3.3.0 - with: - node-version: 16 - name: Checkout uses: actions/checkout@v3 - - name: Cache /.cache/yarn + - name: Cache /.ccache uses: actions/cache@v3 with: - path: .cache/yarn - key: ${{ hashFiles('yarn.lock') }} + path: .ccache + key: ${{ runner.os }}-ccache-${{ hashFiles('yarn.lock') }} + restore-keys: ${{ runner.os }}-ccache- + - name: Set up Node.js + uses: actions/setup-node@v3.4.1 + with: + node-version: 16 + cache: 'yarn' - name: Install JS dependencies run: | yarn ci @@ -41,17 +43,13 @@ jobs: uses: microsoft/setup-msbuild@v1.1 - name: Setup VSTest.console.exe uses: darenm/Setup-VSTest@v1 - - name: Set up Node.js - uses: actions/setup-node@v3.3.0 - with: - node-version: 16 - name: Checkout uses: actions/checkout@v3 - - name: Cache /.cache/yarn - uses: actions/cache@v3 + - name: Set up Node.js + uses: actions/setup-node@v3.4.1 with: - path: .cache/yarn - key: ${{ hashFiles('yarn.lock') }} + node-version: 16 + cache: 'yarn' - name: Install JS dependencies run: | yarn ci diff --git a/package.json b/package.json index eb9311ec..d83e2e66 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "url": "https://github.com/react-native-async-storage/async-storage.git" }, "scripts": { - "ci": "yarn --pure-lockfile --non-interactive --cache-folder .cache/yarn", + "ci": "yarn --pure-lockfile --non-interactive", "format": "concurrently yarn:format:*", "format:c": "clang-format -i $(git ls-files '*.cpp' '*.h' '*.m' '*.mm')", "format:js": "prettier --write $(git ls-files '*.js' '*.json' '*.md' '*.ts' '*.tsx' '*.yml')", diff --git a/scripts/macos_e2e.sh b/scripts/macos_e2e.sh index 30a082f3..7bfbd9c3 100755 --- a/scripts/macos_e2e.sh +++ b/scripts/macos_e2e.sh @@ -2,6 +2,23 @@ BUILD_ACTIONS="$@" +if [[ "$CCACHE_DISABLE" != "1" ]]; then + if ! command -v ccache 1> /dev/null; then + brew install ccache + fi + + CCACHE_HOME=$(dirname $(dirname $(which ccache)))/opt/ccache + + export CCACHE_DIR="$(git rev-parse --show-toplevel)/.ccache" + + export CC="${CCACHE_HOME}/libexec/clang" + export CXX="${CCACHE_HOME}/libexec/clang++" + export CMAKE_C_COMPILER_LAUNCHER=$(which ccache) + export CMAKE_CXX_COMPILER_LAUNCHER=$(which ccache) + + ccache --zero-stats 1> /dev/null +fi + # Workaround for `Element StaticText, {{163.0, 836.0}, {156.0, 21.0}}, value: Set native delegate is not hittable`. # This occurs when a button is not visible in the window. We resize the window # here to ensure that it is. @@ -15,4 +32,8 @@ xcodebuild \ -derivedDataPath example/macos/build \ $BUILD_ACTIONS +if [[ "$CCACHE_DISABLE" != "1" ]]; then + ccache --show-stats --verbose +fi + exit $?