Skip to content

Commit

Permalink
TODO Add parseConfigs.py to workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jrvollmer committed Sep 16, 2023
1 parent 3de5b9b commit 40003cb
Showing 1 changed file with 19 additions and 36 deletions.
55 changes: 19 additions & 36 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,51 +40,33 @@ jobs:
git clean -ffdxe mbed-os
git reset --hard HEAD
# Checks if the current reference in mbed-os.lib is the same as what is stored on the runner from the
# previous workflow. If not, update the stored reference and fetch the new libraries
# TODO This only handles mbed-os.lib. To be able to handle other .lib files, it would be worth creating
# a script or custom action to check/update all library references
- name: Check if mbed-os Libraries Need to be Fetched
id: check-mbed-os-libs
# Gets the two most recent states of the repo on the runner. If any *.lib files changed between the two commits, fetch the libraries
- name: Fetch Libraries If Needed
run: |
if [[ -f "$MBED_OS_REF_LOCATION/mbed-os.lib" ]]; then
if [[ -n $(diff "$MBED_OS_REF_LOCATION/mbed-os.lib" mbed-os.lib) ]]; then
cp mbed-os.lib "$MBED_OS_REF_LOCATION"
echo "fetch_libs=y" >> "$GITHUB_OUTPUT"
echo "Needed to fetch mbed-os libraries because they were not up-to-date on the runner" >> $GITHUB_STEP_SUMMARY
else
echo "fetch_libs=$([[ -d mbed-os ]] && echo n || echo y)" >> "$GITHUB_OUTPUT"
[[ -d mbed-os ]] && \
echo "mbed-os libraries are up-to-date :relieved:" >> $GITHUB_STEP_SUMMARY || \
echo "Needed to fetch mbed-os libraries because mbed-os did not exist on the runner, but the stored library reference was up-to-date :finnadie:" >> $GITHUB_STEP_SUMMARY
fi
else
mkdir -p "$MBED_OS_REF_LOCATION"
cp mbed-os.lib "$MBED_OS_REF_LOCATION"
echo "fetch_libs=$([[ -d mbed-os ]] && echo n || echo y)" >> "$GITHUB_OUTPUT"
echo "Needed to fetch mbed-os libraries because neither mbed-os nor the stored reference was present on the runner :point_right::point_left:" >> $GITHUB_STEP_SUMMARY
commits=$(git reflog -1 | grep -Po "(?<=moving from )\S+|(?<= to )\S+$")
if [[ -n "$(git diff --name-only $commits *.lib)" ]]; then
echo "Needed to fetch mbed-os libraries :finnadie:" >> $GITHUB_STEP_SUMMARY
#if [[ -d mbed-os ]]; then
# echo "Removing mbed-os before fetching libraries"
# rm -rf mbed-os
#fi
# Fetch libraries
#mbed-tools deploy
fi
- name: Fetch Mbed Libraries
if: steps.check-mbed-os-libs.outputs.fetch_libs == 'y'
run: |
if [[ -d mbed-os ]]; then
echo "Removing mbed-os before fetching libraries"
rm -rf mbed-os
fi
mbed-tools deploy
# Gets device info using `mbed-tools detect` and sets output needed for compiling and flashing
# NOTE: Expecting '/mnt/$USER/' to be the base path for the mount point, as specified in the runner's ldm (https://github.com/LemonBoy/ldm) configuration, despite /media/[$USER/] typically being the base path for removable media
# NOTE: Expecting '/mnt/$USER/' to be the base path for the mount point, as specified in the runner's ldm (https://github.com/LemonBoy/ldm) configuration,
# despite /media/[$USER/] typically being the base path for removable media
- name: Get Device Info
id: get-dev-info
run: |
detect_out=$(mbed-tools detect)
device=$(echo "$detect_out" | grep -oE "NUCLEO_\\S*")
device=$(python3 parseConfigs.py)
detect_out=$(mbed-tools detect | grep "$device")
#device=$(echo "$detect_out" | grep -oE "NUCLEO_\\S*")
serial=$(echo "$detect_out" | grep -oE "/dev/tty\\S*")
mountpoint=$(echo "$detect_out" | grep -oE "/mnt/$USER/\\S*")
if [[ -z "$device" || -z "$serial" || -z "$mountpoint" ]]; then
echo "Failed to detect target, serial port, and/or mount point matching 'NUCLEO_*', '/dev/tty*', and '/mnt/$USER/*', respectively :hurtrealbad:" >> $GITHUB_STEP_SUMMARY
if [[ -z "$serial" || -z "$mountpoint" ]]; then
echo "Failed to detect serial port and/or mount point matching '/dev/tty*' and '/mnt/$USER/*', respectively, for target '$device' :hurtrealbad:" >> $GITHUB_STEP_SUMMARY
exit 1
fi
echo "device=$device" >> "$GITHUB_OUTPUT"
Expand All @@ -102,6 +84,7 @@ jobs:

steps:
- name: Compile and Flash
if: false # TODO Remove
run: |
mbed-tools configure -t ${{ env.TOOLCHAIN }} -m ${{ needs.setup.outputs.target }}
cmake -S . -B cmake_build/${{ needs.setup.outputs.target }}/${{ env.BUILD_PROFILE }}/${{ env.TOOLCHAIN }} -GNinja
Expand Down

0 comments on commit 40003cb

Please sign in to comment.