Skip to content

Commit

Permalink
Merge tag 'v0.18.0' into merge
Browse files Browse the repository at this point in the history
Release 0.18.0

Added
- Add support for custom image URLs ([cross-platform-actions#13](cross-platform-actions#13))
- Add architecture alias for x86-64: x64 ([cross-platform-actions#58](cross-platform-actions#58))
  • Loading branch information
korli committed Mar 15, 2024
2 parents 0f84c50 + 476a1a8 commit ba5c563
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 16 deletions.
21 changes: 20 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,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 @@ -228,3 +227,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
10 changes: 8 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.18.0] - 2023-08-04
### Added
- Add support for custom image URLs ([#13](https://github.com/cross-platform-actions/action/pull/13))
- Add architecture alias for x86-64: x64 ([#58](https://github.com/cross-platform-actions/action/issues/58))

## [0.17.0] - 2023-07-25
### Changed
- Bump QEMU to 8.0.3 ([resources#3](https://github.com/cross-platform-actions/resources/pull/4))
Expand Down Expand Up @@ -118,9 +123,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Initial release

[Unreleased]: https://github.com/cross-platform-actions/action/compare/v0.17.0...HEAD
[Unreleased]: https://github.com/cross-platform-actions/action/compare/v0.18.0...HEAD

[0.16.0]: https://github.com/cross-platform-actions/action/compare/v0.16.0...v0.17.0
[0.18.0]: https://github.com/cross-platform-actions/action/compare/v0.17.0...v0.18.0
[0.17.0]: https://github.com/cross-platform-actions/action/compare/v0.16.0...v0.17.0
[0.16.0]: https://github.com/cross-platform-actions/action/compare/v0.15.0...v0.16.0
[0.15.0]: https://github.com/cross-platform-actions/action/compare/v0.14.0...v0.15.0
[0.14.0]: https://github.com/cross-platform-actions/action/compare/v0.13.0...v0.14.0
Expand Down
13 changes: 11 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.

37 changes: 36 additions & 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 All @@ -138,6 +138,29 @@ same) and the GitHub action will only see `13` instead of `13.0`. The solution
is to explicitly state that a string is required by using quotes: `version:
'13.0'`.

#### Custom VM Image (`image_url`)

With the `image_url` input it's possible to specify a custom virtual machine
image. The main reason for this feature is to do additional custom
provisioning, like installing additional packages. This allows to pre-install
everything that is needed for a CI job beforhand, which can save time later
when the job is run.

Only existing operating systems, architectures and versions are supported.

##### Building a Custom VM Image

1. Fork one of the existing [*builder repositories ](https://github.com/cross-platform-actions/?q=builder)
1. Add the additional provisioning to the `resources/custom.sh` script. Don't
remove any existing provisioning scripts.
1. Adjust the CI workflow to remove any unwanted architectures or versions
1. Create and push a new tag
1. This will launch the CI workflow, build the image(s) and create a draft
GitHub release. The VM image(s) are automatically attached to the release
1. Edit the release to publish it
1. Copy the URL for the VM image
1. Use the URL with the `image_url` input

## `Supported Platforms`

This sections lists the currently supported platforms by operating system. Each
Expand Down Expand Up @@ -170,6 +193,18 @@ operating system will list which versions are supported.
| 9.3 ||
| 9.2 ||

### Architectures

This section lists the supported architectures and any aliases. All the names
are case insensitive. For a combination of supported architectures and
operating systems, see the sections for each operating system above.

| Architecture | Aliases |
|--------------|-----------------|
| `arm64` | `aarch64` |
| `x86-64` | `x86_64`, `x64` |
| | |

### Hypervisors

This section lists the available hypervisors, which platforms they can run and
Expand Down
18 changes: 15 additions & 3 deletions spec/architecture.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,31 @@ describe('toKind', () => {

describe('ARM64', () => {
it('returns the arm64 architecture', () => {
expect(architecture.toKind('arm64')).toBe(architecture.Kind.arm64)
expect(architecture.toKind('ARM64')).toBe(architecture.Kind.arm64)
})
})

describe('x86_64', () => {
describe('x86-64', () => {
it('returns the x86_64 architecture', () => {
expect(architecture.toKind('x86-64')).toBe(architecture.Kind.x86_64)
})
})

describe('x86_64', () => {
it('returns the x86_64 architecture', () => {
expect(architecture.toKind('x86_64')).toBe(architecture.Kind.x86_64)
})
})

describe('X64', () => {
it('returns the x86_64 architecture', () => {
expect(architecture.toKind('x64')).toBe(architecture.Kind.x86_64)
})
})

describe('X86_64', () => {
it('returns the x86_64 architecture', () => {
expect(architecture.toKind('x86-64')).toBe(architecture.Kind.x86_64)
expect(architecture.toKind('X86_64')).toBe(architecture.Kind.x86_64)
})
})

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
1 change: 1 addition & 0 deletions src/architecture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,6 @@ const architectureMap: Record<string, Kind> = {
aarch64: Kind.arm64,
'x86-64': Kind.x86_64,
x86_64: Kind.x86_64,
x64: Kind.x86_64,
x86: Kind.x86
} as const

0 comments on commit ba5c563

Please sign in to comment.