Skip to content

Commit d7c9eb0

Browse files
authored
✨ Set GROOVY_HOME environment variable (#56)
1 parent b953a55 commit d7c9eb0

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

.github/workflows/test.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "CI"
1+
name: 'CI'
22
on:
33
pull_request:
44
push:
@@ -11,7 +11,7 @@ jobs:
1111
- name: Setup Node.js
1212
uses: actions/setup-node@v3
1313
with:
14-
node-version-file: ".nvmrc"
14+
node-version-file: '.nvmrc'
1515
- run: |
1616
yarn install
1717
- run: |
@@ -28,5 +28,7 @@ jobs:
2828
- uses: ./
2929
with:
3030
groovy-version: 4.x
31+
- name: Echo GROOVY_HOME
32+
run: echo $GROOVY_HOME
3133
- name: Display groovy version
3234
run: groovy --version

__tests__/setup-groovy.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ describe('setup-groovy', () => {
2525
jest.spyOn(core, 'getInput').mockReturnValue(version)
2626

2727
const groovyPath = await setupGroovy()
28+
const groovyHome = path.dirname(groovyPath)
2829

2930
expect(groovyPath.endsWith(groovyExecutableFolderName)).toBe(true)
3031
expect(await existsSync(path.join(groovyPath, 'groovy'))).toBe(true)
32+
expect(process.env['GROOVY_HOME']).toBe(groovyHome)
3133
}
3234
)
3335

dist/index.js

+8-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/setup-groovy.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
import {getInput, debug, addPath, error as coreError} from '@actions/core'
1+
import {
2+
getInput,
3+
debug,
4+
addPath,
5+
error as coreError,
6+
exportVariable
7+
} from '@actions/core'
28
import {downloadTool, extractZip} from '@actions/tool-cache'
39
import {lt} from 'semver'
410
import {getMatchingVersion} from './release'
11+
import path from 'path'
512

613
const GROOVY_BASE_URL =
714
'https://groovy.jfrog.io/artifactory/dist-release-local/groovy-zips'
@@ -27,7 +34,14 @@ export const setupGroovyVersion = async (version: string) => {
2734
const groovyBinaryFileName = getFileName(matchingVersion)
2835
const url = `${GROOVY_BASE_URL}/${groovyBinaryFileName}`
2936
const groovyRootPath = await downloadGroovy(url)
30-
const groovyBinaryPath = `${groovyRootPath}/groovy-${matchingVersion}/bin`
37+
const groovyBinaryPath = path.join(
38+
groovyRootPath,
39+
`groovy-${matchingVersion}`,
40+
'bin'
41+
)
42+
const groovyHomePath = path.dirname(groovyBinaryPath)
43+
debug(`Setting 'GROOVY_HOME' environment variable to: ${groovyHomePath}`)
44+
exportVariable('GROOVY_HOME', groovyHomePath)
3145
debug(`Adding '${groovyBinaryPath}' to PATH`)
3246
addPath(groovyBinaryPath)
3347
return groovyBinaryPath

0 commit comments

Comments
 (0)