Unverified Commit 4b56f19b authored by Daz DeBoer's avatar Daz DeBoer Committed by GitHub
Browse files

Use pre-installed Gradle when available (#301)

Fixes #270
parents de6862d8 4576973c
Loading
Loading
Loading
Loading
−3
Changes for .github/workflows/integ-test-execution.yml: 0 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -24,9 +24,6 @@ jobs:
      fail-fast: false
      matrix:
        os: ${{fromJSON(inputs.runner-os)}}
        include:
          - os: windows-latest
            script-suffix: '.bat'
    runs-on: ${{ matrix.os }}
    steps:
    - name: Checkout sources
+4 −4
Changes for .github/workflows/integ-test-provision-gradle-versions.yml: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -25,9 +25,6 @@ jobs:
      fail-fast: false
      matrix:
        os: ${{fromJSON(inputs.runner-os)}}
        include:
          - os: windows-latest
            script-suffix: '.bat'
    runs-on: ${{ matrix.os }}
    steps:
    - name: Checkout sources
@@ -62,6 +59,9 @@ jobs:
      uses: ./setup-gradle
      with:
        gradle-version: current
    - name: Test use current
      working-directory: .github/workflow-samples/no-wrapper
      run: gradle help
    - name: Check current version output parameter
      if: ${{ !startsWith(steps.gradle-current.outputs.gradle-version , '8.') }}
      uses: actions/github-script@v7
@@ -73,7 +73,7 @@ jobs:
    strategy:
      fail-fast: false
      matrix:
        gradle: [7.3, 6.9, 5.6.4, 4.10.3, 3.5.1]
        gradle: [8.9, 8.8, 7.6.4, 6.9.4, 5.6.4, 4.10.3, 3.5.1] # 8.8 is the latest installed on windows runners
        os: ${{fromJSON(inputs.runner-os)}}
        include:
          - java-version: 11
+66 −13
Changes for sources/package-lock.json: 66 added lines, 13 removed lines.
Original line number Diff line number Diff line
@@ -23,12 +23,14 @@
        "semver": "7.6.0",
        "string-argv": "0.3.2",
        "typed-rest-client": "1.8.11",
        "unhomoglyph": "1.0.6"
        "unhomoglyph": "1.0.6",
        "which": "4.0.0"
      },
      "devDependencies": {
        "@types/jest": "29.5.12",
        "@types/node": "20.12.4",
        "@types/unzipper": "0.10.9",
        "@types/which": "3.0.4",
        "@typescript-eslint/parser": "7.5.0",
        "@vercel/ncc": "0.38.1",
        "eslint": "8.57.0",
@@ -2215,6 +2217,12 @@
        "@types/node": "*"
      }
    },
    "node_modules/@types/which": {
      "version": "3.0.4",
      "resolved": "https://registry.npmjs.org/@types/which/-/which-3.0.4.tgz",
      "integrity": "sha512-liyfuo/106JdlgSchJzXEQCVArk0CvevqPote8F8HgWgJ3dRCcTHgJIsLDuee0kxk/mhbInzIZk3QWSZJ8R+2w==",
      "dev": true
    },
    "node_modules/@types/yargs": {
      "version": "17.0.23",
      "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.23.tgz",
@@ -3694,6 +3702,21 @@
        "node": ">= 8"
      }
    },
    "node_modules/cross-spawn/node_modules/which": {
      "version": "2.0.2",
      "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
      "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
      "dev": true,
      "dependencies": {
        "isexe": "^2.0.0"
      },
      "bin": {
        "node-which": "bin/node-which"
      },
      "engines": {
        "node": ">= 8"
      }
    },
    "node_modules/crypto": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz",
@@ -8885,18 +8908,17 @@
      }
    },
    "node_modules/which": {
      "version": "2.0.2",
      "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
      "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
      "dev": true,
      "version": "4.0.0",
      "resolved": "https://registry.npmjs.org/which/-/which-4.0.0.tgz",
      "integrity": "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==",
      "dependencies": {
        "isexe": "^2.0.0"
        "isexe": "^3.1.1"
      },
      "bin": {
        "node-which": "bin/node-which"
        "node-which": "bin/which.js"
      },
      "engines": {
        "node": ">= 8"
        "node": "^16.13.0 || >=18.0.0"
      }
    },
    "node_modules/which-boxed-primitive": {
@@ -8949,6 +8971,14 @@
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/which/node_modules/isexe": {
      "version": "3.1.1",
      "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz",
      "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==",
      "engines": {
        "node": ">=16"
      }
    },
    "node_modules/wrap-ansi": {
      "version": "7.0.0",
      "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
@@ -10875,6 +10905,12 @@
        "@types/node": "*"
      }
    },
    "@types/which": {
      "version": "3.0.4",
      "resolved": "https://registry.npmjs.org/@types/which/-/which-3.0.4.tgz",
      "integrity": "sha512-liyfuo/106JdlgSchJzXEQCVArk0CvevqPote8F8HgWgJ3dRCcTHgJIsLDuee0kxk/mhbInzIZk3QWSZJ8R+2w==",
      "dev": true
    },
    "@types/yargs": {
      "version": "17.0.23",
      "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.23.tgz",
@@ -11882,6 +11918,17 @@
        "path-key": "^3.1.0",
        "shebang-command": "^2.0.0",
        "which": "^2.0.1"
      },
      "dependencies": {
        "which": {
          "version": "2.0.2",
          "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
          "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
          "dev": true,
          "requires": {
            "isexe": "^2.0.0"
          }
        }
      }
    },
    "crypto": {
@@ -15700,12 +15747,18 @@
      }
    },
    "which": {
      "version": "2.0.2",
      "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
      "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
      "dev": true,
      "version": "4.0.0",
      "resolved": "https://registry.npmjs.org/which/-/which-4.0.0.tgz",
      "integrity": "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==",
      "requires": {
        "isexe": "^2.0.0"
        "isexe": "^3.1.1"
      },
      "dependencies": {
        "isexe": {
          "version": "3.1.1",
          "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz",
          "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ=="
        }
      }
    },
    "which-boxed-primitive": {
+5 −3
Changes for sources/package.json: 5 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -45,12 +45,14 @@
    "semver": "7.6.0",
    "string-argv": "0.3.2",
    "typed-rest-client": "1.8.11",
    "unhomoglyph": "1.0.6"
    "unhomoglyph": "1.0.6",
    "which": "4.0.0"
  },
  "devDependencies": {
    "@types/jest": "29.5.12",
    "@types/node": "20.12.4",
    "@types/unzipper": "0.10.9",
    "@types/which": "3.0.4",
    "@typescript-eslint/parser": "7.5.0",
    "@vercel/ncc": "0.38.1",
    "eslint": "8.57.0",
@@ -59,11 +61,11 @@
    "eslint-plugin-prettier": "5.1.3",
    "jest": "29.7.0",
    "js-yaml": "4.1.0",
    "nock": "13.5.4",
    "npm-run-all": "4.1.5",
    "patch-package": "8.0.0",
    "prettier": "3.2.5",
    "ts-jest": "29.1.2",
    "typescript": "5.4.3",
    "nock": "13.5.4"
    "typescript": "5.4.3"
  }
}
+20
Changes for sources/src/execution/provision.ts: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
import * as fs from 'fs'
import * as os from 'os'
import * as path from 'path'
import which from 'which'
import * as httpm from '@actions/http-client'
import * as core from '@actions/core'
import * as cache from '@actions/cache'
import * as exec from '@actions/exec'
import * as toolCache from '@actions/tool-cache'

import * as gradlew from './gradlew'
@@ -95,6 +97,12 @@ async function findGradleVersionDeclaration(version: string): Promise<GradleVers

async function installGradleVersion(versionInfo: GradleVersionInfo): Promise<string> {
    return core.group(`Provision Gradle ${versionInfo.version}`, async () => {
        const preInstalledGradle = await findGradleVersionOnPath(versionInfo)
        if (preInstalledGradle !== undefined) {
            core.info(`Gradle version ${versionInfo.version} is already available on PATH. Not installing.`)
            return preInstalledGradle
        }

        return locateGradleAndDownloadIfRequired(versionInfo)
    })
}
@@ -184,3 +192,15 @@ interface GradleVersionInfo {
    version: string
    downloadUrl: string
}

async function findGradleVersionOnPath(versionInfo: GradleVersionInfo): Promise<string | undefined> {
    const gradleExecutable = await which('gradle', {nothrow: true})
    if (gradleExecutable) {
        const output = await exec.getExecOutput(gradleExecutable, ['-v'], {silent: true})
        if (output.stdout.includes(`Gradle ${versionInfo.version}`)) {
            return gradleExecutable
        }
    }

    return undefined
}