Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes timeout parameter configurable #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
minimum-size: 4GB
maximum-size: 8GB
disk-root: ${{ matrix.disk-root }}
timeout: 120 # 2 minutes

- name: validation
shell: pwsh
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 7 additions & 1 deletion src/configure-pagefile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()); }
Expand Down