Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests - Caching #67

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
66ace93
tests: add cache key unit tests
AdrianRomanski Dec 8, 2024
df54967
tests: add get cache test, move cacheKey to utils
AdrianRomanski Dec 9, 2024
7daec0c
tests: set cache record
AdrianRomanski Dec 11, 2024
b649d40
Merge branch 'main' into testing-enchantment
BioPhoton Dec 11, 2024
5528725
tests: read target cache beginning
AdrianRomanski Dec 12, 2024
89baebf
tests: read target cache - mock read json file
AdrianRomanski Dec 12, 2024
3e97e60
tests: separate testing of calls from testing of return value
AdrianRomanski Dec 12, 2024
11109d7
tests: add negative scenario readTargetsCache
AdrianRomanski Dec 12, 2024
be99d62
tests: read targets cache optimization, better naming, polishing code
AdrianRomanski Dec 12, 2024
17bfd35
tests: better naming, code polish
AdrianRomanski Dec 12, 2024
5b1ad17
tests: writeTargetsToCache, final touches
AdrianRomanski Dec 12, 2024
fc32230
Merge branch 'main' into testing-enchantment
AdrianRomanski Dec 12, 2024
d78918a
tests: memory optimization
AdrianRomanski Dec 12, 2024
10ab635
Merge remote-tracking branch 'origin/testing-enchantment' into testin…
AdrianRomanski Dec 12, 2024
fd14326
chore: nx format
AdrianRomanski Dec 12, 2024
b046f6e
tests: name changes
AdrianRomanski Dec 20, 2024
4c35d59
chore: exclude changelog file from prettier formatting
AdrianRomanski Dec 20, 2024
da5919b
tests: delete unnecessary nesting of describe blocks
AdrianRomanski Dec 20, 2024
2e749e3
tests: change hardcoded env set to vi.stubEnv
AdrianRomanski Dec 20, 2024
a78f6c4
tests: move consts project configuration to fixtures
AdrianRomanski Dec 20, 2024
31e094b
tests: remove unnecessary describe nesting
AdrianRomanski Jan 3, 2025
138d786
tests: revert order
AdrianRomanski Jan 3, 2025
207eafd
tests: use stubEnv instead of manual NX_CACHE_PROJECT_GRAPH setting
AdrianRomanski Jan 3, 2025
3c52145
tests: remove big fixture in favor of small mocking data
AdrianRomanski Jan 3, 2025
8bfe583
tests: change manual NX_CACHE_PROJECT_GRAPH setting to stubEnv
AdrianRomanski Jan 5, 2025
07bfa75
tests: memory optimization, checking for variable duplicates, introdu…
AdrianRomanski Jan 5, 2025
42afe92
tests: mockReturnValue instead of implementation
AdrianRomanski Jan 5, 2025
6c4d56e
tests: consistent testing names, code organization
AdrianRomanski Jan 5, 2025
2a5bfae
tests: put import with * for spying as the last one for better readab…
AdrianRomanski Jan 5, 2025
bbfec58
chore: revert changelog changes
AdrianRomanski Jan 6, 2025
0f6d523
chore: disables prettier formatting for .nx directory
AdrianRomanski Jan 6, 2025
1af8d1c
tests: change names of describe blocks to match function names
AdrianRomanski Jan 6, 2025
4f8c5f2
self-review: add spy checking test for setCacheRecord
AdrianRomanski Jan 6, 2025
4e88caf
self-review: run nx format
AdrianRomanski Jan 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/dist
/coverage
/.nx/cache
/.nx/workspace-data
/.nx/workspace-data
CHANGELOG.md
69 changes: 23 additions & 46 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,227 +1,207 @@
## 0.0.0-alpha.27 (2024-12-11)


### 🚀 Features

- cleanup git status in folders that are checked in ([5e2c9b5](https://github.com/push-based/nx-verdaccio/commit/5e2c9b5))
- add skip install ([b1628ef](https://github.com/push-based/nx-verdaccio/commit/b1628ef))
- **nx-verdaccio:** add skipInstall and post script ([f2c0c86](https://github.com/push-based/nx-verdaccio/commit/f2c0c86))

### ❤️ Thank You
AdrianRomanski marked this conversation as resolved.
Show resolved Hide resolved
### ❤️ Thank You

- Michael @rx-angular
- Michael Hladky @BioPhoton

## 0.0.0-alpha.26 (2024-10-23)


### 🩹 Fixes

- add skipTeardown to env-teardown executor ([ff52749](https://github.com/push-based/nx-verdaccio/commit/ff52749))
- add skipTeardown to env-teardown executor ([664c6bd](https://github.com/push-based/nx-verdaccio/commit/664c6bd))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular
- Michael Hladky @BioPhoton

## 0.0.0-alpha.25 (2024-10-22)


### 🩹 Fixes

- pkg-install unit tests ([9c6e64d](https://github.com/push-based/nx-verdaccio/commit/9c6e64d))
- npmWorkspace tests unit tests ([7485fe4](https://github.com/push-based/nx-verdaccio/commit/7485fe4))
- e2e ([10a7c76](https://github.com/push-based/nx-verdaccio/commit/10a7c76))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

## 0.0.0-alpha.24 (2024-10-20)


### 🩹 Fixes

- install optional deps with package ([abf41db](https://github.com/push-based/nx-verdaccio/commit/abf41db))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

## 0.0.0-alpha.23 (2024-10-19)


### 🩹 Fixes

- detach if not windows ([5f0e94e](https://github.com/push-based/nx-verdaccio/commit/5f0e94e))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

## 0.0.0-alpha.22 (2024-10-18)


### 🩹 Fixes

- envRoot derivation in executor ([ae6b9aa](https://github.com/push-based/nx-verdaccio/commit/ae6b9aa))
- **nx-verdaccio:** move envRoot into executors ([3818fba](https://github.com/push-based/nx-verdaccio/commit/3818fba))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular
- Michael Hladky @BioPhoton

## 0.0.0-alpha.21 (2024-10-15)


### 🩹 Fixes

- remove detached ([558a25e](https://github.com/push-based/nx-verdaccio/commit/558a25e))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

## 0.0.0-alpha.20 (2024-10-15)


### 🩹 Fixes

- docs ([4921af8](https://github.com/push-based/nx-verdaccio/commit/4921af8))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

## 0.0.0-alpha.19 (2024-10-15)


### 🩹 Fixes

- deps ([daec92d](https://github.com/push-based/nx-verdaccio/commit/daec92d))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

## 0.0.0-alpha.18 (2024-10-15)


### 🩹 Fixes

- use info to log ([fce0cab](https://github.com/push-based/nx-verdaccio/commit/fce0cab))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

## 0.0.0-alpha.17 (2024-10-15)


### 🩹 Fixes

- forward params of nxv-e2e target ([8348d94](https://github.com/push-based/nx-verdaccio/commit/8348d94))

### ❤️ Thank You
### ❤️ Thank You
AdrianRomanski marked this conversation as resolved.
Show resolved Hide resolved

- Michael @rx-angular

## 0.0.0-alpha.16 (2024-10-15)


### 🩹 Fixes

- mark package ([8a0630b](https://github.com/push-based/nx-verdaccio/commit/8a0630b))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

## 0.0.0-alpha.15 (2024-10-15)


### 🩹 Fixes

- nx17 fix ([ebbfe6b](https://github.com/push-based/nx-verdaccio/commit/ebbfe6b))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

## 0.0.0-alpha.14 (2024-10-15)


### 🩹 Fixes

- version ([55a8bb1](https://github.com/push-based/nx-verdaccio/commit/55a8bb1))
- version 1 ([9cfa53e](https://github.com/push-based/nx-verdaccio/commit/9cfa53e))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

## 0.0.0-alpha.13 (2024-10-15)


### 🩹 Fixes

- add command to make it work in older nx versions ([8cca3b7](https://github.com/push-based/nx-verdaccio/commit/8cca3b7))
- add description ([9af5dd2](https://github.com/push-based/nx-verdaccio/commit/9af5dd2))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

## 0.0.0-alpha.12 (2024-10-14)


### 🩹 Fixes

- readme 3 ([7b2422b](https://github.com/push-based/nx-verdaccio/commit/7b2422b))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

## 0.0.0-alpha.11 (2024-10-14)


### 🩹 Fixes

- readme 2 ([2540ebd](https://github.com/push-based/nx-verdaccio/commit/2540ebd))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

## 0.0.0-alpha.10 (2024-10-14)


### 🩹 Fixes

- readme ([26f1b13](https://github.com/push-based/nx-verdaccio/commit/26f1b13))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

## 0.0.0-alpha.9 (2024-10-14)


### 🩹 Fixes

- deps ([ceeb41b](https://github.com/push-based/nx-verdaccio/commit/ceeb41b))
- deps ([4f5303e](https://github.com/push-based/nx-verdaccio/commit/4f5303e))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

## 0.0.0-alpha.8 (2024-10-14)


### 🚀 Features

- **nx-verdaccio:** update plugin to enable env-setup caching ([f129325](https://github.com/push-based/nx-verdaccio/commit/f129325))
Expand All @@ -234,13 +214,12 @@
- set default values for cacheSizeTasks and options in plugin ([b782914](https://github.com/push-based/nx-verdaccio/commit/b782914))
- mock exec implementation to handle callbacks in unit tests ([88ebbd4](https://github.com/push-based/nx-verdaccio/commit/88ebbd4))

### ❤️ Thank You
### ❤️ Thank You

- getlarge

## 0.0.0-alpha.7 (2024-10-13)


### 🚀 Features

- modify package json before publishing ([3faf91c](https://github.com/push-based/nx-verdaccio/commit/3faf91c))
Expand All @@ -255,31 +234,29 @@
- refactor testing API usage ([f3e4c29](https://github.com/push-based/nx-verdaccio/commit/f3e4c29))
- refactor testing ([7425758](https://github.com/push-based/nx-verdaccio/commit/7425758))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular
- Michael Hladky @BioPhoton

## 0.0.0-alpha.6 (2024-09-29)


### 🩹 Fixes

- make package public ([046a788](https://github.com/push-based/-nx-verdaccio-e2e-setup/commit/046a788))
- change JS esm module type to CommonJS ([9d9d60d](https://github.com/push-based/-nx-verdaccio-e2e-setup/commit/9d9d60d))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

## 0.0.0-alpha.5 (2024-09-29)


### 🩹 Fixes

- fix typo ([8830e1a](https://github.com/push-based/-nx-verdaccio-e2e-setup/commit/8830e1a))

### ❤️ Thank You
### ❤️ Thank You

- Michael @rx-angular

Expand Down
12 changes: 4 additions & 8 deletions projects/nx-verdaccio/src/plugin/caching.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import { hashObject } from 'nx/src/hasher/file-hasher';
import {
type ProjectConfiguration,
readJsonFile,
writeJsonFile,
} from '@nx/devkit';
import { existsSync } from 'node:fs';

export function cacheKey(prefix: string, hashData: Record<string, unknown>) {
return `${prefix}-${hashObject(hashData)}`;
}
import { cacheKey } from './utils/caching.utils';

export function getCacheRecord<T>(
targetsCache: Record<string, T>,
prefix: string,
hashData: Record<string, unknown>
) {
): T {
const targetCacheKey = cacheKey(prefix, hashData);

if (targetsCache[targetCacheKey]) {
Expand All @@ -28,7 +24,7 @@ export function setCacheRecord<T>(
prefix: string,
hashData: Record<string, unknown>,
cacheData: T
) {
): T {
const targetCacheKey = cacheKey(prefix, hashData);

return (targetsCache[targetCacheKey] = cacheData);
Expand All @@ -45,7 +41,7 @@ export function readTargetsCache(
export function writeTargetsToCache(
cachePath: string,
results: Record<string, Partial<ProjectConfiguration>>
) {
): void {
process.env.NX_CACHE_PROJECT_GRAPH !== 'false' &&
writeJsonFile(cachePath, results);
}
BioPhoton marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading