Skip to content

Commit

Permalink
Fix 9: Allow OpenBSD to run on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-carlborg committed May 31, 2022
1 parent 3a0c0bf commit cad4964
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 46 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,27 @@ jobs:
uname:
hardware: amd64

- name: OpenBSD
version: '6.8'
host: ubuntu-latest
workDirectory: /home/runner/work/action/action
uname:
hardware: amd64

- name: OpenBSD
version: '6.9'
host: macos-10.15
workDirectory: /Users/runner/work/action/action
uname:
hardware: amd64

- name: OpenBSD
version: '6.9'
host: ubuntu-latest
workDirectory: /home/runner/work/action/action
uname:
hardware: amd64

- name: NetBSD
version: '9.2'
host: ubuntu-latest
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 running OpenBSD on Linux ([#8](https://github.com/cross-platform-actions/action/issues/9))

## [0.4.0] - 2022-05-10
### Added
Expand Down
76 changes: 37 additions & 39 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 @@ -113,7 +113,7 @@ they can run.

| Runner | OpenBSD | FreeBSD | NetBSD |
| ----------------- | ------- | ------- | ------ |
| **Linux** | | ✓ | ✓ |
| **Linux** | | ✓ | ✓ |
| **macos-10.15** | ✓ | ✓ | ✗ |

## Under the Hood
Expand Down
2 changes: 1 addition & 1 deletion src/architecture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const architectures: ReadonlyMap<Kind, Architecture> = (() => {
machineType: 'pc',
accelerator:
host.kind === host.Kind.darwin ? vm.Accelerator.hvf : vm.Accelerator.tcg,
resourceUrl: `${resourceBaseUrl}v0.4.0/qemu-system-x86_64-${hostString}.tar`
resourceUrl: `${resourceBaseUrl}v0.5.0/qemu-system-x86_64-${hostString}.tar`
})

return map
Expand Down
6 changes: 3 additions & 3 deletions src/operating_system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export abstract class OperatingSystem {
readonly architecture: architecture.Architecture

private static readonly resourceUrls = ResourceUrls.create()
protected readonly xhyveHypervisorUrl = `${OperatingSystem.resourceUrls.resourceBaseUrl}v0.3.1/xhyve-macos.tar`
protected readonly xhyveHypervisorUrl = `${OperatingSystem.resourceUrls.resourceBaseUrl}v0.5.0/xhyve-macos.tar`

private readonly version: string

Expand All @@ -51,7 +51,7 @@ export abstract class OperatingSystem {

constructor(name: string, arch: architecture.Architecture, version: string) {
const hostString = host.toString(host.kind)
this.resourcesUrl = `${OperatingSystem.resourceUrls.resourceBaseUrl}v0.3.1/resources-${hostString}.tar`
this.resourcesUrl = `${OperatingSystem.resourceUrls.resourceBaseUrl}v0.5.0/resources-${hostString}.tar`
this.name = name
this.version = version
this.architecture = arch
Expand Down Expand Up @@ -342,7 +342,7 @@ class OpenBsd extends OperatingSystem {
}

get virtualMachineImageReleaseVersion(): string {
return 'v0.2.0'
return 'v0.2.1'
}

createVirtualMachine(
Expand Down
11 changes: 10 additions & 1 deletion src/qemu_vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ export abstract class Vm extends vm.Vm {
'-smp', `cpus=${this.configuration.cpuCount},sockets=${this.configuration.cpuCount}`,
'-m', this.configuration.memory,

'-device', 'virtio-net,netdev=user.0',
'-device', `${this.netDevive},netdev=user.0`,
'-netdev', `user,id=user.0,hostfwd=tcp::${this.configuration.ssHostPort}-:22`,

'-display', 'none',
'-monitor', 'none',
// '-nographic',

'-boot', 'strict=off',
/* eslint-disable @typescript-eslint/no-non-null-assertion */
Expand All @@ -54,6 +55,10 @@ export abstract class Vm extends vm.Vm {
'-drive', `if=none,file=${this.configuration.resourcesDiskImage},id=drive1,cache=writeback,discard=ignore,format=raw`,
]
}

protected get netDevive(): string {
return 'virtio-net'
}
}

export class FreeBsd extends Vm {
Expand Down Expand Up @@ -88,6 +93,10 @@ export class OpenBsd extends Vm {
return this.defaultHardDriveFlags
}

protected override get netDevive(): string {
return 'e1000'
}

protected override async shutdown(): Promise<void> {
await this.execute('sudo shutdown -h -p now')
}
Expand Down

0 comments on commit cad4964

Please sign in to comment.