Skip to content

Commit

Permalink
ci: Use Nx cache (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst authored May 23, 2023
1 parent 7bdc9af commit 8a35558
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 28 deletions.
77 changes: 63 additions & 14 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ jobs:
node-version-file: "package.json"
- name: Use dependency cache
uses: actions/cache@v3
id: cache
id: dependency-cache
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Use build cache
uses: actions/cache@v3
with:
path: .nxcache
key: build-cache-key-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
build-cache-key-${{ runner.os }}-
- name: Install dependencies
run: yarn --frozen-lockfile --ignore-engines
if: steps.cache.outputs.cache-hit != 'true'
if: steps.dependency-cache.outputs.cache-hit != 'true'
- run: yarn build

type-check:
Expand All @@ -38,13 +45,20 @@ jobs:
node-version-file: "package.json"
- name: Use dependency cache
uses: actions/cache@v3
id: cache
id: dependency-cache
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Use build cache
uses: actions/cache@v3
with:
path: .nxcache
key: build-cache-key-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
build-cache-key-${{ runner.os }}-
- name: Install dependencies
run: yarn --frozen-lockfile --ignore-engines
if: steps.cache.outputs.cache-hit != 'true'
if: steps.dependency-cache.outputs.cache-hit != 'true'
- run: yarn check:types

formatting-check:
Expand All @@ -57,13 +71,20 @@ jobs:
node-version-file: "package.json"
- name: Use dependency cache
uses: actions/cache@v3
id: cache
id: dependency-cache
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Use build cache
uses: actions/cache@v3
with:
path: .nxcache
key: build-cache-key-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
build-cache-key-${{ runner.os }}-
- name: Install dependencies
run: yarn --frozen-lockfile --ignore-engines
if: steps.cache.outputs.cache-hit != 'true'
if: steps.dependency-cache.outputs.cache-hit != 'true'
- run: yarn check:formatting

test-unit:
Expand All @@ -77,13 +98,20 @@ jobs:
node-version-file: "package.json"
- name: Use dependency cache
uses: actions/cache@v3
id: cache
id: dependency-cache
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Use build cache
uses: actions/cache@v3
with:
path: .nxcache
key: build-cache-key-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
build-cache-key-${{ runner.os }}-
- name: Install dependencies
run: yarn --frozen-lockfile --ignore-engines
if: steps.cache.outputs.cache-hit != 'true'
if: steps.dependency-cache.outputs.cache-hit != 'true'
- run: yarn test:unit

test-integration:
Expand All @@ -110,13 +138,20 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Use dependency cache
uses: actions/cache@v3
id: cache
id: dependency-cache
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Use build cache
uses: actions/cache@v3
with:
path: .nxcache
key: build-cache-key-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
build-cache-key-${{ runner.os }}-
- name: Install dependencies
run: yarn --frozen-lockfile --ignore-engines
if: steps.cache.outputs.cache-hit != 'true'
if: steps.dependency-cache.outputs.cache-hit != 'true'
- run: yarn test:integration

test-e2e:
Expand All @@ -136,13 +171,20 @@ jobs:
- uses: volta-cli/action@v3
- name: Use dependency cache
uses: actions/cache@v3
id: cache
id: dependency-cache
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Use build cache
uses: actions/cache@v3
with:
path: .nxcache
key: build-cache-key-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
build-cache-key-${{ runner.os }}-
- name: Install dependencies
run: yarn --frozen-lockfile --ignore-engines
if: steps.cache.outputs.cache-hit != 'true'
if: steps.dependency-cache.outputs.cache-hit != 'true'
- run: yarn test:e2e

lint:
Expand All @@ -156,13 +198,20 @@ jobs:
node-version-file: "package.json"
- name: Use dependency cache
uses: actions/cache@v3
id: cache
id: dependency-cache
with:
path: "**/node_modules"
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- name: Use build cache
uses: actions/cache@v3
with:
path: .nxcache
key: build-cache-key-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
build-cache-key-${{ runner.os }}-
- name: Install dependencies
run: yarn --frozen-lockfile --ignore-engines
if: steps.cache.outputs.cache-hit != 'true'
if: steps.dependency-cache.outputs.cache-hit != 'true'
- run: yarn lint

artifacts:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ yarn-error.log

.vscode/settings.json

*.tgz
*.tgz

.nxcache
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
packages/e2e-tests/scenarios/*/ref/**/*
packages/bundler-plugin-core/test/fixtures
packages/bundler-plugin-core/test/fixtures
.nxcache
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "2.0.0",
"packages": "packages/*",
"npmClient": "yarn",
"useWorkspaces": true
}
25 changes: 16 additions & 9 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
{
"extends": "nx/presets/npm.json",
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"affected": {
"defaultBase": "main"
},
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": ["build", "lint", "test"],
"parallel": 10
"cacheDirectory": ".nxcache"
}
}
},
"namedInputs": {
"sharedGlobals": ["{workspaceRoot}/*.js", "{workspaceRoot}/*.json", "{workspaceRoot}/yarn.lock"]
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"]
"inputs": ["sharedGlobals"],
"dependsOn": ["^build"],
"outputs": ["{projectRoot}/dist"]
},
"lint": {
"dependsOn": ["^build", "build"]
"inputs": ["sharedGlobals"],
"dependsOn": ["^build", "build"],
"outputs": []
},
"test": {
"dependsOn": ["^build"]
"inputs": ["sharedGlobals"],
"dependsOn": ["^build"],
"outputs": []
},
"check:types": {
"dependsOn": ["^build"]
"inputs": ["sharedGlobals"],
"dependsOn": ["^build"],
"outputs": []
},
"build:npm": {
"dependsOn": ["build", "^build"]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@nrwl/cli": "14.5.10",
"@nrwl/workspace": "14.5.10",
"husky": "^8.0.0",
"lerna": "^6.0.1",
"lerna": "^6.6.2",
"nx": "14.5.10",
"prettier": "^2.7.1",
"pretty-quick": "^3.1.3",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8080,7 +8080,7 @@ kleur@^3.0.3:
resolved "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==

lerna@^6.0.1:
lerna@^6.6.2:
version "6.6.2"
resolved "https://registry.npmjs.org/lerna/-/lerna-6.6.2.tgz#ad921f913aca4e7307123a598768b6f15ca5804f"
integrity sha512-W4qrGhcdutkRdHEaDf9eqp7u4JvI+1TwFy5woX6OI8WPe4PYBdxuILAsvhp614fUG41rKSGDKlOh+AWzdSidTg==
Expand Down

0 comments on commit 8a35558

Please sign in to comment.