diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 14aacdb..98ff3ac 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -12,10 +12,17 @@ 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: - self-hosted + defaults: + run: + working-directory: ${{ env.embedded-mbed-dir }} outputs: target: ${{ steps.get-dev-info.outputs.device }} @@ -23,9 +30,16 @@ jobs: flash_mntpt: ${{ steps.get-dev-info.outputs.mountpoint }} steps: - - name: Get Repo + - 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 @@ -80,20 +94,53 @@ 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: needs: setup env: BUILD_PROFILE: develop TOOLCHAIN: GCC_ARM + venv_path: ${{ github.workspace }}/btf_venv runs-on: - self-hosted + defaults: + run: + working-directory: ${{ env.embedded-mbed-dir }} steps: - - name: Compile and Flash + - name: Compile embedded-mbed 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 }} - cp cmake_build/${{ needs.setup.outputs.target }}/${{ env.BUILD_PROFILE }}/${{ env.TOOLCHAIN }}/embedded-mbed.bin ${{ needs.setup.outputs.flash_mntpt }} + echo "Compile now" # TODO + # TODO mbed-tools configure -t ${{ env.TOOLCHAIN }} -m ${{ needs.setup.outputs.target }} + # TODO cmake -S . -B cmake_build/${{ needs.setup.outputs.target }}/${{ env.BUILD_PROFILE }}/${{ env.TOOLCHAIN }} -GNinja + # TODO cmake --build cmake_build/${{ needs.setup.outputs.target }}/${{ env.BUILD_PROFILE }}/${{ env.TOOLCHAIN }} + + - name: Setup Virtual Environment and Start BTF + id: start-btf + continue-on-error: true + working-directory: ${{ env.btf-dir }} + run: | + source setup.sh ${{ env.venv_path }} + python3 testRunner.py ${{ github.workspace }}/${{ github.embedded-mbed-dir }}/tests.yml ${{ github.workspace }}/${{ github.embedded-mbed-dir }}/setup.yml & + echo "$!" + echo "btf_pid=$!" >> "$GITHUB_OUTPUT" + + - name: Run Tests +# TODO working-directory: ${{ env.embedded-mbed-dir }} + if: steps.start-btf.outcome == 'success' + 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 }} + # + # 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 "BTF PID: ${{ steps.start-btf.outputs.btf_pid }}" # TODO echo "Successfully flashed to ${{ needs.setup.outputs.target }} :v:" >> $GITHUB_STEP_SUMMARY + - name: Deactivate Virtual Environment If Needed + if: always() + run: | + echo "$VIRTUAL_ENV" + deactivate # TODO Put this in a condition + rm -rf ${{ env.venv_path }}