Skip to content

Run tests

Run tests #2908

Workflow file for this run

name: Run tests
on:
pull_request: {}
schedule:
- cron: '* * * * 0' # every sunday
env:
ZEPHYR_SDK_VERSION: 0.16.4
ZEPHYR_REV: zephyr-v3.5.0
jobs:
merge-test-1:
runs-on: ubuntu-22.04
strategy:
matrix:
platform: ["native_posix", "native_posix_64", "mps2_an521"]
asserts: ["", "-x VERBOSE=ON -x ASSERTS=ON"]
name: Merge tests 1 (${{ matrix.platform }}${{ matrix.asserts != '' && ' with asserts' || '' }})
steps:
- name: Checkout the code
uses: actions/checkout@v3
- 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' && 'zephyr' || 'host'}}
zephyr_toolchain_arch: ${{ matrix.platform == 'mps2_an521' && 'arm' || ''}}
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 }})
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
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-3:
runs-on: windows-latest
name: Merge tests 3 (Windows)
steps:
- name: Checkout the code
uses: actions/checkout@v3
- 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-4:
runs-on: ubuntu-22.04
name: Merge tests 4 (Test repo files)
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- 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 (Fuzz)
needs:
- merge-test-1
- merge-test-2
- merge-test-3
- merge-test-4
if: "startswith(github.head_ref, 'release/')"
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Read zcbor version
run: echo "ZCBOR_VERSION=$(cat zcbor/VERSION)" >> $GITHUB_ENV
- 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
- 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@v3
with:
name: fuzz-failures
path: tests/fuzz/build-afl/output/default/crashes/
- name: Upload release files
uses: actions/upload-artifact@v3
with:
name: zcbor-release-$ZCBOR_VERSION
path: dist/*
release-test-2:
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 2 (Python ${{ matrix.python-version }}${{ matrix.asserts != '' && ' with asserts' || '' }})
needs:
- merge-test-1
- merge-test-2
- merge-test-3
- merge-test-4
if: "github.event_name == 'schedule' || (github.event_name == 'pull_request' && startswith(github.head_ref, 'release/'))"
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
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_64 --platform mps2_an521 --platform qemu_malta_be ${{ matrix.asserts }}"
zephyr_toolchain: zephyr
zephyr_toolchain_arch: arm,mips
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-2
- merge-test-3
- merge-test-4
if: "github.event_name == 'schedule' || (github.event_name == 'pull_request' && startswith(github.head_ref, 'release/'))"
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
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