Skip to content

Commit

Permalink
Merge branch 'master' into es/aarch64/int8
Browse files Browse the repository at this point in the history
  • Loading branch information
alvoron committed Nov 14, 2024
2 parents 5dbd319 + a661f0d commit 03315bf
Show file tree
Hide file tree
Showing 2,724 changed files with 174,086 additions and 110,443 deletions.
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ body:
- Caffe
- ONNX
- PyTorch
- mxnet
- PaddlePaddle
validations:
required: false
Expand Down
63 changes: 62 additions & 1 deletion .github/actions/cache/__tests__/cleanup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ const getInputMock = jest.spyOn(core, 'getInput').mockImplementation();
const setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation();

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'test-cleanup-'));
const cacheRemotePath = path.join(tempDir, 'cache_remote');
const cacheRemotePath = path.join(
tempDir,
'subdir_1',
'subdir_2',
'cache_remote'
);

const cacheFiles = ['cache_1.cache', 'cache_2.cache', 'cache_3.cache'];
const minAccessTime = 7 * 24 * 60 * 60 * 1000; // 1 week
Expand Down Expand Up @@ -283,4 +288,60 @@ describe('cleanup', () => {
// check that sub directory exists
expect(fs.existsSync(cacheSubPath)).toBe(true);
});

it('Cleanup directory with subdirectories and files (recursive=true)', async () => {
const cacheSubPath = path.join(tempDir, 'subdir_1');
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'cache-path':
return cacheSubPath;
case 'restore-keys':
return 'cache';
case 'cache-size':
return 1;
case 'recursive':
return true;
default:
return '';
}
});

await cleanupImpl.cleanUp();

expect(runMock).toHaveReturned();
// cache2 and cache3 should be removed
for (const cache of cacheFiles.slice(1, 2)) {
expect(fs.existsSync(path.join(cacheRemotePath, cache))).toBe(false);
}
// check that file1 exists
expect(fs.existsSync(path.join(cacheRemotePath, cacheFiles[0]))).toBe(true);
});

it('Cleanup directory with subdirectories and files (recursive=false)', async () => {
const cacheSubPath = path.join(tempDir, 'subdir_1');
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'cache-path':
return cacheSubPath;
case 'restore-keys':
return 'cache';
case 'cache-size':
return 1;
case 'recursive':
return false;
default:
return '';
}
});

await cleanupImpl.cleanUp();

expect(runMock).toHaveReturned();
// cache2 and cache3 should be removed
for (const cache of cacheFiles) {
expect(fs.existsSync(path.join(cacheRemotePath, cache))).toBe(true);
}
});
});
6 changes: 5 additions & 1 deletion .github/actions/cache/__tests__/save.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ describe('save', () => {

it('Cache files: absent remote cache dir', async () => {
// Set the action's inputs as return values from core.getInput()
const cacheRemotePathAbsent = path.join(tempDir, 'cache_remote_absent');
const cacheRemotePathAbsent = path.join(
tempDir,
'cache_remote_absent',
'subdir'
);
getInputMock.mockImplementation(name => {
switch (name) {
case 'cache-path':
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/cache/cleanup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ inputs:
evicted to limit the total cache storage'
default: 50
required: false
recursive:
description: 'Scan the current directory only or all subdirectories'
default: false
required: false

runs:
using: 'node20'
Expand Down
Loading

0 comments on commit 03315bf

Please sign in to comment.