Skip to content

150 sphinx build in the ci pipeline #649

150 sphinx build in the ci pipeline

150 sphinx build in the ci pipeline #649

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches:
- main
schedule:
- cron: '00 6 1 * *'
release:
types:
- published
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .
python -m pip install -U pylint
- name: Run Main code Lint
run: pylint src/peakrdl_python
- name: Install dependencies for unit tests
run: |
python -m pip install .[unit_test] -U
- name: Run unit tests Lint
run: pylint src/peakrdl_python tests/unit_tests
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .
python -m pip install -U mypy
- name: Type Check
run: mypy src/peakrdl_python
unit_tests:
needs:
- mypy
- lint
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.9, "3.10", "3.11", "3.12", "3.13" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# the unit tests need the development version of installer as tomllib may be needed
# for older versions of python
python -m pip install .[unit_test]
- name: Run Unit Tests
run: |
python -m unittest discover -s tests/unit_tests -t .
dev_runner:
needs:
- mypy
- lint
- unit_tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.9, "3.10", "3.11", "3.12", "3.13" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[dev]
# the generate_and_test script is intended to run directly from source rather than from
# the installed package
python -m pip uninstall peakrdl-python -y
# peakrdl-ipxact is needed for some of the test cases so is imported by the
# generate_and_test script
# retrieve the example code from the systemRDL compiler
wget -L https://raw.githubusercontent.com/SystemRDL/systemrdl-compiler/main/examples/accelera-generic_example.rdl -O tests/testcases/accelera-generic_example.rdl
- name: Test Development Runner
run: |
python -m generate_and_test --RDL_source_file tests/testcases/simulator_test.rdl --root_node simulator_test
python -m generate_and_test --RDL_source_file tests/testcases/simulator_test.rdl --root_node simulator_test --async
python -m generate_and_test --RDL_source_file tests/testcases/accelera-generic_example.rdl --root_node some_register_map
python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp bool_property_to_include
python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp bool_property_to_include enum_property_to_include
python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp bool_property_to_include enum_property_to_include int_property_to_include
python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp bool_property_to_include enum_property_to_include int_property_to_include str_property_to_include
python -m generate_and_test --RDL_source_file tests/testcases/user_defined_properties.rdl --root_node user_defined_properties --udp bool_property_to_include enum_property_to_include int_property_to_include str_property_to_include struct_property_to_include double_layer_struct_property_to_include
python -m generate_and_test --RDL_source_file tests/testcases/reserved_elements.rdl --root_node reserved_elements --hide_regex "(?:[\w_\[\]]+\.)+RSVD"
peakrdl_integration:
needs:
- mypy
- lint
- unit_tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.9, "3.10", "3.11", "3.12", "3.13" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[peakrdl]
- name: Run PeakRDL Case
run: |
peakrdl python tests/testcases/basic.rdl -o peakrdl_out/raw/
peakrdl python tests/testcases/hidden_property.rdl -o peakrdl_out/raw/
peakrdl python tests/testcases/hidden_property.rdl -o peakrdl_out/raw/show_hidden/ --show_hidden
peakrdl python tests/testcases/simple.xml tests/testcases/multifile.rdl -o peakrdl_out/raw
peakrdl python tests/testcases/extended_memories.rdl -o peakrdl_out/raw/
peakrdl python tests/testcases/user_defined_properties.rdl -o peakrdl_out/raw/ --udp bool_property_to_include
peakrdl python tests/testcases/reserved_elements.rdl -o peakrdl_out/raw/ --hide_regex "(?:[\w_\[\]]+\.)+RSVD"
python -m unittest discover -s peakrdl_out/raw
peakrdl python tests/testcases/basic.rdl -o peakrdl_out/raw_async/ --async
peakrdl python tests/testcases/hidden_property.rdl -o peakrdl_out/raw_async/ --async
peakrdl python tests/testcases/hidden_property.rdl -o peakrdl_out/raw_async/show_hidden/ --show_hidden --async
python -m unittest discover -s peakrdl_out/raw_async
peakrdl python tests/testcases/basic.rdl -o peakrdl_out/raw_legacy/ --legacy_block_access
python -m unittest discover -s peakrdl_out/raw_legacy
peakrdl python tests/testcases/basic.rdl -o peakrdl_out/no_test/ --skip_test_case_generation
# test a TOMl file that passes in overridden templates
peakrdl python tests/testcases/basic.rdl -o peakrdl_out/simple_user_template/ --peakrdl-cfg tests/alternative_templates_toml/peakrdl.toml
python tests/alternative_templates_toml/header_check.py --generated_package_location peakrdl_out/simple_user_template/ --top_name basic
peakrdl python tests/testcases/basic.rdl -o peakrdl_out/dynamic_user_template/ --peakrdl-cfg tests/alternative_templates_dynamic_toml/peakrdl.toml
python tests/alternative_templates_dynamic_toml/header_check.py --generated_package_location peakrdl_out/dynamic_user_template/ --top_name basic
- name: Check Examples
run: |
# build the libraries for the two cases
cd example/tranversing_address_map/
peakrdl python chip_with_registers.rdl -o .
python -m reseting_registers
python -m dumping_register_state_to_json_file
python -m writing_register_state_from_json_file
cd ../..
cd example/simulating_callbacks
peakrdl python chip_with_a_GPIO.rdl -o .
# this example creates a gui that stays up for ever so needs changing before it can be
# in the test suite
# python -m flashing_the_LED
cd ../..
cd example/optimised_access/
peakrdl python optimised_access.rdl -o .
python -m demo_optimised_access
cd ../..
cd example/array_access/
peakrdl python array_access.rdl -o .
python -m demo_array_access
cd ../..
cd example/enumerated_fields/
peakrdl python enumerated_fields.rdl -o .
python -m demo_enumerated_fields
cd ../..
cd example/why_ral/
peakrdl python gpio.rdl -o .
python -m without_ral
python -m with_ral
python -m with_hal
cd ../..
integration_tests:
needs:
- mypy
- lint
- unit_tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9, "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .
# retrieve the example code from the systemRDL compiler
wget -L https://raw.githubusercontent.com/SystemRDL/systemrdl-compiler/main/examples/accelera-generic_example.rdl -O tests/testcases/accelera-generic_example.rdl
- name: Generate testcases
run: |
# one of the test cases uses IPxact so we need the importer
python -m pip install peakrdl-ipxact
# the generated code is type checked with mypy so this is needed
python -m pip install mypy
python generate_testcases.py
mypy testcase_output
# pylint testcase_output/autopep8 --disable=duplicate-code,line-too-long,too-many-statements,invalid-name,unused-import,too-many-instance-attributes,too-many-arguments,too-many-lines
python -m unittest discover -s testcase_output
autoformating:
needs:
- integration_tests
- peakrdl_integration
- dev_runner
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9, "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .
python -m pip install mypy
# one of the test cases uses IPxact so we need the importer
python -m pip install peakrdl-ipxact
# black is the autoformatter used for this this testing
python -m pip install black
# retrieve the example code from the systemRDL compiler
wget -L https://raw.githubusercontent.com/SystemRDL/systemrdl-compiler/main/examples/accelera-generic_example.rdl -O tests/testcases/accelera-generic_example.rdl
- name: Generate testcases
run: |
# black will ignore files in the .gitingore by default, so we need to ensure that the
# content is generated with a different name
python generate_testcases.py --output autoformatted_output --test_case accelera-generic_example.rdl
# no need to check them as they are tested in the previous test
- name: Test Autoformating
run: |
# run the autoformatting
black autoformatted_output --line-length 120
# check the files are correct with mypy and unittesting
mypy autoformatted_output
python -m unittest discover -s autoformatted_output
#-------------------------------------------------------------------------------
documentation:
needs:
# the documentation relies on examples so these must be prechecked
# as part of the dependency
- autoformating
name: Build the sphinx documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .
# Standard drop-in approach that should work for most people.
- uses: ammaraskar/sphinx-action@master
with:
docs-folder: "docs/"
# Create an artifact of the html output.
- uses: actions/upload-artifact@v1
with:
name: DocumentationHTML
path: docs/_build/html/
#-------------------------------------------------------------------------------
build:
needs:
- autoformating
- dev_runner
- documentation
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install -U build
- name: Build
run: python -m build
- uses: actions/upload-artifact@v4
with:
path: |
dist/*.tar.gz
dist/*.whl
#-------------------------------------------------------------------------------
deploy:
needs:
- build
runs-on: ubuntu-latest
# Only publish when a GitHub Release is created.
if: github.event_name == 'release'
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}