yaml #269
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 and Test | |
on: | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
description: 'Log level' | |
required: true | |
default: 'warning' | |
push: | |
paths: | |
- ".github/workflows/build.yaml" | |
- "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: 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' | |
# - 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 dependencies | |
run: | | |
pip install -e . | |
- name: Run tests | |
run: | | |
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: 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: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
pip install -e . | |
- name: Run tests | |
run: | | |
pytest --junit-xml junit.xml | |
- uses: actions/upload-artifact@v4 # upload test results | |
if: success() || failure() # run this step even if previous step failed | |
with: | |
name: test-results | |
path: junit.xml | |
# - name: Start SSH session | |
# uses: luchihoratiu/debug-via-ssh@main | |
# with: | |
# NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }} | |
# SSH_PASS: ${{ secrets.SSH_PASS }} | |
- name: Collect coverage data | |
run: | | |
pip install gcovr coverage-badge | |
gcovr --html-details -o coverage.html | |
- name: Build | |
run: | | |
cd src | |
make clean | |
make CFLAGS=--Werror | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: firmware_from_linux | |
path: bin/main.hex | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: coverage_report | |
path: | | |
coverage.html | |
coverage.xml | |
coverage-badge.svg | |
Compare_builds: | |
needs: [Build_Windows, Build_Linux] | |
runs-on: ubuntu-22.04 | |
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." | |