Skip to content

Commit

Permalink
ci: Add package caching support
Browse files Browse the repository at this point in the history
Signed-off-by: eXhumer <[email protected]>
  • Loading branch information
eXhumer committed Aug 21, 2024
1 parent c0ee5be commit 413c83d
Showing 1 changed file with 33 additions and 20 deletions.
53 changes: 33 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,30 @@ jobs:
- name: Enable Corepack
run: corepack enable

- name: Setup Node.js with cache
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: yarn

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '${{ matrix.python }}'

- name: Install dependencies
run: |
python3 -m pip install setuptools
yarn install --frozen-lockfile
- name: Install Python dependencies
run: python3 -m pip install setuptools

- name: Cache yarn packages
id: cache-packages-darwin-node_${{ matrix.node }}-python_${{ matrix.python }}-${{ matrix.arch }}
uses: actions/cache@v4
with:
path: '**/node_modules'
key: darwin-node_${{ matrix.node }}-python_${{ matrix.python }}-${{ matrix.arch }}-packages-${{ hashFiles('**/yarn.lock') }}
if: ${{ github.event_name }} == 'push' and ${{ github.ref }} == 'refs/heads/main'

- name: Install yarn dependencies
run: yarn install --frozen-lockfile
if: steps.cache-packages-darwin-node_${{ matrix.node }}-python_${{ matrix.python }}-${{ matrix.arch }}.outputs.cache-hit != 'true'

- name: Build package
env:
Expand Down Expand Up @@ -81,7 +90,6 @@ jobs:
matrix:
arch: [x64]
node: [22]
python: [3.12]

steps:
- name: Checkout
Expand All @@ -90,19 +98,22 @@ jobs:
- name: Enable Corepack
run: corepack enable

- name: Setup Node.js with cache
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: yarn

- name: Set up Python
uses: actions/setup-python@v5
- name: Cache yarn packages
id: cache-packages-linux-node_${{ matrix.node }}-${{ matrix.arch }}
uses: actions/cache@v4
with:
python-version: '${{ matrix.python }}'
path: '**/node_modules'
key: ubuntu-node_${{ matrix.node }}-${{ matrix.arch }}-packages-${{ hashFiles('**/yarn.lock') }}
if: ${{ github.event_name }} == 'push' and ${{ github.ref }} == 'refs/heads/main'

- name: Install dependencies
- name: Install yarn dependencies
run: yarn install --frozen-lockfile
if: steps.cache-packages-linux-node_${{ matrix.node }}-${{ matrix.arch }}.outputs.cache-hit != 'true'

- name: Build package
env:
Expand All @@ -124,7 +135,6 @@ jobs:
matrix:
arch: [x64, ia32]
node: [22]
python: [3.12]

steps:
- name: Checkout
Expand All @@ -133,19 +143,22 @@ jobs:
- name: Enable Corepack
run: corepack enable

- name: Setup Node.js with cache
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: yarn

- name: Set up Python
uses: actions/setup-python@v5
- name: Cache yarn packages
id: cache-packages-windows-node_${{ matrix.node }}-${{ matrix.arch }}
uses: actions/cache@v4
with:
python-version: '${{ matrix.python }}'
path: '**/node_modules'
key: windows-node_${{ matrix.node }}-${{ matrix.arch }}-packages-${{ hashFiles('**/yarn.lock') }}
if: ${{ github.event_name }} == 'push' and ${{ github.ref }} == 'refs/heads/main'

- name: Install dependencies
- name: Install yarn dependencies
run: yarn install --frozen-lockfile
if: steps.cache-packages-windows-node_${{ matrix.node }}-${{ matrix.arch }}.outputs.cache-hit != 'true'

- name: Build package
env:
Expand Down

0 comments on commit 413c83d

Please sign in to comment.