-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Improve cache service availability determination and change failure log levels #2100
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
Open
Copilot
wants to merge
11
commits into
main
Choose a base branch
from
copilot/fix-2099
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+170
−52
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
be5a2ce
Initial plan
Copilot 3c90578
Improve cache service availability determination and change warnings …
Copilot 513216f
Fix tests to expect errors instead of warnings for cache failures
Copilot cf3aaeb
Update tests to expect warnings instead of errors for non-5xx cache f…
Copilot bbc6082
Add .nx/ to .gitignore to exclude build cache files
Copilot c51178a
Implement 5xx server error detection and fix most cache tests
Copilot bab3dcf
Complete PR feedback implementation: all cache tests passing
Copilot d48d6b6
Remove logCacheError function and implement inline 5xx error detectio…
Copilot 89397db
Restore server error test and confirm logCacheError function removal
Copilot bd54a24
Fix v1 cache service to only check ACTIONS_CACHE_URL
Copilot a0907ed
Remove .nx/ from .gitignore as requested
Copilot 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
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 |
---|---|---|
@@ -1,14 +1,69 @@ | ||
import * as cache from '../src/cache' | ||
|
||
test('isFeatureAvailable returns true if server url is set', () => { | ||
try { | ||
describe('isFeatureAvailable', () => { | ||
const originalEnv = process.env | ||
|
||
beforeEach(() => { | ||
jest.resetModules() | ||
process.env = {...originalEnv} | ||
// Clean cache-related environment variables | ||
delete process.env['ACTIONS_CACHE_URL'] | ||
delete process.env['ACTIONS_RESULTS_URL'] | ||
delete process.env['ACTIONS_CACHE_SERVICE_V2'] | ||
delete process.env['GITHUB_SERVER_URL'] | ||
}) | ||
|
||
afterAll(() => { | ||
process.env = originalEnv | ||
}) | ||
|
||
test('returns true for cache service v1 when ACTIONS_CACHE_URL is set', () => { | ||
process.env['ACTIONS_CACHE_URL'] = 'http://cache.com' | ||
expect(cache.isFeatureAvailable()).toBe(true) | ||
} finally { | ||
delete process.env['ACTIONS_CACHE_URL'] | ||
} | ||
}) | ||
}) | ||
|
||
test('returns false for cache service v1 when only ACTIONS_RESULTS_URL is set', () => { | ||
process.env['ACTIONS_RESULTS_URL'] = 'http://results.com' | ||
expect(cache.isFeatureAvailable()).toBe(false) | ||
}) | ||
|
||
test('returns true for cache service v1 when both URLs are set', () => { | ||
process.env['ACTIONS_CACHE_URL'] = 'http://cache.com' | ||
process.env['ACTIONS_RESULTS_URL'] = 'http://results.com' | ||
expect(cache.isFeatureAvailable()).toBe(true) | ||
}) | ||
|
||
test('returns true for cache service v2 when ACTIONS_RESULTS_URL is set', () => { | ||
process.env['ACTIONS_CACHE_SERVICE_V2'] = 'true' | ||
process.env['ACTIONS_RESULTS_URL'] = 'http://results.com' | ||
expect(cache.isFeatureAvailable()).toBe(true) | ||
}) | ||
|
||
test('returns false for cache service v2 when only ACTIONS_CACHE_URL is set', () => { | ||
process.env['ACTIONS_CACHE_SERVICE_V2'] = 'true' | ||
process.env['ACTIONS_CACHE_URL'] = 'http://cache.com' | ||
expect(cache.isFeatureAvailable()).toBe(false) | ||
}) | ||
|
||
test('returns false when no cache URLs are set', () => { | ||
expect(cache.isFeatureAvailable()).toBe(false) | ||
}) | ||
|
||
test('returns false for cache service v2 when no URLs are set', () => { | ||
process.env['ACTIONS_CACHE_SERVICE_V2'] = 'true' | ||
expect(cache.isFeatureAvailable()).toBe(false) | ||
}) | ||
|
||
test('returns true for GHES with v1 even when v2 flag is set', () => { | ||
process.env['GITHUB_SERVER_URL'] = 'https://my-enterprise.github.com' | ||
process.env['ACTIONS_CACHE_SERVICE_V2'] = 'true' | ||
process.env['ACTIONS_CACHE_URL'] = 'http://cache.com' | ||
expect(cache.isFeatureAvailable()).toBe(true) | ||
}) | ||
|
||
test('isFeatureAvailable returns false if server url is not set', () => { | ||
expect(cache.isFeatureAvailable()).toBe(false) | ||
test('returns false for GHES with only ACTIONS_RESULTS_URL', () => { | ||
process.env['GITHUB_SERVER_URL'] = 'https://my-enterprise.github.com' | ||
process.env['ACTIONS_RESULTS_URL'] = 'http://results.com' | ||
expect(cache.isFeatureAvailable()).toBe(false) | ||
}) | ||
}) |
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
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.