[PATCH rtems 1/2] github: Enable CI
Christian Mauderer
christian.mauderer at embedded-brains.de
Mon Jan 16 13:41:19 UTC 2023
Allow users to optionally use the CI from github.
---
.github/actions/build-bsps/action.yml | 49 ++++++++
.github/actions/run-simulator/action.yml | 144 +++++++++++++++++++++++
.github/workflows/bsps.yml | 63 ++++++++++
.github/workflows/simulator.yml | 72 ++++++++++++
4 files changed, 328 insertions(+)
create mode 100644 .github/actions/build-bsps/action.yml
create mode 100644 .github/actions/run-simulator/action.yml
create mode 100644 .github/workflows/bsps.yml
create mode 100644 .github/workflows/simulator.yml
diff --git a/.github/actions/build-bsps/action.yml b/.github/actions/build-bsps/action.yml
new file mode 100644
index 0000000000..c06e560125
--- /dev/null
+++ b/.github/actions/build-bsps/action.yml
@@ -0,0 +1,49 @@
+name: "Build BSPs"
+description: "Build BSPs for the given target architecture."
+
+inputs:
+ bsp:
+ description: "The bsp to build 'sparc/erc32'"
+ type: string
+ required: true
+ sources-rtems:
+ description: "Where to find the RTEMS sources. Use absolute path!"
+ type: string
+ required: true
+ prefix:
+ description: "Prefix directory with the installed tools. Use absolute path!"
+ type: string
+ required: true
+
+runs:
+ using: "composite"
+ steps:
+ - name: create name for logs
+ shell: bash
+ run: |
+ shortname=`echo "${{ inputs.bsp }}" | sed -e "s|/|_|g"`
+ echo "shortname=${shortname}" >> $GITHUB_ENV
+ - name: create log dir
+ shell: bash
+ run: mkdir "${GITHUB_WORKSPACE}"/bsp-logs
+ - name: Run BSP builder
+ shell: bash
+ run: |
+ "${{ inputs.prefix }}"/bin/rtems-bsp-builder \
+ --build-path "${GITHUB_WORKSPACE}"/rtems-build \
+ --prefix "${{ inputs.prefix }}" \
+ --rtems-tools "${{ inputs.prefix }}/bin" \
+ --rtems "${{ inputs.sources-rtems }}" \
+ --bsp ${{ inputs.bsp }} \
+ --log "${GITHUB_WORKSPACE}"/bsp-logs/log-${{ env.shortname }}.txt \
+ --warnings-report "${GITHUB_WORKSPACE}"/bsp-logs/warnings-${{ env.shortname }}.txt \
+ --failures-report "${GITHUB_WORKSPACE}"/bsp-logs/failures-${{ env.shortname }}.txt
+ - name: Archive log
+ uses: actions/upload-artifact at v3
+ with:
+ name: log-${{ env.shortname }}
+ path: bsp-logs
+ - name: Check for errors
+ shell: bash
+ run: |
+ grep "Failures: 0" "$GITHUB_WORKSPACE"/bsp-logs/log-${{ env.shortname }}.txt
diff --git a/.github/actions/run-simulator/action.yml b/.github/actions/run-simulator/action.yml
new file mode 100644
index 0000000000..23aa70e8ea
--- /dev/null
+++ b/.github/actions/run-simulator/action.yml
@@ -0,0 +1,144 @@
+name: "Run Simulator"
+description: "Build BSPs for the given target/BSP and run tests on a simulator"
+
+inputs:
+ target:
+ description: "The Arch/BSP to run. For example 'sparc/erc32'"
+ type: string
+ required: true
+ sources-rtems:
+ description: "Where to find the RTEMS sources. Use absolute path!"
+ type: string
+ required: true
+ prefix:
+ description: "Prefix directory with the installed tools. Use absolute path!"
+ type: string
+ required: true
+
+runs:
+ using: "composite"
+ steps:
+ - shell: bash
+ run: |
+ # Find correct parameters for this simulator
+ args=""
+ found=0
+ [ "${{ inputs.target }}" == "sparc/erc32" ] && \
+ args="--rtems-bsp=erc32-sis" && \
+ found=1
+ [ "${{ inputs.target }}" == "sparc/gr740" ] && \
+ args="--rtems-bsp=gr740-sis" && \
+ found=1
+ [ "${{ inputs.target }}" == "riscv/griscv" ] && \
+ args="--rtems-bsp=griscv-sis" && \
+ found=1
+ [ "${{ inputs.target }}" == "arm/xilinx_zynq_a9_qemu" ] && \
+ args="--rtems-bsp=xilinx_zynq_a9_qemu" && \
+ found=1
+ echo "rtems_test_args=${args}" >> $GITHUB_ENV
+ echo "simulator_supported=${found}" >> $GITHUB_ENV
+ - if: ${{ env.simulator_supported == 0 }}
+ shell: bash
+ run: |
+ # Check whether parameters for this simulator have been found
+ echo "${{ inputs.target }} is not supported for simulator runs"
+ false
+ - shell: bash
+ run: |
+ # create environment variables for paths and names
+ shortname=`echo "${{ inputs.target }}" | sed -e "s|/|_|g"`
+ echo "shortname=${shortname}" >> $GITHUB_ENV
+ echo "logdir=${GITHUB_WORKSPACE}/logs-${shortname}" >> $GITHUB_ENV
+ echo "builddir=${GITHUB_WORKSPACE}/build-${shortname}" >> $GITHUB_ENV
+ - shell: bash
+ run: |
+ # create directories
+ mkdir -p "${{ env.logdir }}"
+ mkdir -p "${{ env.builddir }}"
+ - shell: bash
+ run: |
+ # generate BSP config
+ echo -e "[${{ inputs.target }}]\nBUILD_TESTS = True" >> "${{ env.builddir }}/config.ini"
+ cat "${{ env.builddir }}/config.ini"
+ - shell: bash
+ run: |
+ # configure
+ cd ${{ env.builddir }} && ${{ inputs.sources-rtems }}/waf configure \
+ --out="${{ env.builddir }}" \
+ --rtems-config="${{ env.builddir }}/config.ini" \
+ --top="${{ inputs.sources-rtems }}" \
+ --prefix="${{ inputs.prefix }}"
+ - if: ${{ failure() }}
+ shell: bash
+ run: |
+ # print log
+ cat "${{ env.builddir }}/config.log"
+ - shell: bash
+ run: |
+ # compile
+ cd ${{ env.builddir }} && ${{ inputs.sources-rtems }}/waf \
+ --out="${{ env.builddir }}" \
+ --top="${{ inputs.sources-rtems }}" \
+ --prefix="${{ inputs.prefix }}"
+ find ${{ env.builddir }} -name "*.exe"
+ - shell: bash
+ run: |
+ # run tests
+ # Note: PATH needs to be adapted so that for example qemu is found
+ PATH="${{ inputs.prefix }}/bin":$PATH rtems-test \
+ --log="${{ env.logdir }}/test.log" \
+ --log-mode=all \
+ --report-path="${{ env.logdir }}/report" \
+ --report-format=json \
+ --warn-all \
+ --rtems-tools="${{ inputs.prefix }}" \
+ ${{ env.rtems_test_args }} \
+ ${{ env.builddir }}
+ - name: Archive log
+ uses: actions/upload-artifact at v3
+ if: success() || failure()
+ with:
+ name: test-logs-${{ env.shortname }}
+ path: logs-${{ env.shortname }}
+ - shell: bash
+ run: |
+ # Set default values
+ echo "results_total=-1" | tee -a $GITHUB_ENV
+ echo "tests_passed=0" | tee -a $GITHUB_ENV
+ echo "tests_user-input=0" | tee -a $GITHUB_ENV
+ echo "tests_expected-fail=0" | tee -a $GITHUB_ENV
+ echo "tests_benchmark=0" | tee -a $GITHUB_ENV
+ - shell: bash
+ run: |
+ # Count number of passed / failed / ... tests
+ jq -r '.reports | group_by(.result) | map({result: .[0].result, count: length})[] | ("tests_"+.result+"="+(.count|tostring))' ${{ env.logdir }}/report.json | tee -a $GITHUB_ENV
+ jq -r '.reports | ("results_total="+(length|tostring))' ${{ env.logdir }}/report.json | tee -a $GITHUB_ENV
+ - shell: bash
+ run: |
+ # Summarize tests
+ echo "results_ok=$(expr \
+ ${{ env.tests_passed }} + \
+ ${{ env.tests_user-input }} + \
+ ${{ env.tests_expected-fail }} + \
+ ${{ env.tests_benchmark }})" | tee -a $GITHUB_ENV
+ - shell: bash
+ run: |
+ # Generate ASCII-Table report
+ jq -r '.reports[] | ((.executable | split("testsuites/")[1] | split(".exe")[0])+";"+(if .result=="passed" or .result=="user-input" or .result=="benchmark" or .result=="expected-fail" then "\u001b[32m\u2714" else "\u001b[31m\u2716" end)+" "+.result+"\u001b[0m")' ${{ env.logdir }}/report.json | column -t -s\;
+ - shell: bash
+ run: |
+ # Summarize not passed tests on github step summary
+ echo "### Tests for ${{ inputs.target }}" >> $GITHUB_STEP_SUMMARY
+ jq -r '.reports | group_by(.result) | map({result: .[0].result, count: length})[] | ("- "+.result+": "+(.count|tostring))' ${{ env.logdir }}/report.json >> $GITHUB_STEP_SUMMARY
+ echo "" >> $GITHUB_STEP_SUMMARY
+ if [ ${{ env.results_ok }} -ne ${{ env.results_total }} ]; then
+ echo "The following tests did not pass:" >> $GITHUB_STEP_SUMMARY
+ echo "| name | result |" >> $GITHUB_STEP_SUMMARY
+ echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
+ jq -r '.reports[] | select(.result != "passed" and .result != "benchmark" and .result != "user-input" and .result != "expected-fail") | ("| "+(.executable | split("testsuites/")[1] | split(".exe")[0])+" | "+.result+" |")' ${{ env.logdir }}/report.json >> $GITHUB_STEP_SUMMARY
+ fi
+ - shell: bash
+ run: |
+ # check whether all tests worked as expected
+ echo "${{ env.results_ok }} of ${{ env.results_total }} worked as expected."
+ [ ${{ env.results_ok }} -eq ${{ env.results_total }} ]
diff --git a/.github/workflows/bsps.yml b/.github/workflows/bsps.yml
new file mode 100644
index 0000000000..c42e84cb5e
--- /dev/null
+++ b/.github/workflows/bsps.yml
@@ -0,0 +1,63 @@
+name: BSPs
+
+on:
+ # Trigger manually from the Actions tab
+ workflow_dispatch:
+
+jobs:
+ setup-bsp-matrix:
+ runs-on: ubuntu-latest
+ outputs:
+ matrix: ${{ steps.set-matrix.outputs.matrix }}
+ steps:
+ - uses: actions/checkout at v3
+ with:
+ path: rtems
+ - name: Build matrix
+ id: set-matrix
+ shell: bash
+ run: |
+ cd ${GITHUB_WORKSPACE}/rtems
+ out=$(./waf bsp_list | jq -R '.|split("/")|{ arch: .[0], bsp: .[1] }' | jq -sc '{include: .}')
+ echo "$out"
+ echo "::set-output name=matrix::$out"
+
+ build:
+ needs: setup-bsp-matrix
+ strategy:
+ fail-fast: false
+ matrix: ${{ fromJson(needs.setup-bsp-matrix.outputs.matrix) }}
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout at v3
+ with:
+ path: rtems
+ - uses: actions/checkout at v3
+ with:
+ path: rtems-actions
+ ref: ci
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install \
+ python3 \
+ python-is-python3
+ - name: Download toolchain artifact
+ uses: dawidd6/action-download-artifact at v2
+ with:
+ repo: RTEMS/rtems-source-builder
+ branch: ci
+ workflow: toolchain.yml
+ workflow_conclusion: completed
+ name: tools-${{ matrix.arch }}
+ - name: Unpack toolchain
+ run: |
+ mkdir -p "$GITHUB_WORKSPACE/toolchain"
+ for t in *.tar.bz2; do tar xf $t -v -C "$GITHUB_WORKSPACE/toolchain"; done
+ ls -la "$GITHUB_WORKSPACE/toolchain"
+ - name: Build BSPs
+ uses: ./rtems-actions/.github/actions/build-bsps
+ with:
+ bsp: "${{ matrix.arch }}/${{ matrix.bsp }}"
+ sources-rtems: "$GITHUB_WORKSPACE/rtems"
+ prefix: "$GITHUB_WORKSPACE/toolchain/opt/rtems/6"
diff --git a/.github/workflows/simulator.yml b/.github/workflows/simulator.yml
new file mode 100644
index 0000000000..7360e76a5e
--- /dev/null
+++ b/.github/workflows/simulator.yml
@@ -0,0 +1,72 @@
+name: Simulator
+
+on:
+ # Triggers the workflow on push or pull request for the given branch
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+ # Trigger manually from the Actions tab
+ workflow_dispatch:
+
+jobs:
+ build:
+ strategy:
+ fail-fast: false
+ matrix:
+ simulators:
+ - riscv/griscv
+ - sparc/gr740
+ - arm/xilinx_zynq_a9_qemu
+ runs-on: ubuntu-latest
+ steps:
+ - name: split arch and BSP
+ shell: bash
+ run: |
+ arch=`echo "${{ matrix.simulators }}" | sed -e "s|/.*||g"`
+ bsp=`echo "${{ matrix.simulators }}" | sed -e "s|.*/||g"`
+ echo "arch=${arch}" >> $GITHUB_ENV
+ echo "bsp=${bsp}" >> $GITHUB_ENV
+ - uses: actions/checkout at v3
+ with:
+ path: rtems
+ - uses: actions/checkout at v3
+ with:
+ path: rtems-actions
+ ref: ci
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install \
+ python3 \
+ python-is-python3 \
+ jq
+ - name: Download toolchain artifact
+ uses: dawidd6/action-download-artifact at v2
+ with:
+ repo: RTEMS/rtems-source-builder
+ branch: ci
+ workflow: toolchain.yml
+ workflow_conclusion: completed
+ name: tools-${{ env.arch }}
+ - name: Download qemu artifact
+ uses: dawidd6/action-download-artifact at v2
+ with:
+ repo: RTEMS/rtems-source-builder
+ branch: ci
+ workflow: toolchain.yml
+ workflow_conclusion: completed
+ name: devel-qemu
+ - name: Unpack toolchain
+ run: |
+ mkdir -p "$GITHUB_WORKSPACE/toolchain"
+ for t in *.tar.bz2; do tar xf $t -v -C "$GITHUB_WORKSPACE/toolchain"; done
+ ls -la "$GITHUB_WORKSPACE/toolchain"
+ - name: Start simulator run
+ id: simulator
+ uses: ./rtems-actions/.github/actions/run-simulator
+ with:
+ target: ${{ matrix.simulators }}
+ sources-rtems: "$GITHUB_WORKSPACE/rtems"
+ prefix: "$GITHUB_WORKSPACE/toolchain/opt/rtems/6"
--
2.35.3
More information about the devel
mailing list