Repository navigation
feat(orchestrator): cacheMode, move-dir default #311
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e699602
feat(orchestrator): cacheMode, move-dir default
webbertakken 905714a
fix(orchestrator): shared cacheMode, safe fallback
webbertakken d50ad50
fix(orchestrator): reject unknown cache modes
webbertakken 74f78fd
build(orchestrator): @types/node 20 to match engines
webbertakken ac496fa
build: refresh bun.lock for @types/node 20
webbertakken b6b953a
fix(cache): tombstone a source before removing it
webbertakken 093469c
fix(cache): stage every directory copy
webbertakken 1841827
fix(orchestrator): warn on localCacheMode in CLI
webbertakken 19b2866
Merge main into feat/orchestrator-cache-mode
webbertakken b592b12
fix(cache): keep sweeping past a stuck leftover
webbertakken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
plugins/orchestrator/src/model/orchestrator/services/cache/cache-mode.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { deprecatedCacheModeWarning, resolveCacheMode } from './cache-mode'; | ||
|
|
||
| describe('resolveCacheMode', () => { | ||
| it('defaults to move-directory', () => { | ||
| expect(resolveCacheMode()).toBe('move-directory'); | ||
| expect(resolveCacheMode('', '')).toBe('move-directory'); | ||
| }); | ||
|
|
||
| it('prefers cacheMode over the deprecated localCacheMode', () => { | ||
| expect(resolveCacheMode('tar', 'copy-directory')).toBe('tar'); | ||
| expect(resolveCacheMode('', 'copy-directory')).toBe('copy-directory'); | ||
| }); | ||
|
|
||
| it('rejects an unknown mode instead of running it as a directory move', () => { | ||
| expect(() => resolveCacheMode('move-dir')).toThrow("unknown mode 'move-dir'"); | ||
| expect(() => resolveCacheMode('', 'Tar')).toThrow("unknown mode 'Tar'"); | ||
| }); | ||
|
|
||
| it('rejects the removed canonical-overlay mode, also through the deprecated alias', () => { | ||
| expect(() => resolveCacheMode('canonical-overlay')).toThrow( | ||
| 'canonical-overlay has been removed', | ||
| ); | ||
| expect(() => resolveCacheMode('', 'canonical-overlay')).toThrow( | ||
| 'canonical-overlay has been removed', | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('deprecatedCacheModeWarning', () => { | ||
| it('warns only when the deprecated localCacheMode is used without cacheMode', () => { | ||
| expect(deprecatedCacheModeWarning('', 'tar')).toContain("use 'cacheMode' instead"); | ||
| expect(deprecatedCacheModeWarning('tar', 'copy-directory')).toBeUndefined(); | ||
| expect(deprecatedCacheModeWarning('tar', '')).toBeUndefined(); | ||
| expect(deprecatedCacheModeWarning()).toBeUndefined(); | ||
| }); | ||
| }); |
51 changes: 51 additions & 0 deletions
51
plugins/orchestrator/src/model/orchestrator/services/cache/cache-mode.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import type { LocalCacheMode } from './local-cache-service'; | ||
|
|
||
| const supportedCacheModes: readonly LocalCacheMode[] = ['move-directory', 'copy-directory', 'tar']; | ||
|
|
||
| /** | ||
| * Resolves the cache mode both entry points (the GitHub Action and | ||
| * `game-ci orchestrate`) run with: `cacheMode` first, then its deprecated alias | ||
| * `localCacheMode`, then `move-directory`. Anything else, including the removed | ||
| * `canonical-overlay` mode or a typo, fails loudly rather than silently running | ||
| * as a directory move. | ||
| */ | ||
| export function resolveCacheMode( | ||
| cacheMode?: string, | ||
| legacyLocalCacheMode?: string, | ||
| ): LocalCacheMode { | ||
| const mode = cacheMode || legacyLocalCacheMode || 'move-directory'; | ||
|
|
||
| if (mode === 'canonical-overlay') { | ||
| throw new Error( | ||
| 'cacheMode: canonical-overlay has been removed. ' + | ||
| "Use 'move-directory' (recommended for retained runners/build farms) or 'tar' " + | ||
| '(recommended for remote/ephemeral caches, or combine with rclone/S3 built-in ' + | ||
| 'container hooks - see the caching docs for details).', | ||
| ); | ||
| } | ||
|
|
||
| if (!supportedCacheModes.includes(mode as LocalCacheMode)) { | ||
| throw new Error( | ||
| `cacheMode: unknown mode '${mode}'. Use one of: ${supportedCacheModes.join(', ')}.`, | ||
| ); | ||
| } | ||
|
|
||
| return mode as LocalCacheMode; | ||
| } | ||
|
|
||
| /** | ||
| * The warning to show when only the deprecated `localCacheMode` alias is set, | ||
| * or undefined when `cacheMode` is used (or neither is). | ||
| */ | ||
| export function deprecatedCacheModeWarning( | ||
| cacheMode?: string, | ||
| legacyLocalCacheMode?: string, | ||
| ): string | undefined { | ||
| if (cacheMode || !legacyLocalCacheMode) return undefined; | ||
|
|
||
| return ( | ||
| "'localCacheMode' is deprecated: use 'cacheMode' instead. 'local' no longer describes " + | ||
| 'this setting now that distributed rclone/S3 caching is a supported mode too. ' + | ||
| 'localCacheMode keeps working for now; see game-ci/roadmap#11.' | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.