Cache expensive CI steps (#21)

Speed-up pipeline by caching eslint, prettier, TypeScript, node_modules
This commit is contained in:
Lars Strojny 2022-11-14 02:43:27 +01:00 committed by GitHub
parent 57e8a4d831
commit edf4e605e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 2 deletions

View file

@ -31,8 +31,61 @@ jobs:
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json,**/package.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache eslint
id: cache-eslint
uses: actions/cache@v3
env:
cache-name: cache-eslint
with:
path: .eslintcache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json,**/package.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache TypeScript
id: cache-typescript
uses: actions/cache@v3
env:
cache-name: cache-typescript
with:
path: .tsbuildinfo
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json,**/package.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache prettier
id: cache-prettier
uses: actions/cache@v3
env:
cache-name: cache-prettier
with:
path: node_modules/.cache/prettier/.prettier-cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json,**/package.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies - name: Install dependencies
run: npm install run: npm install
if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
- name: Lint the project - name: Lint the project
run: npm run lint run: npm run lint

View file

@ -16,7 +16,7 @@
}, },
"main": "dist/src/index.js", "main": "dist/src/index.js",
"scripts": { "scripts": {
"lint": "ifNotCi() { test \"$CI\" && echo \"$2\" || echo \"$1\"; }; `npm bin`/tsc --noEmit && `npm bin`/prettier --ignore-path=.gitignore `ifNotCi --write --check` '**/**.{ts,js,json}' && `npm bin`/eslint `ifNotCi --fix` --ignore-path=.gitignore '**/**.{ts,js,json}'", "lint": "ifNotCi() { test \"$CI\" && echo \"$2\" || echo \"$1\"; }; `npm bin`/tsc --noEmit && `npm bin`/prettier --ignore-path=.gitignore `ifNotCi --write \"--check --cache --cache-strategy content\"` '**/**.{ts,js,json}' && `npm bin`/eslint `ifNotCi --fix \"--cache --cache-strategy content\"` --ignore-path=.gitignore '**/**.{ts,js,json}'",
"start": "npm run build && npm run link && nodemon", "start": "npm run build && npm run link && nodemon",
"test": "ifNotCi() { test \"$CI\" && echo \"$2\" || echo \"$1\"; }; npm run code-generation && `npm bin`/jest `ifNotCi --watchAll`", "test": "ifNotCi() { test \"$CI\" && echo \"$2\" || echo \"$1\"; }; npm run code-generation && `npm bin`/jest `ifNotCi --watchAll`",
"link": "npm install --no-save file:///$PWD/", "link": "npm install --no-save file:///$PWD/",

View file

@ -12,7 +12,9 @@
"esModuleInterop": true, "esModuleInterop": true,
"importsNotUsedAsValues": "error", "importsNotUsedAsValues": "error",
"noImplicitAny": true, "noImplicitAny": true,
"resolveJsonModule": true "resolveJsonModule": true,
"tsBuildInfoFile": ".tsbuildinfo",
"incremental": true
}, },
"include": ["src/", "tests/"], "include": ["src/", "tests/"],
"exclude": [] "exclude": []