Skip to content

Commit

Permalink
ci: rework caching in release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
B4nan committed Feb 6, 2024
1 parent ffa2a44 commit 0577642
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 32 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
pull_request:

jobs:
# NPM install is done in a separate job and cached to speed up the following jobs.
build_and_test:
name: Build & Test
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
Expand All @@ -25,14 +24,17 @@ jobs:

- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: 'package-lock.json'

- name: Install Dependencies
run: npm ci

- name: Run Tests
run: npm test

Expand Down
54 changes: 23 additions & 31 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,34 @@ on:
types: [ published ]

jobs:
# NPM install is done in a separate job and cached to speed up the following jobs.
build_and_test:
name: Build & Test
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 16, 16 ]
node-version: [ 16, 18, 20 ]

steps:
- uses: actions/checkout@v4
- name: Cancel Workflow Action
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Cache Node Modules
if: ${{ matrix.node-version == 16 }}
uses: actions/cache@v4
with:
path: |
node_modules
build
key: cache-${{ github.run_id }}-v14
cache: 'npm'
cache-dependency-path: 'package-lock.json'

- name: Install Dependencies
run: npm install
run: npm ci

- name: Run Tests
run: npm test

Expand All @@ -49,17 +51,12 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Use Node.js 16
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 16
- name: Load Cache
uses: actions/cache@v4
with:
path: |
node_modules
build
key: cache-${{ github.run_id }}-v14
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- run: npm run lint


Expand All @@ -71,17 +68,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: Load Cache
uses: actions/cache@v4
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
path: |
node_modules
build
key: cache-${{ github.run_id }}-v14
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- # Determine if this is a beta or latest release
name: Set Release Tag
run: echo "RELEASE_TAG=$(if [ ${{ github.event_name }} = release ]; then echo latest; else echo beta; fi)" >> $GITHUB_ENV
Expand Down

0 comments on commit 0577642

Please sign in to comment.