Skip to content

Commit

Permalink
Add post run that prints VM output
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-carlborg committed Feb 17, 2024
1 parent c04fd7f commit e99ff3c
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ inputs:
runs:
using: node20
main: dist/index.js
post: dist/post.mjs

branding:
icon: play-circle
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Add support for FreeBSD 14.0 ([#74](https://github.com/cross-platform-actions/action/issues/74))
- Add post run step that prints the VM output

### Fixed
- OpenBSD VM fails during "Initializing VM" with QEMU on macOS ([#73](https://github.com/cross-platform-actions/action/issues/73))
Expand Down
2 changes: 2 additions & 0 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.

5 changes: 5 additions & 0 deletions dist/post.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"format": "prettier --write '**/*.ts'",
"format-check": "prettier --check '**/*.ts'",
"lint": "eslint src/**/*.ts",
"package": "ncc build --source-map --license licenses.txt",
"package": "npm run package:main && npm run package:post",
"package:main": "ncc build --source-map --license licenses.txt",
"package:post": "cp post/main.mjs dist/post.mjs",
"test": "jasmine",
"all": "npm run build && npm run format && npm run lint && npm run package && npm test"
},
Expand Down
5 changes: 5 additions & 0 deletions post/main.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {existsSync} from 'fs'
import {spawnSync} from 'child_process'

if (existsSync('/tmp/cross-platform-actions.log'))
spawnSync('sudo', ['cat', '/tmp/cross-platform-actions.log'], {stdio: 'inherit'})
1 change: 1 addition & 0 deletions src/qemu_vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export abstract class Vm extends vm.Vm {

'-display', 'none',
'-monitor', 'none',
'-serial', `file:${this.logFile}`,
// '-nographic',

'-boot', 'strict=off',
Expand Down
1 change: 1 addition & 0 deletions src/vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export abstract class Vm {
private static _isRunning?: boolean

readonly hypervisorPath: fs.PathLike
protected readonly logFile: fs.PathLike = '/tmp/cross-platform-actions.log'
protected vmProcess: Process = new LiveProcess()
protected readonly architecture: architecture.Architecture
protected readonly configuration: vm.Configuration
Expand Down

0 comments on commit e99ff3c

Please sign in to comment.