Add CI for the examples. #18
This file contains hidden or 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: Book examples | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| inputs: | |
| rtos_commit: | |
| description: 'Set to override default RTOS commit hash' | |
| type: string | |
| required: false | |
| network_stack_commit: | |
| description: 'Set to override default network stack commit hash' | |
| type: string | |
| required: false | |
| jobs: | |
| check-format: | |
| name: Check coding conventions | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ghcr.io/cheriot-platform/devcontainer:latest | |
| options: --user 1001 | |
| steps: | |
| - name: Checkout repository and submodules | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Generate compiler_commands.json files | |
| run: ./scripts/generate_compile_commands.sh | |
| - name: Run clang-format | |
| run: ./scripts/run_clang_format.sh /cheriot-tools/bin | |
| check-examples: | |
| name: Build and run examples | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ghcr.io/cheriot-platform/devcontainer:latest | |
| options: --user 1001 | |
| steps: | |
| - name: Checkout repository and submodules | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Set RTOS version | |
| if: ${{ inputs.rtos_commit }} | |
| run: | | |
| cd cheriot-rtos | |
| git checkout ${{ inputs.rtos_commit }} | |
| git submodule update --init --recursive | |
| - name: Set network stack version | |
| if: ${{ inputs.network_stack_commit }} | |
| run: | | |
| cd network-stack | |
| git checkout ${{ inputs.network_stack_commit }} | |
| git submodule update --init --recursive | |
| - name: Build examples | |
| run: | | |
| set -e | |
| for example_dir in $PWD/examples/*/; do | |
| if [ -f $example_dir/xmake.lua ] ; then | |
| cd $example_dir | |
| echo Building $example_dir | |
| xmake f --sdk=/cheriot-tools/ | |
| xmake | |
| fi | |
| done | |
| - name: Run examples | |
| run: | | |
| try_run() | |
| { | |
| timeout 10 xmake run | |
| RESULT=$? | |
| if [ $RESULT -eq 0 ] ; then | |
| return 0 | |
| fi | |
| if [ -f .noterminate -a $RESULT -eq 124 ] ; then | |
| echo Killed via timeout, as expected | |
| return 0 | |
| fi | |
| if [ -f .xcrash ] ; then | |
| echo Killed via CHERI trap, as expected | |
| return 0 | |
| fi | |
| echo Test $(pwd) failed! | |
| exit 1 | |
| } | |
| for example_dir in $PWD/examples/*/; do | |
| if [ -f $example_dir/xmake.lua ] ; then | |
| cd $example_dir | |
| # Skip trying to run tests if the don't run on a simulator | |
| if grep sail xmake.lua ; then | |
| echo Testing $example_dir with Sail | |
| try_run | |
| fi | |
| if grep ibex xmake.lua ; then | |
| echo Testing $example_dir with Ibex | |
| try_run | |
| fi | |
| fi | |
| done | |
| all-checks: | |
| needs: [check-examples, check-format] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Dummy step | |
| run: true |