| |
| |
| |
| name: Regression Tests |
|
|
| on: |
| workflow_call: |
| inputs: |
| nox_session_test_sim: |
| required: true |
| type: string |
| default: dev_test_sim |
| nox_session_test_nosim: |
| required: true |
| type: string |
| default: dev_test_nosim |
| collect_coverage: |
| required: false |
| type: boolean |
| default: false |
| download_artifacts: |
| required: false |
| type: boolean |
| default: false |
| group: |
| required: false |
| type: string |
| default: "ci" |
| description: Group of environments to run the tests against. Leave empty to run them all. |
|
|
| jobs: |
|
|
| generate_envs: |
| runs-on: ubuntu-latest |
| name: Generate a list of environments to run tests against |
| steps: |
| - uses: actions/checkout@v4 |
| - run: ./.github/generate-envs.py --output-format=gha --gha-output-file="$GITHUB_OUTPUT" --group="${{inputs.group}}" |
| id: run_generate_script |
| outputs: |
| envs: ${{ steps.run_generate_script.outputs.envs }} |
|
|
| tests: |
|
|
| needs: generate_envs |
|
|
| name: ${{matrix.name}} |
| runs-on: ${{matrix.runs-on}} |
| env: |
| SIM: ${{matrix.sim}} |
| TOPLEVEL_LANG: ${{matrix.lang}} |
| CXX: ${{matrix.cxx || 'g++'}} |
| CC: ${{matrix.cc || 'gcc'}} |
| OS: ${{matrix.os}} |
| PYTHON_VERSION: ${{matrix.python-version}} |
|
|
| strategy: |
| fail-fast: false |
| matrix: |
| include: ${{ fromJson(needs.generate_envs.outputs.envs) }} |
|
|
| steps: |
| - uses: actions/checkout@v4 |
| with: |
| |
| |
| |
| fetch-depth: 2 |
|
|
| |
| - uses: actions/download-artifact@v4 |
| with: |
| path: dist |
| pattern: cocotb-dist-* |
| merge-multiple: true |
| if: ${{ inputs.download_artifacts }} |
|
|
| |
| - name: Set up Python ${{matrix.python-version}} |
| if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos') |
| uses: actions/setup-python@v5 |
| with: |
| python-version: ${{matrix.python-version}} |
| - name: Set up Anaconda ${{matrix.python-version}} (Windows) |
| if: startsWith(matrix.os, 'windows') |
| uses: conda-incubator/setup-miniconda@v3 |
| with: |
| auto-update-conda: true |
| |
| activate-environment: "" |
| - name: Set up python version for Anaconda (base) ${{matrix.python-version}} (Windows) |
| if: startsWith(matrix.os, 'windows') |
| run: conda install --yes python=${{matrix.python-version}} |
|
|
| |
| - name: Install Python testing dependencies |
| run: | |
| pip install nox |
| - name: Run tests without simulators |
| run: nox -s "${{ inputs.nox_session_test_nosim }}" |
| continue-on-error: ${{matrix.may-fail || false}} |
|
|
| |
| - name: Set up Icarus (Ubuntu - apt) |
| if: startsWith(matrix.os, 'ubuntu') && matrix.sim == 'icarus' && matrix.sim-version == 'apt' |
| run: | |
| sudo apt-get install -y --no-install-recommends iverilog |
| - name: Set up Icarus (Ubuntu - source) |
| if: startsWith(matrix.os, 'ubuntu') && matrix.sim == 'icarus' && matrix.sim-version != 'apt' |
| run: | |
| sudo apt-get install -y --no-install-recommends g++ gperf flex bison make autoconf |
| git clone https://github.com/steveicarus/iverilog.git |
| cd iverilog |
| git reset --hard ${{matrix.sim-version}} |
| bash ./autoconf.sh |
| bash ./configure |
| make -j $(nproc) |
| sudo make install |
| - name: Set up Icarus (Windows - source) |
| if: startsWith(matrix.os, 'windows') && matrix.sim == 'icarus' |
| run: | |
| conda install -c msys2 m2-base m2-make m2-autoconf m2-flex m2-bison m2-gperf m2w64-toolchain |
| git clone https://github.com/steveicarus/iverilog.git |
| cd iverilog |
| git reset --hard ${{matrix.sim-version}} |
| bash ./autoconf.sh |
| bash ./configure --host=x86_64-w64-mingw32 --prefix=/c/iverilog |
| make -j $(nproc) |
| make install |
| echo "C:\iverilog\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 |
| - name: Set up Icarus (MacOS - homebrew --HEAD) |
| if: startsWith(matrix.os, 'macos') && matrix.sim == 'icarus' && matrix.sim-version == 'homebrew-HEAD' |
| run: | |
| brew install icarus-verilog --HEAD |
| - name: Set up Icarus (MacOS - homebrew) |
| if: startsWith(matrix.os, 'macos') && matrix.sim == 'icarus' && matrix.sim-version == 'homebrew-stable' |
| run: | |
| brew install icarus-verilog |
| |
| |
| - name: Set up GHDL (Ubuntu) |
| if: startsWith(matrix.os, 'ubuntu') && matrix.sim == 'ghdl' |
| run: | |
| sudo apt update |
| sudo apt-get install -y --no-install-recommends gnat |
| git clone https://github.com/ghdl/ghdl.git |
| cd ghdl |
| git reset --hard ${{matrix.sim-version}} |
| mkdir build |
| cd build |
| ../configure |
| make -j $(nproc) |
| sudo make install |
| |
| |
| - name: Set up NVC (Ubuntu) |
| if: startsWith(matrix.os, 'ubuntu') && matrix.sim == 'nvc' |
| run: | |
| sudo apt-get install -y --no-install-recommends llvm-dev libdw-dev flex |
| git clone --depth=1 --no-single-branch https://github.com/nickg/nvc.git |
| cd nvc |
| git reset --hard ${{matrix.sim-version}} |
| ./autogen.sh |
| mkdir build |
| cd build |
| ../configure |
| make -j $(nproc) |
| sudo make install |
| |
| |
| - name: Set up Verilator (Ubunutu - source) |
| if: startsWith(matrix.os, 'ubuntu') && matrix.sim == 'verilator' |
| run: | |
| sudo apt-get install -y --no-install-recommends help2man make g++ perl python3 autoconf flex bison libfl2 libfl-dev zlib1g zlib1g-dev |
| git clone https://github.com/verilator/verilator.git |
| cd verilator |
| git reset --hard ${{matrix.sim-version}} |
| autoconf |
| ./configure |
| make -j $(nproc) |
| sudo make install |
| |
| |
| - name: Install cocotb build dependencies (Windows, mingw) |
| if: startsWith(matrix.os, 'windows') && matrix.toolchain == 'mingw' |
| run: conda install --yes -c msys2 m2-base m2-make m2w64-toolchain libpython |
| - name: Install cocotb runtime dependencies (Windows, msvc) |
| if: startsWith(matrix.os, 'windows') && matrix.toolchain == 'msvc' |
| run: conda install --yes -c msys2 m2-base m2-make |
| - name: Test (Windows) |
| if: startsWith(matrix.os, 'windows') |
| id: windowstesting |
| continue-on-error: ${{matrix.may-fail || false}} |
| timeout-minutes: 20 |
| |
| |
| run: | |
| nox --no-venv -k "${{ inputs.nox_session_test_sim }} and ${{ matrix.sim }} and ${{ matrix.lang }}" |
| |
| |
| - name: Install cocotb build dependencies (Ubuntu - g++) |
| if: startsWith(matrix.os, 'ubuntu') && (!matrix.cxx || matrix.cxx == 'g++') |
| run: | |
| sudo apt-get install g++ |
| - name: Install cocotb build dependencies (Ubuntu - clang++) |
| if: startsWith(matrix.os, 'ubuntu') && matrix.cxx == 'clang++' |
| run: | |
| sudo apt-get install clang |
| - name: Install cocotb build dependencies (MacOS) |
| if: startsWith(matrix.os, 'macos') |
| run: | |
| g++ --version |
| - name: Test (Ubuntu, MacOS) |
| id: unixtesting |
| if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos') |
| continue-on-error: ${{matrix.may-fail || false}} |
| timeout-minutes: 30 |
| run: | |
| if [ "${{matrix.self-hosted}}" == "true" ]; then |
| module load "${{ matrix.sim-version }}" |
| fi |
| nox -k "${{ inputs.nox_session_test_sim }} and ${{ matrix.sim }} and ${{ matrix.lang }}" |
| |
| |
| - name: Combine and report coverage |
| if: inputs.collect_coverage |
| run: nox -s dev_coverage_combine |
|
|
| - name: Upload to codecov |
| if: inputs.collect_coverage |
| uses: codecov/codecov-action@v3 |
| env: |
| |
| CODECOV_TOKEN: 669f2048-851e-479e-a618-8fa64f3736cc |
| with: |
| files: .python_coverage.xml,.cpp_coverage.xml |
| name: ${{ matrix.name }} |
| env_vars: SIM,TOPLEVEL_LANG,CXX,OS,PYTHON_VERSION |
| verbose: true |
|
|