From e85b4cc2a9f740a7b7a87b3c17e47066d1f7d362 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sat, 9 Mar 2024 11:52:30 +1300 Subject: [PATCH] ci: use caching --- .github/workflows/dummy.yml | 2 ++ .github/workflows/generator.yml | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/.github/workflows/dummy.yml b/.github/workflows/dummy.yml index e2027732..3bac0803 100644 --- a/.github/workflows/dummy.yml +++ b/.github/workflows/dummy.yml @@ -23,9 +23,11 @@ jobs: - uses: actions/setup-node@v3 with: node-version: '16' + cache: yarn - uses: ruby/setup-ruby@v1 with: ruby-version: '3.1.2' + bundler-cache: true - name: Install dependencies run: | bundle install diff --git a/.github/workflows/generator.yml b/.github/workflows/generator.yml index 0f9ce536..7470514f 100644 --- a/.github/workflows/generator.yml +++ b/.github/workflows/generator.yml @@ -52,6 +52,32 @@ jobs: bundle config --local path vendor/bundle - name: Install dependencies run: bundle install + + - name: Get npm cache directory + id: npm-cache-dir + shell: bash + run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} + + - uses: actions/cache@v3 + id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' + with: + path: ${{ steps.npm-cache-dir.outputs.dir }} + key: generator-${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + generator-${{ runner.os }}-npm- + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: generator-${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + generator-${{ runner.os }}-yarn- + - run: bundle exec rake run_spec:generator env: SHAKAPACKER_USE_PACKAGE_JSON_GEM: ${{ matrix.use_package_json_gem }}