From d005adabba3609ff569c22784d45dda7bef32cd4 Mon Sep 17 00:00:00 2001 From: Mahdi Sharifi Date: Sat, 6 Apr 2024 02:09:03 +0330 Subject: [PATCH] Use CCache --- .github/workflows/scheduled-builds.yml | 24 +++++++++++++++++++++++- index.js | 6 +++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/scheduled-builds.yml b/.github/workflows/scheduled-builds.yml index 4453580..28a2f29 100644 --- a/.github/workflows/scheduled-builds.yml +++ b/.github/workflows/scheduled-builds.yml @@ -12,6 +12,14 @@ jobs: container: image: ubuntu:devel steps: + - name: Restore CCache + uses: actions/cache@v4 + with: + path: .ccache + key: ${{ runner.os }}:libnode:ccache:${{ github.run_number }} + restore-keys: | + ${{ runner.os }}:libnode:ccache: + - name: Update system run: apt-get update && apt-get --yes upgrade @@ -19,7 +27,17 @@ jobs: run: apt-get install --yes ca-certificates curl gnupg && curl -sL https://deb.nodesource.com/setup_21.x | bash - && apt-get update - name: Install building tools - run: apt-get install --yes git python3 python3-pip gcc g++ make ninja-build nodejs + run: apt-get install --yes git python3 python3-pip gcc g++ make ninja-build nodejs ccache + + - name: Setup CCache + run: | + sudo update-ccache-symlinks + echo "/usr/lib/ccache" >> "$GITHUB_PATH" + + ccacheDir="${GITHUB_WORKSPACE}/.ccache" + test -d "$ccacheDir" || mkdir "$ccacheDir" + + echo "CCACHE_DIR=$ccacheDir" >> "$GITHUB_ENV" - name: Clone the repo run: git clone https://github.com/devraymondsh/libnode-distributable @@ -27,5 +45,9 @@ jobs: - name: Run the script run: cd libnode-distributable && node index.js + - name: Show CCache Status + shell: bash + run: ccache -s + - name: A buncha ls run: ls . ; ls .. ; ls out/Debug ; ls ../out/Debug diff --git a/index.js b/index.js index 8015f67..a3d23da 100644 --- a/index.js +++ b/index.js @@ -66,6 +66,10 @@ if (!syncFs.existsSync("node")) { ); } -await spawnAsync("./configure", ["--ninja", "--shared", "--debug"], "node"); +await spawnAsync( + "./configure", + ["--ninja", "--shared", "--debug", "CC='ccache gcc'", "CXX='ccache g++'"], + "node" +); await spawnAsync("make", [`-j${threadCount}`], "node");