mirror of
https://github.com/actions/setup-python
synced 2024-11-30 21:22:28 +08:00
Compare commits
2 Commits
7181375e65
...
f85cf9a47f
Author | SHA1 | Date | |
---|---|---|---|
|
f85cf9a47f | ||
|
d9e42e5be0 |
@ -15,6 +15,7 @@ describe('restore-cache', () => {
|
||||
'2d0ff7f46b0e120e3d3294db65768b474934242637b9899b873e6283dfd16d7c';
|
||||
const poetryLockHash =
|
||||
'f24ea1ad73968e6c8d80c16a093ade72d9332c433aeef979a0dd943e6a99b2ab';
|
||||
const uvLockHash = 'efe9f18aef431b3f1dbe13bee790b00095e74fb19aa5ced5ace96d063f03258d';
|
||||
const poetryConfigOutput = `
|
||||
cache-dir = "/Users/patrick/Library/Caches/pypoetry"
|
||||
experimental.new-installer = false
|
||||
@ -153,6 +154,13 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
||||
path.join(__dirname, 'data', 'inner', '.venv'),
|
||||
path.join(__dirname, 'data', '.venv')
|
||||
]
|
||||
],
|
||||
[
|
||||
'uv',
|
||||
'3.12.0',
|
||||
'__tests__/data/**/pyproject.toml',
|
||||
uvLockHash,
|
||||
undefined,
|
||||
]
|
||||
])(
|
||||
'restored dependencies for %s by primaryKey',
|
||||
@ -188,6 +196,10 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
||||
result => result.value
|
||||
);
|
||||
|
||||
if(!restoredKeys.length) {
|
||||
throw new Error("No restored keys found, this probably means there's something wrong with the test");
|
||||
}
|
||||
|
||||
restoredKeys.forEach(restoredKey => {
|
||||
if (restoredKey) {
|
||||
if (process.platform === 'linux' && packageManager === 'pip') {
|
||||
|
@ -13,6 +13,7 @@ describe('run', () => {
|
||||
'2d0ff7f46b0e120e3d3294db65768b474934242637b9899b873e6283dfd16d7c';
|
||||
const poetryLockHash =
|
||||
'571bf984f8d210e6a97f854e479fdd4a2b5af67b5fdac109ec337a0ea16e7836';
|
||||
const uvLockHash = 'TODO'; // TODO: what should be the correct value?
|
||||
|
||||
// core spy
|
||||
let infoSpy: jest.SpyInstance;
|
||||
@ -202,6 +203,34 @@ describe('run', () => {
|
||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('saves cache from uv', async () => {
|
||||
inputs['cache'] = 'uv';
|
||||
inputs['python-version'] = '3.12.0';
|
||||
getStateSpy.mockImplementation((name: string) => {
|
||||
if (name === State.CACHE_MATCHED_KEY) {
|
||||
console.log(name);
|
||||
return uvLockHash;
|
||||
} else if (name === State.CACHE_PATHS) {
|
||||
return JSON.stringify([__dirname]);
|
||||
} else {
|
||||
return requirementsHash;
|
||||
}
|
||||
});
|
||||
|
||||
await run();
|
||||
|
||||
expect(getInputSpy).toHaveBeenCalled();
|
||||
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||
`Cache hit occurred on the primary key ${uvLockHash}, not saving cache.`
|
||||
);
|
||||
expect(saveCacheSpy).toHaveBeenCalled();
|
||||
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||
`Cache saved with the key: ${requirementsHash}`
|
||||
);
|
||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('saves with -1 cacheId , should not fail workflow', async () => {
|
||||
inputs['cache'] = 'poetry';
|
||||
inputs['python-version'] = '3.10.0';
|
||||
|
4
dist/setup/index.js
vendored
4
dist/setup/index.js
vendored
@ -90737,8 +90737,8 @@ class UvCache extends cache_distributor_1.default {
|
||||
this.patterns = patterns;
|
||||
}
|
||||
getCacheGlobalDirectories() {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
if (process.platform === 'win32') {
|
||||
// `LOCALAPPDATA` should always be defined,
|
||||
// but we can't just join `undefined`
|
||||
@ -90753,7 +90753,7 @@ class UvCache extends cache_distributor_1.default {
|
||||
computeKeys() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const hash = yield glob.hashFiles(this.patterns);
|
||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||
const restoreKey = undefined;
|
||||
return {
|
||||
primaryKey,
|
||||
|
@ -26,7 +26,7 @@ export default class UvCache extends CacheDistributor {
|
||||
|
||||
protected async computeKeys() {
|
||||
const hash = await glob.hashFiles(this.patterns);
|
||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||
const restoreKey = undefined;
|
||||
return {
|
||||
primaryKey,
|
||||
|
Loading…
Reference in New Issue
Block a user