Skip to content

Commit

Permalink
TODO Integrate BTF into workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jrvollmer committed Oct 5, 2023
1 parent fecf84b commit b1e07ea
Showing 1 changed file with 57 additions and 4 deletions.
61 changes: 57 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ concurrency:
group: ${{ github.event_name }}.${{ github.head_ref }}.${{ github.workflow }}
cancel-in-progress: false

env:
embedded-mbed-dir: embedded-mbed
btf-dir: BTF

jobs:
setup:
runs-on:
Expand All @@ -23,24 +27,54 @@ jobs:
flash_mntpt: ${{ steps.get-dev-info.outputs.mountpoint }}

steps:
- name: Get Repo
# TODO Remove
- name: Cleanup Everything
run: |
rm -rf ${{ github.workspace }}/*
pwd # TODO
ls # TODO
- name: Get BTF Repo
uses: actions/checkout@v3
with:
repository: ${{ github.repository_owner }}/BTF
path: ${{ env.btf-dir }}

- name: Get embedded-mbed Repo
uses: actions/checkout@v3
with:
path: ${{ env.embedded-mbed-dir }}
# Don't run `git clean -ffdx` and `git reset --hard HEAD` in this step to avoid removing `mbed-os/`.
# These will be run post checkout in the following step
clean: false

# Clean up any changes in the working index, including untracked files aside from mbed-os/
- name: Post Checkout Cleanup
working-directory: ${{ env.embedded-mbed-dir }}
run: |
git clean -ffdxe mbed-os
git reset --hard HEAD
# 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
working-directory: ${{ env.embedded-mbed-dir }}
run: |
pwd # TODO
ls # TODO
git config --global --list
git reflog # TODO
git log
git branch -a
git status
commits=$(git reflog -1 | grep -Po "(?<=moving from )\S+|(?<= to )\S+$")
if [[ -n "$(git diff --name-only $commits *.lib)" ]]; then
echo "${commits% }"
echo "$(git reflog | wc -l)"
if [[ "${commits% }" == "main" && "$(git reflog | wc -l)" == "1" ]]; then
# First time checking out the embedded-mbed repository
echo "Needed to fetch mbed-os libraries :finnadie:" >> $GITHUB_STEP_SUMMARY
# Fetch libraries
mbed-tools deploy
elif [[ -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"
Expand All @@ -55,7 +89,10 @@ jobs:
# despite /media/[$USER/] typically being the base path for removable media
- name: Get Device Info
id: get-dev-info
working-directory: ${{ env.embedded-mbed-dir }}
run: |
pwd # TODO
ls # TODO
# Get the target from the setup configuration file and get information pertaining to it
device=$(grep -Po '(^\s+target:\s+)\K.+' setup.yml)
detect_out=$(mbed-tools detect | grep "$device")
Expand All @@ -74,7 +111,8 @@ jobs:
echo "mountpoint=$mountpoint" >> "$GITHUB_OUTPUT"
echo "Found target '$device' connected to serial port '$serial' with storage mounted to '$mountpoint' :relieved:" >> $GITHUB_STEP_SUMMARY
compile-and-flash:
compile-and-test:
if: false # TODO Remove
needs: setup
env:
BUILD_PROFILE: develop
Expand All @@ -83,11 +121,26 @@ jobs:
- self-hosted

steps:
- name: Compile and Flash
- name: Compile embedded-mbed
working-directory: ${{ env.embedded-mbed-dir }}
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
cmake --build cmake_build/${{ needs.setup.outputs.target }}/${{ env.BUILD_PROFILE }}/${{ env.TOOLCHAIN }}
- name: Setup Virtual Environment and Start BTF
working-directory: ${{ env.btf-dir }}
run: |
echo "source setup.sh ~/"
- name: Run Tests
working-directory: ${{ env.embedded-mbed-dir }}
run: |
# TODO Split up compile and flash so that BTF can be brought to foreground immediately after flashing
# TODO cp cmake_build/${{ needs.setup.outputs.target }}/${{ env.BUILD_PROFILE }}/${{ env.TOOLCHAIN }}/embedded-mbed.bin ${{ needs.setup.outputs.flash_mntpt }}
cp cmake_build/${{ needs.setup.outputs.target }}/${{ env.BUILD_PROFILE }}/${{ env.TOOLCHAIN }}/embedded-mbed.bin ${{ needs.setup.outputs.flash_mntpt }}
# TODO Bring BTF to the foreground
# TODO deactivate venv (???) (If doing this, use 'continu-on-error: true' for this step and create a Deactivate step to deactivate the venv
# TODO If deactivation is necessary, do the same thing with the previous step, but only run the deactivate step if the previous step failed
echo "Successfully flashed to ${{ needs.setup.outputs.target }} :v:" >> $GITHUB_STEP_SUMMARY

0 comments on commit b1e07ea

Please sign in to comment.