diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cf87d15..6434538 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,6 +42,7 @@ jobs: minimum-size: 4GB maximum-size: 8GB disk-root: ${{ matrix.disk-root }} + timeout: 120 # 2 minutes - name: validation shell: pwsh diff --git a/README.md b/README.md index b2257b6..158ad62 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,12 @@ This action is intended to configure Pagefile size and location for Windows images in GitHub Actions. # Available parameters -| Argument | Description | Format | Default value | -|----------|-------------|--------|---------------| -| `minimum-size` | Set minimum size of Pagefile | `2048MB`, `4GB`, `8GB` and etc. | `8GB` | -| `maximum-size` | Set maximum size of Pagefile | The same like `minimum-size` | `minimum-size` | -| `disk-root` | Set disk root where Pagefile will be located | `C:` or `D:` | `D:` | +| Argument | Description | Format | Default value | +| -------------- | -------------------------------------------- | ------------------------------- | -------------- | +| `minimum-size` | Set minimum size of Pagefile | `2048MB`, `4GB`, `8GB` and etc. | `8GB` | +| `maximum-size` | Set maximum size of Pagefile | The same like `minimum-size` | `minimum-size` | +| `disk-root` | Set disk root where Pagefile will be located | `C:` or `D:` | `D:` | +| `timeout` | Set disk root where Pagefile will be located | seconds e.g. `60` | `60` (1min) | # Usage ``` diff --git a/action.yml b/action.yml index 538d7b8..8edbbf8 100644 --- a/action.yml +++ b/action.yml @@ -13,6 +13,10 @@ inputs: description: 'Set disk root where pagefile.sys will be located' required: false default: 'D:' + timeout: + description: 'Timeout (in seconds) to use when performing pagesize configuration' + required: false + default: '60' runs: using: 'node12' main: 'dist/index.js' diff --git a/src/configure-pagefile.ts b/src/configure-pagefile.ts index 01599b3..8d4b12d 100644 --- a/src/configure-pagefile.ts +++ b/src/configure-pagefile.ts @@ -8,15 +8,21 @@ const run = (): void => { throw new Error(`This task is intended only for Windows platform. It can't be run on '${process.platform}' platform`); } + const minimumSize = core.getInput("minimum-size", { required: true }); const maximumSize = core.getInput("maximum-size", { required: false }) || minimumSize; const diskRoot = core.getInput("disk-root", { required: true }); + + const oneMinuteInSeconds: number = 60 * 1000; + const timeoutInSeconds: number = parseFloat(core.getInput("timeout", { required: false })) * 1000 || oneMinuteInSeconds; core.info("Pagefile configuration:"); core.info(`- Minimum size: ${minimumSize}`); core.info(`- Maximum size: ${maximumSize}`); core.info(`- Disk root: ${diskRoot}`); + core.info(`- Timeout (in seconds): ${timeoutInSeconds}`); + const timeoutInMilliseconds = timeoutInSeconds * 1000; const scriptPath = path.resolve(__dirname, "..", "scripts", "SetPageFileSize.ps1"); const scriptArguments = [ "-MinimumSize", minimumSize, @@ -28,7 +34,7 @@ const run = (): void => { core.debug(`Script arguments: ${scriptArguments}`); const scriptResult = child.spawnSync("powershell", [scriptPath, ...scriptArguments], { - timeout: 60 * 1000 + timeout: timeoutInMilliseconds }); if (scriptResult.stdout) { core.info(scriptResult.stdout.toString()); } if (scriptResult.stderr) { core.error(scriptResult.stderr.toString()); }