mirror of
https://code.forgejo.org/actions/setup-python
synced 2025-06-08 04:18:19 +02:00
Add another pip default dependency file for cache hash (#604)
This commit is contained in:
parent
869e769ec8
commit
7b9ef6fc5a
7 changed files with 98 additions and 18 deletions
|
@ -5,7 +5,7 @@ import * as exec from '@actions/exec';
|
|||
import * as io from '@actions/io';
|
||||
import {getCacheDistributor} from '../src/cache-distributions/cache-factory';
|
||||
import {State} from '../src/cache-distributions/cache-distributor';
|
||||
import * as utils from './../src/utils';
|
||||
import * as constants from '../src/cache-distributions/constants';
|
||||
|
||||
describe('restore-cache', () => {
|
||||
const pipFileLockHash =
|
||||
|
@ -196,11 +196,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
|||
30000
|
||||
);
|
||||
|
||||
it.each([
|
||||
['pip', '3.8.12', 'requirements-linux.txt', 'requirements-linux.txt'],
|
||||
['pip', '3.8.12', 'requirements.txt', 'requirements.txt'],
|
||||
['pipenv', '3.9.12', 'requirements.txt', 'requirements.txt']
|
||||
])(
|
||||
it.each([['pipenv', '3.9.12', 'requirements.txt', 'requirements.txt']])(
|
||||
'Should throw an error because dependency file is not found',
|
||||
async (
|
||||
packageManager,
|
||||
|
@ -213,6 +209,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
|||
pythonVersion,
|
||||
dependencyFile
|
||||
);
|
||||
|
||||
await expect(cacheDistributor.restoreCache()).rejects.toThrowError(
|
||||
`No file in ${process.cwd()} matched to [${cacheDependencyPath
|
||||
.split('\n')
|
||||
|
@ -220,6 +217,40 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
|||
);
|
||||
}
|
||||
);
|
||||
|
||||
it.each([
|
||||
['pip', '3.8.12', 'requirements-linux.txt'],
|
||||
['pip', '3.8.12', 'requirements.txt']
|
||||
])(
|
||||
'Shouldn`t throw an error as there is a default file `pyproject.toml` to use when requirements.txt is not specified',
|
||||
async (packageManager, pythonVersion, dependencyFile) => {
|
||||
const cacheDistributor = getCacheDistributor(
|
||||
packageManager,
|
||||
pythonVersion,
|
||||
dependencyFile
|
||||
);
|
||||
await expect(cacheDistributor.restoreCache()).resolves;
|
||||
}
|
||||
);
|
||||
|
||||
it.each([
|
||||
['pip', '3.8.12', 'requirements-linux.txt'],
|
||||
['pip', '3.8.12', 'requirements.txt']
|
||||
])(
|
||||
'Should throw an error as there is no default file `pyproject.toml` to use when requirements.txt is not specified',
|
||||
async (packageManager, pythonVersion, dependencyFile) => {
|
||||
jest.mock('../src/cache-distributions/constants', () => ({
|
||||
CACHE_DEPENDENCY_BACKUP_PATH: '**/pyprojecttest.toml'
|
||||
}));
|
||||
|
||||
const cacheDistributor = getCacheDistributor(
|
||||
packageManager,
|
||||
pythonVersion,
|
||||
dependencyFile
|
||||
);
|
||||
await expect(cacheDistributor.restoreCache()).resolves;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe('Dependencies changed', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue