unit_tests.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. name: 'Unit tests'
  2. on:
  3. pull_request:
  4. env:
  5. TARGETS: f7
  6. DEFAULT_TARGET: f7
  7. FBT_TOOLCHAIN_PATH: /opt
  8. jobs:
  9. run_units_on_test_bench:
  10. runs-on: [self-hosted, FlipperZeroTest]
  11. steps:
  12. - name: 'Decontaminate previous build leftovers'
  13. run: |
  14. if [ -d .git ]; then
  15. git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
  16. fi
  17. - name: Checkout code
  18. uses: actions/checkout@v3
  19. with:
  20. fetch-depth: 0
  21. ref: ${{ github.event.pull_request.head.sha }}
  22. - name: 'Get flipper from device manager (mock)'
  23. id: device
  24. run: |
  25. echo "flipper=/dev/ttyACM0" >> $GITHUB_OUTPUT
  26. - name: 'Flashing target firmware'
  27. id: first_full_flash
  28. run: |
  29. ./fbt flash_usb_full PORT=${{steps.device.outputs.flipper}} FORCE=1
  30. source scripts/toolchain/fbtenv.sh
  31. python3 scripts/testing/await_flipper.py ${{steps.device.outputs.flipper}}
  32. - name: 'Validating updater'
  33. id: second_full_flash
  34. if: success()
  35. run: |
  36. ./fbt flash_usb_full PORT=${{steps.device.outputs.flipper}} FORCE=1
  37. source scripts/toolchain/fbtenv.sh
  38. python3 scripts/testing/await_flipper.py ${{steps.device.outputs.flipper}}
  39. - name: 'Flash unit tests firmware'
  40. id: flashing
  41. if: success()
  42. run: |
  43. ./fbt flash OPENOCD_ADAPTER_SERIAL=2A0906016415303030303032 FIRMWARE_APP_SET=unit_tests FORCE=1
  44. - name: 'Wait for flipper to finish updating'
  45. id: connect
  46. if: steps.flashing.outcome == 'success'
  47. run: |
  48. source scripts/toolchain/fbtenv.sh
  49. python3 scripts/testing/await_flipper.py ${{steps.device.outputs.flipper}}
  50. - name: 'Copy assets and unit tests data to flipper'
  51. id: copy
  52. if: steps.connect.outcome == 'success'
  53. run: |
  54. source scripts/toolchain/fbtenv.sh
  55. python3 scripts/storage.py -p ${{steps.device.outputs.flipper}} -f send assets/unit_tests /ext/unit_tests
  56. - name: 'Run units and validate results'
  57. if: steps.copy.outcome == 'success'
  58. run: |
  59. source scripts/toolchain/fbtenv.sh
  60. python3 scripts/testing/units.py ${{steps.device.outputs.flipper}}
  61. - name: 'Get last release tag'
  62. id: release_tag
  63. if: success()
  64. run: |
  65. echo "tag=$(git tag -l --sort=-version:refname | grep -v "rc\|RC" | head -1)" >> $GITHUB_OUTPUT
  66. - name: 'Decontaminate previous build leftovers'
  67. if: success()
  68. run: |
  69. if [ -d .git ]; then
  70. git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
  71. fi
  72. - name: 'Checkout latest release'
  73. uses: actions/checkout@v3
  74. if: success()
  75. with:
  76. fetch-depth: 0
  77. ref: ${{ steps.release_tag.outputs.tag }}
  78. - name: 'Flash last release'
  79. if: success()
  80. run: |
  81. ./fbt flash OPENOCD_ADAPTER_SERIAL=2A0906016415303030303032 FIRMWARE_APP_SET=unit_tests FORCE=1
  82. - name: 'Wait for flipper to finish updating'
  83. if: success()
  84. run: |
  85. source scripts/toolchain/fbtenv.sh
  86. python3 scripts/testing/await_flipper.py ${{steps.device.outputs.flipper}}
  87. - name: 'Format flipper SD card'
  88. id: format
  89. if: success()
  90. run: |
  91. source scripts/toolchain/fbtenv.sh
  92. python3 scripts/storage.py -p ${{steps.device.outputs.flipper}} format_ext