Skip to content

Commit

Permalink
add caching to github workflows (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
dario-piotrowicz authored Jul 24, 2023
1 parent 551fa05 commit 1588974
Show file tree
Hide file tree
Showing 8 changed files with 289 additions and 23 deletions.
22 changes: 21 additions & 1 deletion .github/workflows/beta-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,27 @@ jobs:
with:
node-version: 16.x

- name: Install Dependencies
- name: Get current node version
id: node-version
run: |
node_version=$(node -v)
echo "node_version=$node_version" >> $GITHUB_OUTPUT
# Attempt to cache all the node_modules directories based on the node version and package lock.
- name: Cache node_modules
id: npm-cache
uses: actions/cache@v3
env:
cache-name: cache-node-modules-${{ steps.node-version.outputs.node_version }}
with:
key: ${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
path: |
**/node_modules
!/pages-e2e/workspaces/**/node_modules
# If the cache missed then install using `npm ci` to follow package lock exactly
- if: ${{ steps.npm-cache.outputs.cache-hit != 'true'}}
name: Install NPM Dependencies
run: npm ci

- name: Modify package.json version
Expand Down
27 changes: 26 additions & 1 deletion .github/workflows/configs-docs-scraping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,46 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Setup Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Install NPM Dependencies

- name: Get current node version
id: node-version
run: |
node_version=$(node -v)
echo "node_version=$node_version" >> $GITHUB_OUTPUT
# Attempt to cache all the node_modules directories based on the node version and package lock.
- name: Cache node_modules
id: npm-cache
uses: actions/cache@v3
env:
cache-name: cache-node-modules-${{ steps.node-version.outputs.node_version }}
with:
key: ${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
path: |
**/node_modules
!/pages-e2e/workspaces/**/node_modules
# If the cache missed then install using `npm ci` to follow package lock exactly
- if: ${{ steps.npm-cache.outputs.cache-hit != 'true'}}
name: Install NPM Dependencies
run: npm ci

- name: Run Checker
id: run-checker
working-directory: internal-packages/docs-scraper
run: GH_ACTION=true npm run check-docs

- name: Generate table
id: generate-table
if: steps.run-checker.outputs.result == 'out-of-date'
working-directory: internal-packages/docs-scraper
run: GH_ACTION=true npm run generate-configs-table

- name: Create or update issue
if: steps.run-checker.outputs.result == 'out-of-date'
working-directory: internal-packages/docs-scraper
Expand Down
24 changes: 21 additions & 3 deletions .github/workflows/create-pullrequest-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,29 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16.13
cache: 'npm' # cache ~/.npm in case 'npm ci' needs to run

- name: Install NPM Dependencies
run: npm ci
- name: Get current node version
id: node-version
run: |
node_version=$(node -v)
echo "node_version=$node_version" >> $GITHUB_OUTPUT
# Attempt to cache all the node_modules directories based on the node version and package lock.
- name: Cache node_modules
id: npm-cache
uses: actions/cache@v3
env:
cache-name: cache-node-modules-${{ steps.node-version.outputs.node_version }}
with:
key: ${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
path: |
**/node_modules
!/pages-e2e/workspaces/**/node_modules
# If the cache missed then install using `npm ci` to follow package lock exactly
- if: ${{ steps.npm-cache.outputs.cache-hit != 'true'}}
name: Install NPM Dependencies
run: npm ci
- name: Modify package.json version
run: node .github/version-script.js PR=${{ github.event.number }}

Expand Down
202 changes: 191 additions & 11 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,43 @@ jobs:
with:
node-version: 16.13.x

- name: Install
- name: Get current node version
id: node-version
run: |
node_version=$(node -v)
echo "node_version=$node_version" >> $GITHUB_OUTPUT
# Attempt to cache all the node_modules directories based on the node version and package lock
- name: Cache node_modules
id: npm-cache
uses: actions/cache@v3
env:
cache-name: cache-node-modules-${{ steps.node-version.outputs.node_version }}
with:
key: ${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
path: |
**/node_modules
!/pages-e2e/workspaces/**/node_modules
# If the cache missed then install using `npm ci` to follow package lock exactly
- if: ${{ steps.npm-cache.outputs.cache-hit != 'true'}}
name: Install NPM Dependencies
run: npm ci

- name: Cache turbo
id: turbo-cache
uses: actions/cache@v3
with:
path: ./turbo-cache
key: cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-${{ github.ref_name }}-${{ github.sha }}
cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-${{ github.ref_name }}-
cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-
cache-turbo-${{ github.workflow }}-${{ github.job }}
- name: Check formatting
run: npm run prettier:check
run: npm run prettier:check -- --cache-dir ./turbo-cache
linting:
name: Linting
runs-on: ubuntu-latest
Expand All @@ -39,11 +71,43 @@ jobs:
with:
node-version: 16.13.x

- name: Install
- name: Get current node version
id: node-version
run: |
node_version=$(node -v)
echo "node_version=$node_version" >> $GITHUB_OUTPUT
# Attempt to cache all the node_modules directories based on the node version and package lock.
- name: Cache node_modules
id: npm-cache
uses: actions/cache@v3
env:
cache-name: cache-node-modules-${{ steps.node-version.outputs.node_version }}
with:
key: ${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
path: |
**/node_modules
!/pages-e2e/workspaces/**/node_modules
# If the cache missed then install using `npm ci` to follow package lock exactly
- if: ${{ steps.npm-cache.outputs.cache-hit != 'true'}}
name: Install NPM Dependencies
run: npm ci

- name: Cache turbo
id: turbo-cache
uses: actions/cache@v3
with:
path: ./turbo-cache
key: cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-${{ github.ref_name }}-${{ github.sha }}
cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-${{ github.ref_name }}-
cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-
cache-turbo-${{ github.workflow }}-${{ github.job }}
- name: Check linting
run: npm run lint
run: npm run lint -- --cache-dir ./turbo-cache
types:
name: Types
runs-on: ubuntu-latest
Expand All @@ -55,11 +119,43 @@ jobs:
with:
node-version: 16.13.x

- name: Install
- name: Get current node version
id: node-version
run: |
node_version=$(node -v)
echo "node_version=$node_version" >> $GITHUB_OUTPUT
# Attempt to cache all the node_modules directories based on the node version and package lock.
- name: Cache node_modules
id: npm-cache
uses: actions/cache@v3
env:
cache-name: cache-node-modules-${{ steps.node-version.outputs.node_version }}
with:
key: ${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
path: |
**/node_modules
!/pages-e2e/workspaces/**/node_modules
# If the cache missed then install using `npm ci` to follow package lock exactly
- if: ${{ steps.npm-cache.outputs.cache-hit != 'true'}}
name: Install NPM Dependencies
run: npm ci

- name: Cache turbo
id: turbo-cache
uses: actions/cache@v3
with:
path: ./turbo-cache
key: cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-${{ github.ref_name }}-${{ github.sha }}
cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-${{ github.ref_name }}-
cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-
cache-turbo-${{ github.workflow }}-${{ github.job }}
- name: Check types
run: npm run types-check
run: npm run types-check -- --cache-dir ./turbo-cache
build:
name: Build
runs-on: ubuntu-latest
Expand All @@ -71,11 +167,43 @@ jobs:
with:
node-version: 16.13.x

- name: Install
- name: Get current node version
id: node-version
run: |
node_version=$(node -v)
echo "node_version=$node_version" >> $GITHUB_OUTPUT
# Attempt to cache all the node_modules directories based on the node version and package lock.
- name: Cache node_modules
id: npm-cache
uses: actions/cache@v3
env:
cache-name: cache-node-modules-${{ steps.node-version.outputs.node_version }}
with:
key: ${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
path: |
**/node_modules
!/pages-e2e/workspaces/**/node_modules
# If the cache missed then install using `npm ci` to follow package lock exactly
- if: ${{ steps.npm-cache.outputs.cache-hit != 'true'}}
name: Install NPM Dependencies
run: npm ci

- name: Cache turbo
id: turbo-cache
uses: actions/cache@v3
with:
path: ./turbo-cache
key: cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-${{ github.ref_name }}-${{ github.sha }}
cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-${{ github.ref_name }}-
cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-
cache-turbo-${{ github.workflow }}-${{ github.job }}
- name: Build
run: npm run build
run: npm run build -- --cache-dir ./turbo-cache
unit-tests:
name: Unit tests
runs-on: ubuntu-latest
Expand All @@ -87,11 +215,43 @@ jobs:
with:
node-version: 16.13.x

- name: Install
- name: Get current node version
id: node-version
run: |
node_version=$(node -v)
echo "node_version=$node_version" >> $GITHUB_OUTPUT
# Attempt to cache all the node_modules directories based on the node version and package lock.
- name: Cache node_modules
id: npm-cache
uses: actions/cache@v3
env:
cache-name: cache-node-modules-${{ steps.node-version.outputs.node_version }}
with:
key: ${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
path: |
**/node_modules
!/pages-e2e/workspaces/**/node_modules
# If the cache missed then install using `npm ci` to follow package lock exactly
- if: ${{ steps.npm-cache.outputs.cache-hit != 'true'}}
name: Install NPM Dependencies
run: npm ci

- name: Cache turbo
id: turbo-cache
uses: actions/cache@v3
with:
path: ./turbo-cache
key: cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-${{ github.ref_name }}-${{ github.sha }}
cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-${{ github.ref_name }}-
cache-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.base_ref }}-
cache-turbo-${{ github.workflow }}-${{ github.job }}
- name: Run unit tests
run: npm run test:unit
run: npm run test:unit -- --cache-dir ./turbo-cache
e2e-tests:
name: e2e tests
runs-on: ubuntu-latest
Expand All @@ -103,7 +263,27 @@ jobs:
with:
node-version: 18.x

- name: Install
- name: Get current node version
id: node-version
run: |
node_version=$(node -v)
echo "node_version=$node_version" >> $GITHUB_OUTPUT
# Attempt to cache all the node_modules directories based on the node version and package lock.
- name: Cache node_modules
id: npm-cache
uses: actions/cache@v3
env:
cache-name: cache-node-modules-${{ steps.node-version.outputs.node_version }}
with:
key: ${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
path: |
**/node_modules
!/pages-e2e/workspaces/**/node_modules
# If the cache missed then install using `npm ci` to follow package lock exactly
- if: ${{ steps.npm-cache.outputs.cache-hit != 'true'}}
name: Install NPM Dependencies
run: npm ci

- name: Run e2e tests
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,27 @@ jobs:
with:
node-version: 16.x

- name: Install Dependencies
- name: Get current node version
id: node-version
run: |
node_version=$(node -v)
echo "node_version=$node_version" >> $GITHUB_OUTPUT
# Attempt to cache all the node_modules directories based on the node version and package lock.
- name: Cache node_modules
id: npm-cache
uses: actions/cache@v3
env:
cache-name: cache-node-modules-${{ steps.node-version.outputs.node_version }}
with:
key: ${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
path: |
**/node_modules
!/pages-e2e/workspaces/**/node_modules
# If the cache missed then install using `npm ci` to follow package lock exactly
- if: ${{ steps.npm-cache.outputs.cache-hit != 'true'}}
name: Install NPM Dependencies
run: npm ci

- name: Create Release Pull Request or Publish to npm
Expand Down
Loading

0 comments on commit 1588974

Please sign in to comment.