Skip to content

Run tests

Run tests #1489

Workflow file for this run

name: Run tests
on:
pull_request: {}
schedule:
- cron: '0 0 * * 0' # every sunday
env:
ZEPHYR_SDK_VERSION: 0.16.5
ZEPHYR_REV: 5cbf7b1b9d13a39f36ad8dabfaeaec21d98cf5ff
jobs:
merge-test-1:
runs-on: ubuntu-22.04
strategy:
matrix:
platform: ["native_posix", "native_posix/native/64", "mps2/an521/cpu0"]
asserts: ["", "-x VERBOSE=ON -x ASSERTS=ON"]
name: Merge test 1 - Twister (Ubuntu) (${{ matrix.platform }}${{ matrix.asserts != '' && ' with asserts' || '' }})
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Install zcbor
uses: ./.github/actions/install_zcbor
- name: Prepare and run tests
uses: ./.github/actions/prepare_and_run_tests
with:
twister_arguments: "--timestamps --platform ${{ matrix.platform }} ${{ matrix.asserts }} --exclude-tag release"
zephyr_toolchain: ${{ matrix.platform == 'mps2/an521/cpu0' && 'zephyr' || 'host'}}
zephyr_toolchain_arch: ${{ matrix.platform == 'mps2/an521/cpu0' && 'arm' || ''}}
merge-test-1-win:
runs-on: windows-latest
strategy:
matrix:
platform: ["mps2/an521/cpu0"]
asserts: [""]
name: Merge test 1 - Twister (Windows) (${{ matrix.platform }}${{ matrix.asserts != '' && ' with asserts' || '' }} - build only)
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Checkout Zephyr
run: |
git init zephyr-clone
cd zephyr-clone
git remote add origin https://github.com/zephyrproject-rtos/zephyr
git fetch origin $env:ZEPHYR_REV --depth=1
git reset --hard FETCH_HEAD
- name: Install zcbor and pip dependencies
run: |
$ErrorActionPreference="Stop"
pip install -U -r scripts\requirements.txt -r zephyr-clone\scripts\requirements-base.txt -r zephyr-clone\scripts\requirements-build-test.txt -r zephyr-clone\scripts\requirements-run-test.txt; if($LastExitCode -ne 0) {Write-Error "$LastExitCode"};
pip install -e .
- name: Install ninja and 7zip
run: |
choco feature enable -n allowGlobalConfirmation
choco install ninja 7zip
- name: Run West
run: |
$ErrorActionPreference="Stop"
west init -l zephyr-clone; if($LastExitCode -ne 0) {Write-Error "$LastExitCode"};
west update cmsis
- name: Install Zephyr SDK (ARM)
run: |
$client = new-object System.Net.WebClient
$client.DownloadFile("https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v$env:ZEPHYR_SDK_VERSION/zephyr-sdk-${env:ZEPHYR_SDK_VERSION}_windows-x86_64_minimal.7z", "$pwd\zephyr-sdk-${env:ZEPHYR_SDK_VERSION}_windows-x86_64_minimal.7z")
7z x $pwd\zephyr-sdk-${env:ZEPHYR_SDK_VERSION}_windows-x86_64_minimal.7z
Rename-Item -Path zephyr-sdk-${env:ZEPHYR_SDK_VERSION} -NewName zephyr-sdk
cd zephyr-sdk
$client.DownloadFile("https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v$env:ZEPHYR_SDK_VERSION/toolchain_windows-x86_64_arm-zephyr-eabi.7z", "$pwd\toolchain_windows-x86_64_arm-zephyr-eabi.7z")
7z x $pwd\toolchain_windows-x86_64_arm-zephyr-eabi.7z
- name: Run Twister
shell: cmd
run: |
set ZEPHYR_BASE=%cd%\zephyr-clone
set ZEPHYR_TOOLCHAIN_VARIANT=zephyr
set ZEPHYR_SDK_INSTALL_DIR=%cd%\zephyr-sdk
python %ZEPHYR_BASE%\scripts\twister -i -v -T tests -W --timestamps --platform ${{ matrix.platform }} ${{ matrix.asserts }} --exclude-tag release --build-only
merge-test-2:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
name: Merge tests 2 - Python (${{ matrix.python-version }}) functional tests (Ubuntu)
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install zcbor
uses: ./.github/actions/install_zcbor
with:
zcbor_package: 'setup_install'
- name: Run python tests
working-directory: tests/scripts
run: |
python3 -m unittest test_zcbor
merge-test-2-win:
runs-on: windows-latest
name: Merge tests 2 - Python (${{ matrix.python-version }}) functional tests (Windows)
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Read zcbor version
run: |
echo "ZCBOR_VERSION=$(cat zcbor/VERSION)" >> $env:GITHUB_ENV
- name: Install west and dependencies
run: |
pip install -U pip
pip install -U build
pip install -U -r scripts/requirements.txt
- name: Generate and install zcbor package
run: |
$ErrorActionPreference="Stop"
python -m build; if($LastExitCode -ne 0) {Write-Error "$LastExitCode"};
pip install dist/zcbor-$env:ZCBOR_VERSION-py3-none-any.whl; if($LastExitCode -ne 0) {Write-Error "$LastExitCode"};
pip uninstall -y zcbor
pip install -e .
- name: Run python tests
working-directory: tests/scripts
run: |
python3 -m unittest test_zcbor
merge-test-3:
runs-on: ubuntu-22.04
name: Merge tests 3 - Check repo files (Ubuntu)
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install zcbor
uses: ./.github/actions/install_zcbor
with:
zcbor_package: 'setup_develop'
- name: Run tests on repo files
working-directory: tests/scripts
run: |
python3 -m unittest test_repo_files
release-test-1:
runs-on: ubuntu-22.04
name: Release tests 1 - Check versions
needs:
- merge-test-1
- merge-test-1-win
- merge-test-2
- merge-test-2-win
- merge-test-3
if: "startswith(github.head_ref, 'release/')"
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Install zcbor
uses: ./.github/actions/install_zcbor
- name: Run python release tests
working-directory: tests/scripts
run: |
set -e
echo -n ${{ github.head_ref }} > HEAD_REF
python3 -m unittest test_versions
rm HEAD_REF
release-test-2:
runs-on: ubuntu-22.04
name: Release tests 2 - Fuzz
needs:
- release-test-1
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Read zcbor version
run: echo "ZCBOR_VERSION=$(cat zcbor/VERSION)" >> $GITHUB_ENV
- name: Install zcbor
uses: ./.github/actions/install_zcbor
- name: Install packages
run: |
sudo apt update
sudo apt install -y afl++
- name: Run everything fuzz tests
working-directory: tests/fuzz
run: |
./test-afl.sh 2400 64 everything
- name: Run manifest12 fuzz tests
working-directory: tests/fuzz
run: |
./test-afl.sh 800 64 manifest12
- name: Run pet fuzz tests
working-directory: tests/fuzz
run: |
./test-afl.sh 400 64 pet
- name: Rename fuzz failures
if: ${{ failure() }}
working-directory: tests/fuzz/build-afl/output/default/crashes/
run: |
for i in ./* ; do mv "$i" "${i//:/_}_1"; done
- name: Upload fuzz failures
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: fuzz-failures
path: tests/fuzz/build-afl/output/default/crashes/
- name: Upload release files
uses: actions/upload-artifact@v4
with:
name: zcbor-release-${{ env.ZCBOR_VERSION }}
path: dist/*
release-test-3:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
asserts: ["", "-x VERBOSE=ON -x ASSERTS=ON"]
name: Release tests 3 (Python ${{ matrix.python-version }}${{ matrix.asserts != '' && ' with asserts' || '' }})
needs:
- merge-test-1
- merge-test-1-win
- merge-test-2
- merge-test-2-win
- merge-test-3
if: "github.event_name == 'schedule' || (github.event_name == 'pull_request' && startswith(github.head_ref, 'release/'))"
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install zcbor
uses: ./.github/actions/install_zcbor
with:
zcbor_package: 'setup_install'
- name: Prepare and run tests
uses: ./.github/actions/prepare_and_run_tests
with:
twister_arguments: "--timestamps --platform native_posix --platform native_posix/native/64 --platform mps2/an521/cpu0 --platform qemu_malta/qemu_malta/be ${{ matrix.asserts }}"
zephyr_toolchain: zephyr
zephyr_toolchain_arch: arm,mips
release-test-4:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
asserts: ["", "-x VERBOSE=ON -x ASSERTS=ON"]
name: Release tests 4 (Python ${{ matrix.python-version }}${{ matrix.asserts != '' && ' with asserts' || '' }})
needs:
- merge-test-1
- merge-test-1-win
- merge-test-2
- merge-test-2-win
- merge-test-3
if: "github.event_name == 'schedule' || (github.event_name == 'pull_request' && startswith(github.head_ref, 'release/'))"
steps:
- name: Checkout the code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install zcbor
uses: ./.github/actions/install_zcbor
with:
zcbor_package: 'setup_develop'
- name: Run python tests on samples
working-directory: tests/scripts
run: |
python3 -m unittest test_repo_files.TestSamples