mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-10-21 00:08:55 +08:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
90ccf054e6 | ||
|
cb2742a00b | ||
|
c8c53f54bb | ||
|
863daedf86 | ||
|
55871cbb47 | ||
|
e3d60b3873 | ||
|
2dd6cc1801 | ||
|
c6b57b9c8c | ||
|
f11e7d60d7 | ||
|
7137b09ae2 | ||
|
053f389907 | ||
|
4f9b5202aa | ||
|
791b98c565 | ||
|
466a737d16 | ||
|
eb7eb78d95 |
29
.github/workflows/dev.yml
vendored
29
.github/workflows/dev.yml
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
# make sure the build works and doesn't produce spurious changes
|
||||||
name: dev
|
name: dev
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@@ -6,10 +7,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
check:
|
||||||
strategy:
|
runs-on: ubuntu-latest
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
@@ -17,19 +15,10 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
npm install
|
npm install
|
||||||
npm run all
|
npm run all
|
||||||
- name: Test wrapper
|
- name: Check for uncommitted changes
|
||||||
uses: ./
|
# Ensure no changes, but ignore node_modules dir since dev/fresh ci deps installed.
|
||||||
with:
|
run: |
|
||||||
wrapper-directory: __tests__/data/basic
|
git diff --exit-code --stat -- . ':!node_modules' \
|
||||||
build-root-directory: __tests__/data/basic
|
|| (echo "##[error] found changed files after build. please 'npm run all'" \
|
||||||
dependencies-cache-enabled: true
|
"and check in all changes" \
|
||||||
configuration-cache-enabled: true
|
&& exit 1)
|
||||||
arguments: test
|
|
||||||
- name: Test dist download
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
gradle-version: 6.6-milestone-1
|
|
||||||
build-root-directory: __tests__/data/basic
|
|
||||||
dependencies-cache-enabled: true
|
|
||||||
configuration-cache-enabled: true
|
|
||||||
arguments: test --configuration-cache
|
|
||||||
|
14
.github/workflows/prod.yml
vendored
14
.github/workflows/prod.yml
vendored
@@ -2,10 +2,8 @@
|
|||||||
name: prod
|
name: prod
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
pull_request:
|
||||||
push:
|
push:
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
- 'releases/*'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
check:
|
||||||
@@ -27,8 +25,16 @@ jobs:
|
|||||||
- name: Test dist download
|
- name: Test dist download
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
gradle-version: 6.6-milestone-1
|
gradle-version: rc
|
||||||
build-root-directory: __tests__/data/basic
|
build-root-directory: __tests__/data/basic
|
||||||
dependencies-cache-enabled: true
|
dependencies-cache-enabled: true
|
||||||
configuration-cache-enabled: true
|
configuration-cache-enabled: true
|
||||||
arguments: test --configuration-cache
|
arguments: test --configuration-cache
|
||||||
|
- name: Stop Gradle daemon
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
gradle-version: rc
|
||||||
|
build-root-directory: __tests__/data/basic
|
||||||
|
dependencies-cache-enabled: true
|
||||||
|
configuration-cache-enabled: true
|
||||||
|
arguments: --stop
|
||||||
|
@@ -147,11 +147,15 @@ Keep reading to learn how to better control how they work.
|
|||||||
Both the dependencies and configuration caches use the same default configuration:
|
Both the dependencies and configuration caches use the same default configuration:
|
||||||
|
|
||||||
They use the following inputs to calculate the cache key:
|
They use the following inputs to calculate the cache key:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
**/*.gradle
|
||||||
|
**/*.gradle.kts
|
||||||
|
**/gradle.properties
|
||||||
|
gradle/**
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This is a good enough approximation.
|
||||||
They restore cached state even if there isn't an exact match.
|
They restore cached state even if there isn't an exact match.
|
||||||
|
|
||||||
If the defaults don't suit your needs you can override them with the following inputs:
|
If the defaults don't suit your needs you can override them with the following inputs:
|
||||||
|
@@ -9,19 +9,19 @@ describe('cache', () => {
|
|||||||
'__tests__/data/basic/gradle/wrapper/gradle-wrapper.properties'
|
'__tests__/data/basic/gradle/wrapper/gradle-wrapper.properties'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
expect(version).toBe('6.5-bin')
|
expect(version).toBe('6.6.1-bin')
|
||||||
})
|
})
|
||||||
it('for -bin dist', async () => {
|
it('for -bin dist', async () => {
|
||||||
const version = cacheWrapper.extractGradleWrapperSlugFromDistUri(
|
const version = cacheWrapper.extractGradleWrapperSlugFromDistUri(
|
||||||
'distributionUrl=https\\://services.gradle.org/distributions/gradle-6.5-bin.zip'
|
'distributionUrl=https\\://services.gradle.org/distributions/gradle-6.6.1-bin.zip'
|
||||||
)
|
)
|
||||||
expect(version).toBe('6.5-bin')
|
expect(version).toBe('6.6.1-bin')
|
||||||
})
|
})
|
||||||
it('for -all dist', async () => {
|
it('for -all dist', async () => {
|
||||||
const version = cacheWrapper.extractGradleWrapperSlugFromDistUri(
|
const version = cacheWrapper.extractGradleWrapperSlugFromDistUri(
|
||||||
'distributionUrl=https\\://services.gradle.org/distributions/gradle-6.5-all.zip'
|
'distributionUrl=https\\://services.gradle.org/distributions/gradle-6.6.1-all.zip'
|
||||||
)
|
)
|
||||||
expect(version).toBe('6.5-all')
|
expect(version).toBe('6.6.1-all')
|
||||||
})
|
})
|
||||||
it('for milestone', async () => {
|
it('for milestone', async () => {
|
||||||
const version = cacheWrapper.extractGradleWrapperSlugFromDistUri(
|
const version = cacheWrapper.extractGradleWrapperSlugFromDistUri(
|
||||||
|
@@ -10,7 +10,7 @@ describe('crypto-utils', () => {
|
|||||||
expect(hash).toBe(
|
expect(hash).toBe(
|
||||||
process.platform === 'win32'
|
process.platform === 'win32'
|
||||||
? '3364336e94e746ce65a31748a6371b7efd7d499e18ad605c74c91cde0edc0a44'
|
? '3364336e94e746ce65a31748a6371b7efd7d499e18ad605c74c91cde0edc0a44'
|
||||||
: '4ebb65b45e6f6796d5ec6ace96e9471cc6573d294c54f99c4920fe5328e75bab'
|
: '63b9f14f65d014e585099c9c274b9dcbddf5cfd1a8978e5a24efb89ff9304348'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
it('a directory with a glob', async () => {
|
it('a directory with a glob', async () => {
|
||||||
@@ -21,7 +21,7 @@ describe('crypto-utils', () => {
|
|||||||
expect(hash).toBe(
|
expect(hash).toBe(
|
||||||
process.platform === 'win32'
|
process.platform === 'win32'
|
||||||
? '3364336e94e746ce65a31748a6371b7efd7d499e18ad605c74c91cde0edc0a44'
|
? '3364336e94e746ce65a31748a6371b7efd7d499e18ad605c74c91cde0edc0a44'
|
||||||
: '4ebb65b45e6f6796d5ec6ace96e9471cc6573d294c54f99c4920fe5328e75bab'
|
: '63b9f14f65d014e585099c9c274b9dcbddf5cfd1a8978e5a24efb89ff9304348'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
it('a directory with globs', async () => {
|
it('a directory with globs', async () => {
|
||||||
@@ -32,7 +32,7 @@ describe('crypto-utils', () => {
|
|||||||
expect(hash).toBe(
|
expect(hash).toBe(
|
||||||
process.platform === 'win32'
|
process.platform === 'win32'
|
||||||
? 'd9b66fded38f79f601ce745d64ed726a8df8c0b242b02bcd2c1d331f54742ad6'
|
? 'd9b66fded38f79f601ce745d64ed726a8df8c0b242b02bcd2c1d331f54742ad6'
|
||||||
: 'aa72a837158799fbadd1c4aff94fcc2b5bb9dc6ad8d12f6337d047d4b0c8f79e'
|
: 'f42cd10636f09799f4e01cc84e7ae906cc1d9140f1446f8dcd054d19cbc44c2b'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
2
dist/main/index.js
vendored
2
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/post/index.js
vendored
2
dist/post/index.js
vendored
File diff suppressed because one or more lines are too long
3869
package-lock.json
generated
3869
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@@ -24,30 +24,30 @@
|
|||||||
"author": "Paul Merlin <paul@nosphere.org>",
|
"author": "Paul Merlin <paul@nosphere.org>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "0.2.1",
|
"@actions/cache": "1.0.2",
|
||||||
"@actions/core": "1.2.4",
|
"@actions/core": "1.2.5",
|
||||||
"@actions/exec": "1.0.4",
|
"@actions/exec": "1.0.4",
|
||||||
"@actions/glob": "0.1.0",
|
"@actions/glob": "0.1.0",
|
||||||
"@actions/io": "1.0.2",
|
"@actions/io": "1.0.2",
|
||||||
"@actions/tool-cache": "1.5.5",
|
"@actions/tool-cache": "1.6.0",
|
||||||
"string-argv": "0.3.1",
|
"string-argv": "0.3.1",
|
||||||
"typed-rest-client": "1.7.3",
|
"typed-rest-client": "1.7.3",
|
||||||
"unzipper": "0.10.11"
|
"unzipper": "0.10.11"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "26.0.0",
|
"@types/jest": "26.0.13",
|
||||||
"@types/node": "12.12.6",
|
"@types/node": "12.12.6",
|
||||||
"@types/unzipper": "0.10.3",
|
"@types/unzipper": "0.10.3",
|
||||||
"@typescript-eslint/parser": "3.2.0",
|
"@typescript-eslint/parser": "4.1.0",
|
||||||
"@zeit/ncc": "0.22.3",
|
"@zeit/ncc": "0.22.3",
|
||||||
"eslint": "7.2.0",
|
"eslint": "7.9.0",
|
||||||
"eslint-plugin-github": "4.0.1",
|
"eslint-plugin-github": "4.1.1",
|
||||||
"eslint-plugin-jest": "23.13.2",
|
"eslint-plugin-jest": "24.0.1",
|
||||||
"jest": "26.0.1",
|
"jest": "26.4.2",
|
||||||
"jest-circus": "26.0.1",
|
"jest-circus": "26.4.2",
|
||||||
"js-yaml": "3.14.0",
|
"js-yaml": "3.14.0",
|
||||||
"prettier": "2.0.5",
|
"prettier": "2.1.1",
|
||||||
"ts-jest": "26.1.0",
|
"ts-jest": "26.3.0",
|
||||||
"typescript": "3.8.3"
|
"typescript": "4.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,7 @@ export async function restoreCachedConfiguration(
|
|||||||
if (isConfigurationCacheDisabled()) return
|
if (isConfigurationCacheDisabled()) return
|
||||||
|
|
||||||
const cachePath = path.resolve(rootDir, '.gradle/configuration-cache')
|
const cachePath = path.resolve(rootDir, '.gradle/configuration-cache')
|
||||||
|
if (fs.existsSync(cachePath)) return
|
||||||
core.saveState(CONFIGURATION_CACHE_PATH, cachePath)
|
core.saveState(CONFIGURATION_CACHE_PATH, cachePath)
|
||||||
|
|
||||||
const inputCacheExact = github.inputBoolean('configuration-cache-exact')
|
const inputCacheExact = github.inputBoolean('configuration-cache-exact')
|
||||||
|
@@ -18,6 +18,7 @@ export async function restoreCachedDependencies(
|
|||||||
if (isDependenciesCacheDisabled()) return
|
if (isDependenciesCacheDisabled()) return
|
||||||
|
|
||||||
const cachePath = path.resolve(os.homedir(), '.gradle/caches/modules-2')
|
const cachePath = path.resolve(os.homedir(), '.gradle/caches/modules-2')
|
||||||
|
if (fs.existsSync(cachePath)) return
|
||||||
core.saveState(DEPENDENCIES_CACHE_PATH, cachePath)
|
core.saveState(DEPENDENCIES_CACHE_PATH, cachePath)
|
||||||
|
|
||||||
const inputCacheExact = github.inputBoolean('dependencies-cache-exact')
|
const inputCacheExact = github.inputBoolean('dependencies-cache-exact')
|
||||||
|
@@ -26,29 +26,39 @@ export async function restoreCachedWrapperDist(
|
|||||||
if (!wrapperSlug) return
|
if (!wrapperSlug) return
|
||||||
|
|
||||||
const wrapperCacheKey = `wrapper-${wrapperSlug}`
|
const wrapperCacheKey = `wrapper-${wrapperSlug}`
|
||||||
const wrapperCachePath = path.join(
|
const wrapperCachePath = path.resolve(
|
||||||
os.homedir(),
|
os.homedir(),
|
||||||
`.gradle/wrapper/dists/gradle-${wrapperSlug}`
|
`.gradle/wrapper/dists/gradle-${wrapperSlug}`
|
||||||
)
|
)
|
||||||
|
if (fs.existsSync(wrapperCachePath)) return
|
||||||
|
|
||||||
core.saveState(WRAPPER_CACHE_KEY, wrapperCacheKey)
|
core.saveState(WRAPPER_CACHE_KEY, wrapperCacheKey)
|
||||||
core.saveState(WRAPPER_CACHE_PATH, wrapperCachePath)
|
core.saveState(WRAPPER_CACHE_PATH, wrapperCachePath)
|
||||||
|
|
||||||
const restoredKey = await cache.restoreCache(
|
try {
|
||||||
[wrapperCachePath],
|
const restoredKey = await cache.restoreCache(
|
||||||
wrapperCacheKey
|
[wrapperCachePath],
|
||||||
)
|
wrapperCacheKey
|
||||||
|
)
|
||||||
|
|
||||||
if (!restoredKey) {
|
if (!restoredKey) {
|
||||||
|
core.info(
|
||||||
|
'Wrapper installation cache not found, expect a Gradle distribution download.'
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
core.saveState(WRAPPER_CACHE_RESULT, restoredKey)
|
||||||
core.info(
|
core.info(
|
||||||
'Wrapper installation cache not found, expect a Gradle distribution download.'
|
`Wrapper installation restored from cache key: ${restoredKey}`
|
||||||
|
)
|
||||||
|
return
|
||||||
|
} catch (error) {
|
||||||
|
core.info(
|
||||||
|
`Wrapper installation cache restore failed, expect a Gradle distribution download\n ${error}`
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
core.saveState(WRAPPER_CACHE_RESULT, restoredKey)
|
|
||||||
core.info(`Wrapper installation restored from cache key: ${restoredKey}`)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function cacheWrapperDist(): Promise<void> {
|
export async function cacheWrapperDist(): Promise<void> {
|
||||||
|
@@ -18,12 +18,9 @@ export async function execute(
|
|||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
listeners: {
|
listeners: {
|
||||||
stdline: (line: string) => {
|
stdline: (line: string) => {
|
||||||
if (line.startsWith('Publishing build scan...')) {
|
if (line.includes('Publishing build scan...')) {
|
||||||
publishing = true
|
publishing = true
|
||||||
}
|
}
|
||||||
if (publishing && line.length === 0) {
|
|
||||||
publishing = false
|
|
||||||
}
|
|
||||||
if (publishing && line.startsWith('http')) {
|
if (publishing && line.startsWith('http')) {
|
||||||
buildScanUrl = line.trim()
|
buildScanUrl = line.trim()
|
||||||
publishing = false
|
publishing = false
|
||||||
|
@@ -41,9 +41,10 @@ async function gradleReleaseCandidate(): Promise<string> {
|
|||||||
const versionInfo = await gradleVersionDeclaration(
|
const versionInfo = await gradleVersionDeclaration(
|
||||||
`${gradleVersionsBaseUrl}/release-candidate`
|
`${gradleVersionsBaseUrl}/release-candidate`
|
||||||
)
|
)
|
||||||
if (versionInfo) {
|
if (versionInfo && versionInfo.version && versionInfo.downloadUrl) {
|
||||||
return provisionGradle(versionInfo.version, versionInfo.downloadUrl)
|
return provisionGradle(versionInfo.version, versionInfo.downloadUrl)
|
||||||
}
|
}
|
||||||
|
core.info('No current release-candidate found, will fallback to current')
|
||||||
return gradleCurrent()
|
return gradleCurrent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user