Skip to content

Commit cd89f46

Browse files
Endi327Ivan Zosimov
andauthored
Add versions properties to cache (actions#280)
* Add versions properties to cache * lint fix npm run format change * [FIX] unit test * docs: fix typo in the Readme.md * docs: update link to the toolkit/cache package --------- Co-authored-by: Ivan Zosimov <ivan.zosimov@Ivans-MacBook-Pro.local>
1 parent 4fb3975 commit cd89f46

File tree

5 files changed

+5198
-5176
lines changed

5 files changed

+5198
-5176
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ Currently, the following distributions are supported:
113113
**NOTE:** For Azul Zulu OpenJDK architectures x64 and arm64 are mapped to x86 / arm with proper hw_bitness.
114114

115115
### Caching packages dependencies
116-
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are gradle, maven and sbt. The format of the used cache key is `setup-java-${{ platform }}-${{ packageManager }}-${{ fileHash }}`, where the hash is based on the following files:
117-
- gradle: `**/*.gradle*`, `**/gradle-wrapper.properties`, `buildSrc/**/Versions.kt`, `buildSrc/**/Dependencies.kt`, and `gradle/*.versions.toml`
116+
The action has a built-in functionality for caching and restoring dependencies. It uses [toolkit/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are gradle, maven and sbt. The format of the used cache key is `setup-java-${{ platform }}-${{ packageManager }}-${{ fileHash }}`, where the hash is based on the following files:
117+
- gradle: `**/*.gradle*`, `**/gradle-wrapper.properties`, `buildSrc/**/Versions.kt`, `buildSrc/**/Dependencies.kt`, `gradle/*.versions.toml`, and `**/versions.properties`
118118
- maven: `**/pom.xml`
119119
- sbt: all sbt build definition files `**/*.sbt`, `**/project/build.properties`, `**/project/**.scala`, `**/project/**.sbt`
120120

__tests__/cache.test.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('dependency cache', () => {
102102
await expect(restore('gradle')).rejects.toThrow(
103103
`No file in ${projectRoot(
104104
workspace
105-
)} matched to [**/*.gradle*,**/gradle-wrapper.properties,buildSrc/**/Versions.kt,buildSrc/**/Dependencies.kt,gradle/*.versions.toml], make sure you have checked out the target repository`
105+
)} matched to [**/*.gradle*,**/gradle-wrapper.properties,buildSrc/**/Versions.kt,buildSrc/**/Dependencies.kt,gradle/*.versions.toml,**/versions.properties], make sure you have checked out the target repository`
106106
);
107107
});
108108
it('downloads cache based on build.gradle', async () => {
@@ -179,6 +179,14 @@ describe('dependency cache', () => {
179179
expect(firstCall).not.toBe(thirdCall);
180180
});
181181
});
182+
it('downloads cache based on versions.properties', async () => {
183+
createFile(join(workspace, 'versions.properties'));
184+
185+
await restore('gradle');
186+
expect(spyCacheRestore).toHaveBeenCalled();
187+
expect(spyWarning).not.toHaveBeenCalled();
188+
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
189+
});
182190
});
183191
describe('save', () => {
184192
let spyCacheSave: jest.SpyInstance<
@@ -333,6 +341,17 @@ describe('dependency cache', () => {
333341
expect.stringMatching(/^Cache saved with the key:.*/)
334342
);
335343
});
344+
it('uploads cache based on versions.properties', async () => {
345+
createFile(join(workspace, 'versions.properties'));
346+
createStateForSuccessfulRestore();
347+
348+
await save('gradle');
349+
expect(spyCacheSave).toHaveBeenCalled();
350+
expect(spyWarning).not.toHaveBeenCalled();
351+
expect(spyInfo).toHaveBeenCalledWith(
352+
expect.stringMatching(/^Cache saved with the key:.*/)
353+
);
354+
});
336355
});
337356
});
338357
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy