Skip to content

Commit

Permalink
✨ Set GROOVY_HOME environment variable (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
WtfJoke authored Aug 5, 2023
1 parent b953a55 commit d7c9eb0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "CI"
name: 'CI'
on:
pull_request:
push:
Expand All @@ -11,7 +11,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
node-version-file: '.nvmrc'
- run: |
yarn install
- run: |
Expand All @@ -28,5 +28,7 @@ jobs:
- uses: ./
with:
groovy-version: 4.x
- name: Echo GROOVY_HOME
run: echo $GROOVY_HOME
- name: Display groovy version
run: groovy --version
2 changes: 2 additions & 0 deletions __tests__/setup-groovy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ describe('setup-groovy', () => {
jest.spyOn(core, 'getInput').mockReturnValue(version)

const groovyPath = await setupGroovy()
const groovyHome = path.dirname(groovyPath)

expect(groovyPath.endsWith(groovyExecutableFolderName)).toBe(true)
expect(await existsSync(path.join(groovyPath, 'groovy'))).toBe(true)
expect(process.env['GROOVY_HOME']).toBe(groovyHome)
}
)

Expand Down
9 changes: 8 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions src/setup-groovy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import {getInput, debug, addPath, error as coreError} from '@actions/core'
import {
getInput,
debug,
addPath,
error as coreError,
exportVariable
} from '@actions/core'
import {downloadTool, extractZip} from '@actions/tool-cache'
import {lt} from 'semver'
import {getMatchingVersion} from './release'
import path from 'path'

const GROOVY_BASE_URL =
'https://groovy.jfrog.io/artifactory/dist-release-local/groovy-zips'
Expand All @@ -27,7 +34,14 @@ export const setupGroovyVersion = async (version: string) => {
const groovyBinaryFileName = getFileName(matchingVersion)
const url = `${GROOVY_BASE_URL}/${groovyBinaryFileName}`
const groovyRootPath = await downloadGroovy(url)
const groovyBinaryPath = `${groovyRootPath}/groovy-${matchingVersion}/bin`
const groovyBinaryPath = path.join(
groovyRootPath,
`groovy-${matchingVersion}`,
'bin'
)
const groovyHomePath = path.dirname(groovyBinaryPath)
debug(`Setting 'GROOVY_HOME' environment variable to: ${groovyHomePath}`)
exportVariable('GROOVY_HOME', groovyHomePath)
debug(`Adding '${groovyBinaryPath}' to PATH`)
addPath(groovyBinaryPath)
return groovyBinaryPath
Expand Down

0 comments on commit d7c9eb0

Please sign in to comment.