Skip to content

Commit

Permalink
refactor: cached dist files on Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
lquixada committed Dec 17, 2024
1 parent 5518a17 commit ccf5f71
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,24 @@ jobs:
path: ~/.npm # this is cache where npm installs from before going out to the network
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
- name: Install dependencies
if: steps.cacheModules.outputs.cache-hit != 'true'
run: npm install
if: steps.cacheDist.outputs.cache-hit != 'true'
run: make dist

build:
name: Build
needs: [install]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache dist
id: cacheDist
uses: actions/cache@v4
with:
path: ./dist
key: ${{ runner.os }}-node-${{ hashFiles('package.json', 'rollup.config.js', 'src/*.js') }}
- name: Install dependencies
if: steps.cacheDist.outputs.cache-hit != 'true'
run: make dist

debug:
name: Debug
Expand All @@ -29,7 +45,7 @@ jobs:

checks:
name: Check
needs: [install]
needs: [build]
uses: ./.github/workflows/checks.yml
with:
ref: ${{ github.sha }}
Expand All @@ -38,7 +54,7 @@ jobs:
# Github doesn't pass down the SNYK_TOKEN environment variable.
security:
name: Check Security
needs: [install]
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- uses: actions/cache@v4
- name: Restore node modules
uses: actions/cache@v4
with:
path: ~/.npm # this is cache where npm installs from before going out to the network
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
- name: Restore dist
uses: actions/cache@v4
with:
path: ./dist
key: ${{ runner.os }}-node-${{ hashFiles('package.json', 'rollup.config.js', 'src/*.js') }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand Down

0 comments on commit ccf5f71

Please sign in to comment.