mirror of https://github.com/actions/setup-python
Compare commits
2 Commits
f85cf9a47f
...
7181375e65
Author | SHA1 | Date |
---|---|---|
Aarni Koskela | 7181375e65 | |
Aarni Koskela | 89052adf60 |
|
@ -15,7 +15,6 @@ describe('restore-cache', () => {
|
||||||
'2d0ff7f46b0e120e3d3294db65768b474934242637b9899b873e6283dfd16d7c';
|
'2d0ff7f46b0e120e3d3294db65768b474934242637b9899b873e6283dfd16d7c';
|
||||||
const poetryLockHash =
|
const poetryLockHash =
|
||||||
'f24ea1ad73968e6c8d80c16a093ade72d9332c433aeef979a0dd943e6a99b2ab';
|
'f24ea1ad73968e6c8d80c16a093ade72d9332c433aeef979a0dd943e6a99b2ab';
|
||||||
const uvLockHash = 'efe9f18aef431b3f1dbe13bee790b00095e74fb19aa5ced5ace96d063f03258d';
|
|
||||||
const poetryConfigOutput = `
|
const poetryConfigOutput = `
|
||||||
cache-dir = "/Users/patrick/Library/Caches/pypoetry"
|
cache-dir = "/Users/patrick/Library/Caches/pypoetry"
|
||||||
experimental.new-installer = false
|
experimental.new-installer = false
|
||||||
|
@ -154,13 +153,6 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
||||||
path.join(__dirname, 'data', 'inner', '.venv'),
|
path.join(__dirname, 'data', 'inner', '.venv'),
|
||||||
path.join(__dirname, 'data', '.venv')
|
path.join(__dirname, 'data', '.venv')
|
||||||
]
|
]
|
||||||
],
|
|
||||||
[
|
|
||||||
'uv',
|
|
||||||
'3.12.0',
|
|
||||||
'__tests__/data/**/pyproject.toml',
|
|
||||||
uvLockHash,
|
|
||||||
undefined,
|
|
||||||
]
|
]
|
||||||
])(
|
])(
|
||||||
'restored dependencies for %s by primaryKey',
|
'restored dependencies for %s by primaryKey',
|
||||||
|
@ -196,10 +188,6 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
||||||
result => result.value
|
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 => {
|
restoredKeys.forEach(restoredKey => {
|
||||||
if (restoredKey) {
|
if (restoredKey) {
|
||||||
if (process.platform === 'linux' && packageManager === 'pip') {
|
if (process.platform === 'linux' && packageManager === 'pip') {
|
||||||
|
|
|
@ -13,7 +13,6 @@ describe('run', () => {
|
||||||
'2d0ff7f46b0e120e3d3294db65768b474934242637b9899b873e6283dfd16d7c';
|
'2d0ff7f46b0e120e3d3294db65768b474934242637b9899b873e6283dfd16d7c';
|
||||||
const poetryLockHash =
|
const poetryLockHash =
|
||||||
'571bf984f8d210e6a97f854e479fdd4a2b5af67b5fdac109ec337a0ea16e7836';
|
'571bf984f8d210e6a97f854e479fdd4a2b5af67b5fdac109ec337a0ea16e7836';
|
||||||
const uvLockHash = 'TODO'; // TODO: what should be the correct value?
|
|
||||||
|
|
||||||
// core spy
|
// core spy
|
||||||
let infoSpy: jest.SpyInstance;
|
let infoSpy: jest.SpyInstance;
|
||||||
|
@ -203,34 +202,6 @@ describe('run', () => {
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
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 () => {
|
it('saves with -1 cacheId , should not fail workflow', async () => {
|
||||||
inputs['cache'] = 'poetry';
|
inputs['cache'] = 'poetry';
|
||||||
inputs['python-version'] = '3.10.0';
|
inputs['python-version'] = '3.10.0';
|
||||||
|
|
|
@ -90737,8 +90737,8 @@ class UvCache extends cache_distributor_1.default {
|
||||||
this.patterns = patterns;
|
this.patterns = patterns;
|
||||||
}
|
}
|
||||||
getCacheGlobalDirectories() {
|
getCacheGlobalDirectories() {
|
||||||
|
var _a;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
var _a;
|
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
// `LOCALAPPDATA` should always be defined,
|
// `LOCALAPPDATA` should always be defined,
|
||||||
// but we can't just join `undefined`
|
// but we can't just join `undefined`
|
||||||
|
@ -90753,7 +90753,7 @@ class UvCache extends cache_distributor_1.default {
|
||||||
computeKeys() {
|
computeKeys() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const hash = yield glob.hashFiles(this.patterns);
|
const hash = yield glob.hashFiles(this.patterns);
|
||||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||||
const restoreKey = undefined;
|
const restoreKey = undefined;
|
||||||
return {
|
return {
|
||||||
primaryKey,
|
primaryKey,
|
||||||
|
|
|
@ -26,7 +26,7 @@ export default class UvCache extends CacheDistributor {
|
||||||
|
|
||||||
protected async computeKeys() {
|
protected async computeKeys() {
|
||||||
const hash = await glob.hashFiles(this.patterns);
|
const hash = await glob.hashFiles(this.patterns);
|
||||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||||
const restoreKey = undefined;
|
const restoreKey = undefined;
|
||||||
return {
|
return {
|
||||||
primaryKey,
|
primaryKey,
|
||||||
|
|
Loading…
Reference in New Issue