Skip to content

Commit

Permalink
Allow specifying custom image url
Browse files Browse the repository at this point in the history
Signed-off-by: Aisha Tammy <floss@bsd.ac>
  • Loading branch information
epsilon-0 authored and jacob-carlborg committed Aug 4, 2023
1 parent 35286f1 commit 12af1e9
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 11 deletions.
21 changes: 20 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ jobs:
uname_hardware: ${{ matrix.architecture.uname || matrix.architecture.name }}
work_directory: ${{ matrix.host.work_directory }}


NetBSD:
name: NetBSD ${{ matrix.architecture.name }} ${{ matrix.version }} on ${{ matrix.host.name }}
runs-on: ${{ matrix.host.name }}
Expand Down Expand Up @@ -214,3 +213,23 @@ jobs:
version: '13.1'
hypervisor: qemu
run: sysctl hw.model

test-custom-vm-image:
timeout-minutes: 5
name: Test custom VM image
runs-on: macos-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false

- name: Test
uses: ./
with:
operating_system: openbsd
architecture: x86-64
version: '7.3'
image_url: https://github.com/cross-platform-actions/test-custom-image-builder/releases/download/v1.0.0/openbsd-7.3-x86-64.qcow2
run: test -f /foo
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ inputs:
hypervisor:
required: false
description: The hypervisor to use when starting the virtual machine
image_url:
required: false
description: URL for running the action with a custom image.
default: ''

runs:
using: node16
Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Add support for custom image URLs ([#13](https://github.com/cross-platform-actions/action/pull/13))

## [0.17.0] - 2023-07-25
### Changed
Expand Down
12 changes: 10 additions & 2 deletions 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.

2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ This section lists the available inputs for the action.
| `memory` | ❌ | `6G` or `13G` | string | The amount of memory for the virtual machine. The default value is `6G` for Linux runners and `13G` for macOS runners. |
| `cpu_count` | ❌ | `2` or `3` cores | integer | The number of CPU cores for the virtual machine. The default value is `2` for Linux runners and `3` for macOS runners. |
| `hypervisor` | ❌ | `xhyve` or `qemu` | string | The hypervisor to use for running the virtual machine. For Linux runners the only valid value is `qemu`. For macOS runners the default for OpenBSD and FreeBSD is `xhyve` for all other platforms the default is `qemu`. |

| `image_url` | ❌ | ❌ | string | URL a custom VM image that should be used in place of the default ones. |

All inputs are expected to be of the specified type. It's especially important
that you specify `version` as a string, using single or
Expand Down
12 changes: 6 additions & 6 deletions src/action/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ export class Action {
}

async downloadDiskImage(): Promise<string> {
core.info(
`Downloading disk image: ${this.operatingSystem.virtualMachineImageUrl}`
)
const result = await cache.downloadTool(
this.operatingSystem.virtualMachineImageUrl
)
const imageURL =
this.input.imageURL !== ''
? this.input.imageURL
: this.operatingSystem.virtualMachineImageUrl
core.info(`Downloading disk image: ${imageURL}`)
const result = await cache.downloadTool(imageURL)
core.info(`Downloaded file: ${result}`)

return result
Expand Down
6 changes: 6 additions & 0 deletions src/action/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class Input {
private run_?: string
private operatingSystem_?: os.Kind
private version_?: string
private imageURL_?: string
private shell_?: Shell
private environmentVariables_?: string
private architecture_?: architecture.Kind
Expand All @@ -28,6 +29,11 @@ export class Input {
}))
}

get imageURL(): string {
if (this.imageURL_ !== undefined) return this.imageURL_
return (this.imageURL_ = core.getInput('image_url'))
}

get operatingSystem(): os.Kind {
if (this.operatingSystem_ !== undefined) return this.operatingSystem_
const input = core.getInput('operating_system', {required: true})
Expand Down

0 comments on commit 12af1e9

Please sign in to comment.