-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unit test to cicd #28
Open
ramya-subramanyam
wants to merge
8
commits into
develop
Choose a base branch
from
add-unit-test-to-cicd
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8ed0d60
.gitmodules: extras/hil_support: Add submodule.
ramya-subramanyam 476931f
Makefile.arduino.mk: tests/unity: Rename folder.
ramya-subramanyam e8a76b6
tests/unity: Move makefiles inside and test files inside folder.
ramya-subramanyam 015176f
.github/workflows: Add Unity HIL tests on CI/CD.
ramya-subramanyam f791d6a
tests/unity: Add test config file.
ramya-subramanyam 0849cf2
.gitmodules: Remove submodule for hil support.
ramya-subramanyam e9b5a70
.github/workflows: Fix hil unity checks.
ramya-subramanyam f35113b
.github/workflows: Build based on generated package installation.
ramya-subramanyam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
name: Hil unity library checks | ||
|
||
# on which event should we start push, pull request or schedule dispatches | ||
on: | ||
- push | ||
- pull_request | ||
|
||
env: | ||
TEST_VERSION: 1.0.0 | ||
|
||
jobs: | ||
|
||
# The build job compiles the sample code for different boards | ||
tests: | ||
|
||
############################################################################# | ||
# This action sets common variables for the flow and | ||
# identifies the libs to compile | ||
runs-on: | ||
- self-hosted | ||
- X64 | ||
- Linux | ||
- PSoC | ||
|
||
# which combination of sample code and boards should run | ||
# for this example of 2 sample codes and 3 boards a total of 2x3=6 runners have to work. | ||
# if we have only 4 runner then these 4 are started and the last 2 are waiting until they can start | ||
strategy: | ||
|
||
matrix: | ||
# List of all examples in the lib to compile | ||
example: [ | ||
examples/testSketch/testSketch.ino | ||
] | ||
|
||
# board packages we want to run | ||
# attention the matrix spans over the fqbn not platform so that we can choose different boards | ||
# this example compiles each sample code for Arduino Uno, XMC2Go and XMC4700 boards | ||
fqbn: [ | ||
"infineon:psoc:cy8ckit_062s2_ai" | ||
] | ||
|
||
# include additional information for each fqbn, in this case the platform name to install | ||
include: | ||
- fqbn: "infineon:psoc:cy8ckit_062s2_ai" | ||
platform: "infineon:psoc" | ||
|
||
# These are the steps which should run for each combination of fqbn and example code | ||
steps: | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- name: Generate package json | ||
run: | | ||
python ./tools/release.py build-local | ||
|
||
- name: Start local HTTP server | ||
run: | | ||
cd pkg_build | ||
nohup python -m http.server 8000 & echo $! > server.pid | ||
|
||
- name: Install/Update Arduino Platform | ||
run: | | ||
arduino-cli core update-index | ||
arduino-cli core install ${{ matrix.platform }} --additional-urls http://localhost:8000/package_psoc_index.json | ||
arduino-cli core list | ||
|
||
- name: Kill local HTTP server | ||
run: | | ||
cd pkg_build | ||
kill $(cat server.pid) | ||
rm server.pid | ||
|
||
- name: Remove latest installed platform version | ||
run: | | ||
cd ~/.arduino15/packages/infineon/hardware/psoc | ||
rm -rf * | ||
|
||
- name: copy/link repository to arduino path | ||
run: | | ||
mkdir ~/.arduino15/packages/infineon/hardware/psoc/$TEST_VERSION | ||
cp -a ./* ~/.arduino15/packages/infineon/hardware/psoc/$TEST_VERSION | ||
cd ~/.arduino15/packages/infineon/hardware/psoc/$TEST_VERSION | ||
|
||
- name: copy/link arduino core api path | ||
run: | | ||
mkdir ~/.arduino15/packages/infineon/hardware/psoc/$TEST_VERSION/cores/psoc/api | ||
cp -a ~/.arduino15/packages/infineon/hardware/psoc/$TEST_VERSION/extras/arduino-core-api/api/* ~/.arduino15/packages/infineon/hardware/psoc/$TEST_VERSION/cores/psoc/api | ||
|
||
# Fetch variables and move them to the GITHUB_OUTPUT and fetch HIL information | ||
- id: startup | ||
run: | | ||
# switch on the HIL | ||
cd /opt/runner_support/ | ||
|
||
# set the hil-unity-checks | ||
hil=$(./py_checkusb.py --readyaml ~/.arduino15/packages/infineon/hardware/psoc/$TEST_VERSION/tests/unity/hil-unity-checklist.yaml --json) | ||
echo "hil=${hil}" >> $GITHUB_OUTPUT | ||
echo "hil=${hil}" | ||
|
||
# fetch unity libraries | ||
readarray -t data < <(echo $hil | jq -r '.|keys[]') | ||
export dev=$(jq --compact-output --null-input '$ARGS.positional' --args -- "${data[@]}") | ||
echo "devices=${dev}" >> $GITHUB_OUTPUT | ||
echo "devices=${dev}" | ||
|
||
# setup environment | ||
- name: Environment | ||
run: | | ||
hil=${{ toJson(steps.startup.outputs.hil) }} | ||
REPO="$(basename "$GITHUB_REPOSITORY")" | ||
DEVICE=${{ steps.startup.outputs.devices }} | ||
DEVICE=$(echo $DEVICE | tr -d '[]') | ||
FQBN=$(echo $DEVICE | tr -d '[]') | ||
DEVICE=`tr ':' '.' <<<"${DEVICE}"` | ||
|
||
echo "repo=$REPO" >> $GITHUB_ENV | ||
echo "device=$DEVICE" >> $GITHUB_ENV | ||
echo "version=$TEST_VERSION" >> $GITHUB_ENV | ||
echo "fqbn=$FQBN" >> $GITHUB_ENV | ||
|
||
echo "Repo " $REPO | ||
echo "Device " $DEVICE | ||
echo "FQBN " $FQBN | ||
echo "Version " ${TEST_VERSION} | ||
|
||
- name: Build | ||
run: | | ||
export TMPDIR=$HOME/tmp | ||
mkdir -p $TMPDIR | ||
rm -rf $HOME/artefact | ||
mkdir -p $HOME/artefact | ||
|
||
cd ~/.arduino15/packages/infineon/hardware/psoc/$TEST_VERSION/tests/unity/ | ||
echo "==============================================================================================================" | ||
echo "Run Tests" | ||
echo "==============================================================================================================" | ||
make FQBN=${{ env.fqbn }} PORT=/dev/ttyACM0 single_hardware_connected | ||
mkdir -p ~/artefact/unit_tests/${{ env.device }} | ||
mv ./build/* ~/artefact/unit_tests/. | ||
echo "==============================================================================================================" | ||
|
||
|
||
|
||
echo "==============================================================================================================" | ||
echo "Monitor" | ||
timeout 1m \ | ||
/opt/runner_support/py_console.py \ | ||
--port /dev/ttyACM0 \ | ||
--baud 115200 \ | ||
--report ~/artefact/unit_tests/${{ env.device }}/report.json | ||
|
||
echo "==============================================================================================================" | ||
|
||
|
||
# Upload the compiled HEX files to the GitHub server | ||
- name: Artefact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.device }} | ||
path: ~/artefact/* | ||
if-no-files-found: ignore |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
infineon:psoc:cy8ckit_062s2_ai: | ||
math: | ||
1: | ||
- "math" | ||
|
||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that these steps are not really necessary as they are taking care by the arduino-cli installation or?