Merge commit '5d2de9fb544034729083db3f9cd5bb6db90ecdeb' #366
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
Static-analysis: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Prepare cppcheck | |
run: | | |
mkdir -p b | |
git clone https://github.com/danmar/cppcheck.git | |
cd cppcheck | |
git fetch --all --tags --force | |
git checkout 2.14.2 | |
mkdir -p build | |
- name: Cache Cppcheck build | |
id: cppcheck-build | |
uses: actions/cache@v4 | |
env: | |
cache-name: cppcheck-build | |
with: | |
path: ./cppcheck/build | |
key: ${{ runner.os }}-cppcheck-build-${{ env.cache-name }}-${{ hashFiles('cli/*.*') }} | |
restore-keys: | | |
${{ runner.os }}-cppcheck-build-${{ env.cache-name }}- | |
${{ runner.os }}-cppcheck-build- | |
${{ runner.os }}- | |
- name: Install cppcheck | |
shell: bash | |
run: | | |
cd cppcheck/build | |
cmake .. | |
cmake --build . | |
sudo make install | |
cppcheck --version | |
- name: Cache Cppcheck dumps | |
id: cppcheck-dump-dir | |
uses: actions/cache@v4 | |
env: | |
cache-name: cppcheck-build-dir | |
with: | |
path: ./b | |
key: ${{ runner.os }}-cppcheck-dump-dir-${{ env.cache-name }}-${{ hashFiles('src/**/*.{c,h}') }} | |
restore-keys: | | |
${{ runner.os }}-cppcheck-dump-dir-${{ env.cache-name }}- | |
${{ runner.os }}-cppcheck-dump-dir- | |
${{ runner.os }}- | |
- name: Run cppcheck | |
shell: bash | |
run: | | |
cppcheck src --cppcheck-build-dir=b -j8 --enable=all --check-level=exhaustive --force --std=c99 -Isrc/STM8S_StdPeriph_Lib/inc -iSTM8S_StdPeriph_Lib --suppress=missingIncludeSystem --suppress=variableScope -DSTM8S105 -DHSE_Value=16000000 -D_SDCC_ -DUSE_STDPERIPH_DRIVER -USTM8AF52Ax -USTM8AF622x -USTM8AF626x -USTM8AF62Ax -USTM8S003 -USTM8S005 -USTM8S007 -USTM8S103 -USTM8S207 -USTM8S208 -USTM8S903 -U__CSMC__ -U__ICCSTM8__ -U__RCST7__ -U__CDT_PARSER__ -URAM_EXECUTION -UHALL_DEBUG -UTIME_DEBUG -UUSE_FULL_ASSERT 2>/dev/null | |
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." | |