Skip to content

Commit 068c803

Browse files
authored
Merge pull request #80 from mathoudebine/feature/integration-test-github
Add themes matrix for system monitor tests, run tests on Windows and MacOS as well
2 parents b374f3b + 0f8d778 commit 068c803

8 files changed

+260
-74
lines changed
Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
name: Integration tests - simple program run
1+
name: Simple program (Linux)
22

33
on: [push, pull_request]
44

55
jobs:
66
simple-program:
77

88
runs-on: ubuntu-latest
9+
910
strategy:
1011
fail-fast: false
1112
matrix:
@@ -25,44 +26,25 @@ jobs:
2526
2627
- name: Run simple-program.py during 20 seconds
2728
run: |
29+
# For tests there is no real HW: use simulated LCD mode
2830
sed -i 's/^REVISION.*$/REVISION=\"SIMU\"/g' simple-program.py
29-
python3 simple-program.py > tests.log 2>&1 &
31+
32+
# Run the program for 20s
33+
python3 simple-program.py > output.log 2>&1 &
3034
sleep 20
31-
killall -9 python3
3235
33-
- name: View output
36+
- name: Check output for errors
3437
run: |
3538
echo "######## Output : ########"
36-
cat tests.log
37-
38-
- name: Check output for exceptions
39-
run: |
40-
if grep -q Exception tests.log; then
39+
cat output.log
40+
41+
if grep -qi "error" output.log; then
4142
echo "Program failed to run, see output above"
4243
false
43-
fi
44-
if grep -q Traceback tests.log; then
45-
echo "Program failed to run, see output above"
46-
false
47-
fi
48-
49-
- name: Run default configuration
50-
run: |
51-
sed -i "/REVISION:/c\ REVISION: SIMU" config.yaml
52-
timeout --preserve-status 20s python3 main.py > tests.log 2>&1
53-
54-
- name: View output
55-
run: |
56-
echo "######## Output : ########"
57-
cat tests.log
58-
59-
- name: Check output for exceptions
60-
run: |
61-
if grep -q Exception tests.log; then
44+
elif grep -qi "traceback" output.log; then
6245
echo "Program failed to run, see output above"
6346
false
64-
fi
65-
if grep -q Traceback tests.log; then
47+
elif grep -qi "exception" output.log; then
6648
echo "Program failed to run, see output above"
6749
false
6850
fi
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Simple program (MacOS)
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
simple-program:
7+
8+
runs-on: macos-latest
9+
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
python-version: ["3.7", "3.8", "3.9", "3.10"]
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v3
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
python -m pip install -r requirements.txt
26+
27+
- name: Run simple-program.py during 20 seconds
28+
run: |
29+
# For tests there is no real HW: use simulated LCD mode
30+
sed -i "" "s|^REVISION.*$|REVISION=\"SIMU\"|g" simple-program.py
31+
32+
# Run the program for 20s
33+
python3 simple-program.py > output.log 2>&1 &
34+
sleep 20
35+
36+
- name: Check output for errors
37+
run: |
38+
echo "######## Output : ########"
39+
cat output.log
40+
41+
if grep -qi "error" output.log; then
42+
echo "Program failed to run, see output above"
43+
false
44+
elif grep -qi "traceback" output.log; then
45+
echo "Program failed to run, see output above"
46+
false
47+
elif grep -qi "exception" output.log; then
48+
echo "Program failed to run, see output above"
49+
false
50+
fi
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Simple program (Windows)
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
simple-program:
7+
8+
runs-on: windows-latest
9+
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
python-version: ["3.7", "3.8", "3.9", "3.10"]
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v3
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
python -m pip install -r requirements.txt
26+
27+
- name: Run simple-program.py during 20 seconds
28+
run: |
29+
# For tests there is no real HW: use simulated LCD mode
30+
(Get-Content simple-program.py) -replace "^REVISION.*$","REVISION=`"SIMU`"" | Set-Content simple-program.py
31+
32+
# Run the program for 20s
33+
Start-Process -NoNewWindow python3 simple-program.py -RedirectStandardOutput output.log -RedirectStandardError error.log
34+
sleep 20
35+
add-content output.log (get-content error.log)
36+
37+
- name: Check output for errors
38+
run: |
39+
echo "######## Output : ########"
40+
cat output.log
41+
42+
$SEL = Select-String -Path output.log -Pattern "error"
43+
if ($SEL -ne $null)
44+
{
45+
throw "Program failed to run, see output above"
46+
}
47+
$SEL = Select-String -Path output.log -Pattern "traceback"
48+
if ($SEL -ne $null)
49+
{
50+
throw "Program failed to run, see output above"
51+
}
52+
$SEL = Select-String -Path output.log -Pattern "exception"
53+
if ($SEL -ne $null)
54+
{
55+
throw "Program failed to run, see output above"
56+
}
Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
name: System monitor generic run
1+
name: System monitor (Linux)
22

3-
on:
4-
workflow_call:
5-
inputs:
6-
theme:
7-
required: true
8-
type: string
3+
on: [push, pull_request]
94

105
jobs:
11-
system-monitor-generic:
6+
system-monitor:
127

138
runs-on: ubuntu-latest
9+
1410
strategy:
1511
fail-fast: false
1612
matrix:
1713
python-version: ["3.7", "3.8", "3.9", "3.10"]
14+
theme: [ "3.5inchTheme2", "Cyberpunk", "Landscape6Grid", "Terminal" ]
1815

1916
steps:
2017
- uses: actions/checkout@v3
@@ -30,26 +27,30 @@ jobs:
3027
3128
- name: Configure system monitor
3229
run: |
30+
# For tests there is no real HW: use simulated LCD mode
3331
sed -i "/REVISION:/c\ REVISION: SIMU" config.yaml
34-
echo "Using theme ${{ inputs.theme }}"
35-
sed -i "/THEME:/c\ THEME: ${{ inputs.theme }}" config.yaml
32+
33+
# Setup selected theme in config.yaml
34+
echo "Using theme ${{ matrix.theme }}"
35+
sed -i "/THEME:/c\ THEME: ${{ matrix.theme }}" config.yaml
3636
3737
- name: Run system monitor for 20 seconds
3838
run: |
39-
timeout --preserve-status 20s python3 main.py > tests.log 2>&1
39+
python3 main.py > output.log 2>&1 &
40+
sleep 20
4041
41-
- name: View output
42+
- name: Check output for errors
4243
run: |
4344
echo "######## Output : ########"
44-
cat tests.log
45-
46-
- name: Check output for exceptions
47-
run: |
48-
if grep -q Exception tests.log; then
45+
cat output.log
46+
47+
if grep -qi "error" output.log; then
48+
echo "Program failed to run, see output above"
49+
false
50+
elif grep -qi "traceback" output.log; then
4951
echo "Program failed to run, see output above"
5052
false
51-
fi
52-
if grep -q Traceback tests.log; then
53+
elif grep -qi "exception" output.log; then
5354
echo "Program failed to run, see output above"
5455
false
5556
fi
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: System monitor (MacOS)
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
system-monitor:
7+
8+
runs-on: macos-latest
9+
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
python-version: ["3.7", "3.8", "3.9", "3.10"]
14+
theme: [ "3.5inchTheme2", "Cyberpunk", "Landscape6Grid", "Terminal" ]
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v3
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
python -m pip install -r requirements.txt
27+
28+
- name: Configure system monitor
29+
run: |
30+
# For tests there is no real HW: use simulated LCD mode
31+
sed -i "" "s|^ REVISION.*$| REVISION: SIMU|g" config.yaml
32+
33+
# Setup selected theme in config.yaml
34+
echo "Using theme ${{ matrix.theme }}"
35+
sed -i "" "s|^ THEME.*$| THEME: ${{ matrix.theme }}|g" config.yaml
36+
37+
- name: Run system monitor for 20 seconds
38+
run: |
39+
python3 main.py > output.log 2>&1 &
40+
sleep 20
41+
42+
- name: Check output for errors
43+
run: |
44+
echo "######## Output : ########"
45+
cat output.log
46+
47+
if grep -qi "error" output.log; then
48+
echo "Program failed to run, see output above"
49+
false
50+
elif grep -qi "traceback" output.log; then
51+
echo "Program failed to run, see output above"
52+
false
53+
elif grep -qi "exception" output.log; then
54+
echo "Program failed to run, see output above"
55+
false
56+
fi

.github/workflows/system-monitor-tests.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: System monitor (Windows)
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
system-monitor:
7+
8+
runs-on: windows-latest
9+
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
python-version: ["3.7", "3.8", "3.9", "3.10"]
14+
theme: [ "3.5inchTheme2", "Cyberpunk", "Landscape6Grid", "Terminal" ]
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v3
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
python -m pip install -r requirements.txt
27+
28+
- name: Configure system monitor
29+
run: |
30+
# For tests there is no real HW: use simulated LCD mode
31+
(Get-Content config.yaml) -replace "^ REVISION.*$"," REVISION: SIMU" | Set-Content config.yaml
32+
33+
# Setup selected theme in config.yaml
34+
echo "Using theme ${{ matrix.theme }}"
35+
(Get-Content config.yaml) -replace "^ THEME.*$"," THEME: ${{ matrix.theme }}" | Set-Content config.yaml
36+
37+
- name: Run system monitor for 20 seconds
38+
run: |
39+
Start-Process -NoNewWindow python3 main.py -RedirectStandardOutput output.log -RedirectStandardError error.log
40+
sleep 20
41+
add-content output.log (get-content error.log)
42+
43+
- name: Check output for errors
44+
run: |
45+
echo "######## Output : ########"
46+
cat output.log
47+
48+
$SEL = Select-String -Path output.log -Pattern "error"
49+
if ($SEL -ne $null)
50+
{
51+
throw "Program failed to run, see output above"
52+
}
53+
$SEL = Select-String -Path output.log -Pattern "traceback"
54+
if ($SEL -ne $null)
55+
{
56+
throw "Program failed to run, see output above"
57+
}
58+
$SEL = Select-String -Path output.log -Pattern "exception"
59+
if ($SEL -ne $null)
60+
{
61+
throw "Program failed to run, see output above"
62+
}

0 commit comments

Comments
 (0)