forked from OpenSourceEBike/TSDZ2-Smart-EBike
-
Notifications
You must be signed in to change notification settings - Fork 34
168 lines (158 loc) · 5.19 KB
/
build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Build
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
push:
paths:
- ".github/workflows/*"
- "src/*"
- "tests/*"
- "pyproject.toml"
- "setup.py"
pull_request:
paths:
- "src/*"
- "tests/*"
- "pyproject.toml"
- "setup.py"
env:
SDCC_VERSION: 4.4.0
jobs:
Build_Windows:
runs-on: windows-latest
steps:
# - name: Start SSH session
# uses: luchihoratiu/debug-via-ssh@main
# with:
# NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
# SSH_PASS: ${{ secrets.SSH_PASS }}
- name: Install SDCC
run: |
Invoke-WebRequest -UserAgent "Wget" -Uri https://sourceforge.net/projects/sdcc/files/sdcc-win64/$env:SDCC_VERSION/sdcc-$env:SDCC_VERSION-rc3-x64-setup.exe/download -OutFile sdcc_setup.exe
Start-Process -wait -FilePath "sdcc_setup.exe" -ArgumentList "/S", "/D=C:\Program Files\SDCC"
echo "Adding SDCC to PATH"
Add-Content $env:GITHUB_PATH "C:\Program Files\SDCC\bin"
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
# this mainly checks whether tests compile and work on windows. The actual test report runs on Ubuntu job
- name: Check testing framework
run: |
pip install -e .
rm tests/sim/_tsdz2.cdef # make sure cdef is generated from the source to check testing framework
pytest
- name: Build
run: |
cd src
make clean
make CFLAGS=--Werror
- uses: actions/upload-artifact@v4
with:
name: firmware_from_windows
path: bin/main.hex
Build_Linux:
runs-on: ubuntu-latest
steps:
# - name: Start SSH session
# uses: luchihoratiu/debug-via-ssh@main
# with:
# NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
# SSH_PASS: ${{ secrets.SSH_PASS }}
- name: Install SDCC
run: |
cd ~
wget https://sourceforge.net/projects/sdcc/files/sdcc-linux-amd64/$SDCC_VERSION/sdcc-$SDCC_VERSION-amd64-unknown-linux2.5.tar.bz2/download -O sdcc-amd64.tar.bz2
sudo tar xf sdcc-amd64.tar.bz2
cd sdcc-$SDCC_VERSION/
sudo cp -r * /usr/local
sdcc --version
sdcc --print-search-dirs
- uses: actions/checkout@v4
- name: Build
run: |
cd src
make clean
make CFLAGS=--Werror
- uses: actions/upload-artifact@v4
with:
name: firmware_from_linux
path: bin/main.hex
Tests:
runs-on: ubuntu-20.04
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
pip install -e .
pip install --upgrade pytest-md-report
pip install gcovr
- name: Run tests
env:
REPORT_OUTPUT: md_report.md
shell: bash
run: |
rm tests/sim/_tsdz2.cdef # make sure cdef is generated from the source to check testing framework
echo "REPORT_FILE=${REPORT_OUTPUT}" >> "$GITHUB_ENV"
gcc -Wall -Wextra -Q --help=warning # print warnings that shouldbe enabled by pytest --strict
pytest --strict --coverage --md-report --md-report-flavor gfm --md-report-output "$REPORT_OUTPUT"
- name: Output reports to the job summary
if: always()
shell: bash
run: |
if [ -f "$REPORT_FILE" ]; then
echo "## Test Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat "$REPORT_FILE" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
else
echo "Report file not found."
fi
- name: Render the report to the PR when tests fail
uses: marocchino/sticky-pull-request-comment@v2
if: failure()
with:
header: test-report
recreate: true
path: ${{ env.REPORT_FILE }}
- name: Collect coverage data
run: |
echo "### Coverage Report" >> $GITHUB_STEP_SUMMARY
gcovr -r tests --print-summary >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
- uses: actions/upload-artifact@v4
with:
name: coverage_report
path: |
tests/coverage_report.html
Compare_builds:
needs: [Build_Windows, Build_Linux]
runs-on: ubuntu-latest
steps:
- name: Download Windows build
uses: actions/download-artifact@v4
with:
name: firmware_from_windows
path: firmware_from_windows
- name: Download Linux build
uses: actions/download-artifact@v4
with:
name: firmware_from_linux
path: firmware_from_linux
- name: Compare build files
run: |
echo "Comparing build files"
git diff firmware_from_windows/main.hex firmware_from_linux/main.hex --word-diff=color --ignore-space-at-eol --exit-code
echo "Done comparing build files. Files are the same."