File tree 5 files changed +107
-0
lines changed
5 files changed +107
-0
lines changed Original file line number Diff line number Diff line change 65
65
echo "::error::Should have failed"
66
66
exit 1
67
67
fi
68
+
69
+ version :
70
+ runs-on : ${{ matrix.os }}
71
+ strategy :
72
+ fail-fast : false
73
+ matrix :
74
+ os :
75
+ - ubuntu-latest
76
+ - ubuntu-22.04
77
+ - ubuntu-20.04
78
+ install :
79
+ - true
80
+ - false
81
+ steps :
82
+ -
83
+ name : Checkout
84
+ uses : actions/checkout@v4
85
+ -
86
+ name : Install QEMU
87
+ if : ${{ matrix.install }}
88
+ run : |
89
+ sudo apt-get update
90
+ sudo apt-get install -y qemu-user-static
91
+ -
92
+ name : QEMU bins
93
+ run : |
94
+ echo $PATH | tr ':' '\n' | xargs -I {} find {} -type f -executable -name "qemu*" || true
95
+ -
96
+ name : Set up QEMU
97
+ uses : ./
98
+ -
99
+ name : QEMU bins
100
+ run : |
101
+ echo $PATH | tr ':' '\n' | xargs -I {} find {} -type f -executable -name "qemu*" || true
Original file line number Diff line number Diff line change
1
+ import { describe , expect , jest , it } from '@jest/globals' ;
2
+ import * as io from '@actions/io' ;
3
+ import { Exec } from '@docker/actions-toolkit/lib/exec' ;
4
+
5
+ import * as qemu from '../src/qemu' ;
6
+
7
+ describe ( 'isInstalled' , ( ) => {
8
+ it ( 'bin' , async ( ) => {
9
+ const ioWhichSpy = jest . spyOn ( io , 'which' ) ;
10
+ await qemu . isInstalled ( ) ;
11
+ expect ( ioWhichSpy ) . toHaveBeenCalledTimes ( 1 ) ;
12
+ expect ( ioWhichSpy ) . toHaveBeenCalledWith ( qemu . bin ( ) , true ) ;
13
+ } ) ;
14
+ } ) ;
15
+
16
+ describe ( 'printVersion' , ( ) => {
17
+ it ( 'call qemu --version' , async ( ) => {
18
+ const execSpy = jest . spyOn ( Exec , 'exec' ) ;
19
+ await qemu . printVersion ( ) . catch ( ( ) => {
20
+ // noop
21
+ } ) ;
22
+ expect ( execSpy ) . toHaveBeenCalledWith ( qemu . bin ( ) , [ '--version' ] ) ;
23
+ } ) ;
24
+ } ) ;
Original file line number Diff line number Diff line change 26
26
"license" : " Apache-2.0" ,
27
27
"dependencies" : {
28
28
"@actions/core" : " ^1.10.1" ,
29
+ "@actions/io" : " ^1.1.3" ,
29
30
"@docker/actions-toolkit" : " ^0.16.1"
30
31
},
31
32
"devDependencies" : {
Original file line number Diff line number Diff line change 1
1
import * as context from './context' ;
2
+ import * as qemu from './qemu' ;
2
3
import * as core from '@actions/core' ;
3
4
import * as actionsToolkit from '@docker/actions-toolkit' ;
4
5
import { Docker } from '@docker/actions-toolkit/lib/docker/docker' ;
@@ -14,6 +15,14 @@ actionsToolkit.run(
14
15
async ( ) => {
15
16
const input : context . Inputs = context . getInputs ( ) ;
16
17
18
+ await core . group ( 'QEMU version' , async ( ) => {
19
+ if ( await qemu . isInstalled ( ) ) {
20
+ await qemu . printVersion ( ) ;
21
+ } else {
22
+ core . warning ( 'QEMU is not installed' ) ;
23
+ }
24
+ } ) ;
25
+
17
26
await core . group ( `Docker info` , async ( ) => {
18
27
await Docker . printVersion ( ) ;
19
28
await Docker . printInfo ( ) ;
Original file line number Diff line number Diff line change
1
+ import os from 'os' ;
2
+ import * as core from '@actions/core' ;
3
+ import * as io from '@actions/io' ;
4
+ import { Exec } from '@docker/actions-toolkit/lib/exec' ;
5
+
6
+ export async function isInstalled ( ) : Promise < boolean > {
7
+ return await io
8
+ . which ( bin ( ) , true )
9
+ . then ( res => {
10
+ core . debug ( `qemu.isInstalled ok: ${ res } ` ) ;
11
+ return true ;
12
+ } )
13
+ . catch ( error => {
14
+ core . debug ( `qemu.isInstalled error: ${ error } ` ) ;
15
+ return false ;
16
+ } ) ;
17
+ }
18
+
19
+ export async function printVersion ( ) : Promise < void > {
20
+ await Exec . exec ( bin ( ) , [ '--version' ] ) ;
21
+ }
22
+
23
+ export function bin ( ) : string {
24
+ return `qemu-system-${ arch ( ) } ` ;
25
+ }
26
+
27
+ function arch ( ) : string {
28
+ switch ( os . arch ( ) ) {
29
+ case 'x64' : {
30
+ return 'x86_64' ;
31
+ }
32
+ case 'arm64' : {
33
+ return 'aarch64' ;
34
+ }
35
+ default : {
36
+ return os . arch ( ) ;
37
+ }
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments