Skip to content

Commit

Permalink
fixup! 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 794e0fa commit c795021
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 71 deletions.
136 changes: 68 additions & 68 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,31 +284,31 @@ jobs:
# hypervisor: qemu
# shutdown_vm: false
# run: dmesg | grep -i avx2
#
# test-no-vm-shutdown:
# timeout-minutes: 5
# name: Test not shutting down the VM
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# persist-credentials: false
#
# - name: Test
# uses: ./
# with:
# operating_system: freebsd
# architecture: x86-64
# version: '13.2'
# hypervisor: qemu
# shutdown_vm: false
# run: true
#
# - name: Verify VM is still running
# run: ps aux | grep -v grep | grep -q qemu
#

test-no-vm-shutdown:
timeout-minutes: 5
name: Test not shutting down the VM
runs-on: ubuntu-latest

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

- name: Test
uses: ./
with:
operating_system: freebsd
architecture: x86-64
version: '13.2'
hypervisor: qemu
shutdown_vm: false
run: true

- name: Verify VM is still running
run: ps aux | grep -v grep | grep -q qemu

# test-vm-shutdown:
# timeout-minutes: 5
# name: Test shutting down the VM
Expand Down Expand Up @@ -377,49 +377,49 @@ jobs:
#
# - name: Run after
# run: ${{ matrix.data.run_after }}

multiple-steps:
timeout-minutes: 5
name: Test running the action multiple times
runs-on: macos-latest

strategy:
fail-fast: false
matrix:
hypervisor: [qemu, xhyve]

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

- name: Run action first time
uses: ./
with:
operating_system: freebsd
architecture: x86-64
version: '13.2'
hypervisor: ${{ matrix.hypervisor }}
shutdown_vm: false
run: touch foo.txt

- name: Verify VM is still running
run: ps aux | grep -v grep | grep -q -v qemu

- name: Verify file is synced back
run: test -f foo.txt

- name: Run action second time
uses: ./
with:
operating_system: freebsd
architecture: x86-64
version: '13.2'
hypervisor: qemu
shutdown_vm: true
run: test -f foo.txt

#
# multiple-steps:
# timeout-minutes: 5
# name: Test running the action multiple times
# runs-on: macos-latest
#
# strategy:
# fail-fast: false
# matrix:
# hypervisor: [qemu, xhyve]
#
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# persist-credentials: false
#
# - name: Run action first time
# uses: ./
# with:
# operating_system: freebsd
# architecture: x86-64
# version: '13.2'
# hypervisor: ${{ matrix.hypervisor }}
# shutdown_vm: false
# run: touch foo.txt
#
# - name: Verify VM is still running
# run: ps aux | grep -v grep | grep -q -v qemu
#
# - name: Verify file is synced back
# run: test -f foo.txt
#
# - name: Run action second time
# uses: ./
# with:
# operating_system: freebsd
# architecture: x86-64
# version: '13.2'
# hypervisor: qemu
# shutdown_vm: true
# run: test -f foo.txt
#
# openbsd-qemu-macos:
# timeout-minutes: 5
# name: Test OpenBSD with QEMU on macOS runner
Expand Down
6 changes: 5 additions & 1 deletion 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 src/qemu_vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export abstract class Vm extends vm.Vm {

'-display', 'none',
'-monitor', 'none',
'-chardev', 'stdio,id=char0,logfile=/tmp/cross-platform-actions.log,signal=off',
'-chardev', `stdio,id=char0,logfile=${this.logFile},signal=off`,
'-serial', 'chardev:char0',
// '-nographic',

Expand Down
6 changes: 6 additions & 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 Expand Up @@ -105,6 +106,11 @@ export abstract class Vm {
async run(): Promise<void> {
core.info('Booting VM of type: ' + this.constructor.name)
core.debug(this.command.join(' '))

// eagerly create the log file to get correct permissions since the VM will
// be running as root
fs.writeFileSync(this.logFile, '')

this.vmProcess = spawn('sudo', this.command, {
detached: false,
stdio: ['ignore', 'inherit', 'inherit']
Expand Down

0 comments on commit c795021

Please sign in to comment.