9
9
type :
10
10
required : true
11
11
type : string
12
- ref :
13
- required : true
14
- type : string
15
12
16
13
concurrency :
17
- group : qemu-${{ inputs .ref }}-${{ inputs.chip }}-${{ inputs.type }}
14
+ group : qemu-${{ github.event.pull_request.number || github .ref }}-${{ inputs.chip }}-${{ inputs.type }}
18
15
cancel-in-progress : true
19
16
20
17
env :
21
18
QEMU_INSTALL_PATH : " $HOME"
22
19
23
20
jobs :
24
21
qemu-test :
25
- name : ${{ inputs.chip }} - QEMU ${{ inputs.type }} tests
22
+ name : QEMU ${{ inputs.chip }} ${{ inputs.type }} tests
23
+ env :
24
+ id : ${{ github.event.pull_request.number || github.ref }}-${{ inputs.chip }}-${{ inputs.type }}-${{ github.event.pull_request.head.sha || github.sha }}
26
25
runs-on : ubuntu-latest
27
26
steps :
27
+ - name : Check if already run
28
+ if : ${{ github.event.pull_request.number != null }}
29
+ id : get-cache-results
30
+ uses : actions/cache/restore@v4
31
+ with :
32
+ lookup-only : true
33
+ key : tests-qemu-${{ env.id }}
34
+ path : |
35
+ tests/**/*.xml
36
+ tests/**/result_*.json
37
+
38
+ - name : Evaluate if tests should be run
39
+ id : check-tests
40
+ run : |
41
+ cache_exists=${{ steps.get-cache-results.outputs.cache-hit == 'true' || false }}
42
+ enabled=true
43
+
44
+ if [[ $cache_exists == 'true' ]]; then
45
+ echo "Already ran, skipping"
46
+ enabled=false
47
+ fi
48
+
49
+ echo "enabled=$enabled" >> $GITHUB_OUTPUT
50
+
28
51
- name : Checkout repository
29
52
uses : actions/checkout@v4
53
+ if : steps.check-tests.outputs.enabled == 'true'
54
+ with :
55
+ ref : ${{ github.event.pull_request.head.sha || github.sha }}
30
56
31
57
- name : Get QEMU version
32
58
uses :
pozetroninc/[email protected]
59
+ if : steps.check-tests.outputs.enabled == 'true'
33
60
id : get-qemu-version
34
61
with :
35
62
token : ${{secrets.GITHUB_TOKEN}}
40
67
- name : Cache tools
41
68
id : cache-linux
42
69
uses : actions/cache@v4
70
+ if : steps.check-tests.outputs.enabled == 'true'
43
71
with :
44
72
path : |
45
73
~/qemu
@@ -49,13 +77,14 @@ jobs:
49
77
' .github/workflows/tests.yml' ) }}
50
78
51
79
- name : Install dependencies
80
+ if : steps.check-tests.outputs.enabled == 'true'
52
81
run : |
53
82
pip install -U pip
54
83
pip install -r tests/requirements.txt --extra-index-url https://dl.espressif.com/pypi
55
84
sudo apt update && sudo apt install libpixman-1-0 libnuma1 libglib2.0-0 libslirp0 libsdl2-2.0-0
56
85
57
86
- name : Download QEMU
58
- if : steps.cache-linux.outputs.cache-hit != 'true'
87
+ if : steps.cache-linux.outputs.cache-hit != 'true' && steps.check-tests.outputs.enabled == 'true'
59
88
run : |
60
89
cd ${{ env.QEMU_INSTALL_PATH }}
61
90
underscore_release=$(echo ${{ steps.get-qemu-version.outputs.release }} | sed 's/\-/_/g')
@@ -66,22 +95,27 @@ jobs:
66
95
rm qemu-*
67
96
echo "QEMU_PATH=${{ env.QEMU_INSTALL_PATH }}/qemu" >> $GITHUB_ENV
68
97
69
- - name : Download ${{inputs.chip}}-${{inputs.type}} artifacts
70
- uses : actions/download-artifact@v4
98
+ - name : Get binaries
99
+ if : steps.check-tests.outputs.enabled == 'true'
100
+ id : cache-build-binaries
101
+ uses : actions/cache/restore@v4
71
102
with :
72
- name : ${{inputs.chip}}-${{inputs.type}}.artifacts
73
- path : ~/
103
+ fail-on-cache-miss : true
104
+ key : tests-bin-${{ env.id }}
105
+ path : |
106
+ ~/.arduino/tests/**/build*.tmp/*.bin
107
+ ~/.arduino/tests/**/build*.tmp/*.elf
108
+ ~/.arduino/tests/**/build*.tmp/*.json
74
109
75
110
- name : Run Tests
76
- run : QEMU_PATH="${{env.QEMU_PATH}}" bash .github/scripts/tests_run.sh -c -type ${{inputs.type}} -t ${{inputs.chip}} -Q
77
-
111
+ if : steps.check-tests.outputs.enabled == 'true'
112
+ run : QEMU_PATH="${{ env.QEMU_INSTALL_PATH }}" bash .github/scripts/tests_run.sh -c -type ${{inputs.type}} -t ${{inputs.chip}} -i 0 -m 1 -Q
78
113
79
- - name : Upload test result artifacts
80
- uses : actions/upload-artifact @v4
81
- if : ${{ always() }}
114
+ - name : Upload ${{ inputs.chip }} ${{ inputs.type }} QEMU results as cache
115
+ uses : actions/cache/save @v4
116
+ if : ${{ always() && steps.check-tests.outputs.enabled == 'true' }}
82
117
with :
83
- name : qemu_results-${{inputs.chip}}-${{inputs.type}}}
84
- if-no-files-found : error
118
+ key : tests-qemu-${{ env.id }}
85
119
path : |
86
120
tests/**/*.xml
87
121
tests/**/result_*.json
0 commit comments