ci.yml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. name: 'CI'
  2. on:
  3. push:
  4. paths-ignore:
  5. - 'wiki/**'
  6. - 'wiki_static/**'
  7. pull_request:
  8. jobs:
  9. build:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - name: Checkout code
  13. uses: actions/checkout@v2
  14. with:
  15. submodules: true
  16. - uses: satackey/action-docker-layer-caching@v0.0.8
  17. continue-on-error: true
  18. with:
  19. key: docker-cache-${{ hashFiles('docker/**') }}-{hash}
  20. restore-keys: docker-cache-${{ hashFiles('docker/**') }}-
  21. - name: Build docker image
  22. uses: ./.github/actions/docker
  23. - name: Check syntax
  24. uses: ./.github/actions/docker
  25. continue-on-error: false
  26. with:
  27. run: /syntax_check.sh
  28. - name: Build F2 bootloader in docker
  29. uses: ./.github/actions/docker
  30. with:
  31. run: make -C bootloader TARGET=f2
  32. - name: Publish F2 bootloader artifacts
  33. uses: actions/upload-artifact@v2
  34. with:
  35. name: bootloader_f2
  36. path: |
  37. bootloader/.obj/f2/bootloader.elf
  38. bootloader/.obj/f2/bootloader.bin
  39. bootloader/.obj/f2/bootloader.hex
  40. if-no-files-found: error
  41. retention-days: 7
  42. - name: Build local testing firmware in docker
  43. uses: ./.github/actions/docker
  44. with:
  45. run: make -C firmware TARGET=local
  46. - name: Run local tests
  47. uses: ./.github/actions/docker
  48. with:
  49. run: make -C firmware TARGET=local APP_TEST=1 run
  50. - name: Build F2 firmware in docker
  51. uses: ./.github/actions/docker
  52. with:
  53. run: make -C firmware TARGET=f2 APP_RELEASE=1
  54. - name: Publish F2 firmware artifacts
  55. uses: actions/upload-artifact@v2
  56. with:
  57. name: firmware_f2
  58. path: |
  59. firmware/.obj/f2/firmware.elf
  60. firmware/.obj/f2/firmware.bin
  61. firmware/.obj/f2/firmware.hex
  62. if-no-files-found: error
  63. retention-days: 7
  64. - name: Build F3 bootloader in docker
  65. uses: ./.github/actions/docker
  66. with:
  67. run: make -C bootloader TARGET=f3
  68. - name: Publish F3 bootloader artifacts
  69. uses: actions/upload-artifact@v2
  70. with:
  71. name: bootloader_f3
  72. path: |
  73. bootloader/.obj/f3/bootloader.elf
  74. bootloader/.obj/f3/bootloader.bin
  75. bootloader/.obj/f3/bootloader.hex
  76. if-no-files-found: error
  77. retention-days: 7
  78. - name: Build F3 firmware in docker
  79. uses: ./.github/actions/docker
  80. with:
  81. run: make -C firmware TARGET=f3 APP_RELEASE=1
  82. - name: Publish F3 firmware artifacts
  83. uses: actions/upload-artifact@v2
  84. with:
  85. name: firmware_f3
  86. path: |
  87. firmware/.obj/f3/firmware.elf
  88. firmware/.obj/f3/firmware.bin
  89. firmware/.obj/f3/firmware.hex
  90. if-no-files-found: error
  91. retention-days: 7
  92. upload:
  93. name: Upload artifacts to external storage
  94. needs: build
  95. runs-on: ubuntu-latest
  96. steps:
  97. - name: Get bootloader
  98. uses: actions/download-artifact@v2
  99. with:
  100. name: bootloader_f2
  101. path: bootloader
  102. - name: Get firmware
  103. uses: actions/download-artifact@v2
  104. with:
  105. name: firmware_f2
  106. path: firmware
  107. - name: Upload bootloader
  108. uses: burnett01/rsync-deployments@4.1
  109. with:
  110. switches: -avzp --delete
  111. path: bootloader
  112. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${GITHUB_REF##*/}/"
  113. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  114. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  115. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  116. - name: Upload firmware
  117. uses: burnett01/rsync-deployments@4.1
  118. with:
  119. switches: -avzp --delete
  120. path: firmware
  121. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}${GITHUB_REF##*/}/"
  122. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  123. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  124. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  125. fullfirmware:
  126. name: Create latest full firmware
  127. needs: upload
  128. if: github.ref == 'refs/heads/master'
  129. runs-on: ubuntu-latest
  130. steps:
  131. - name: Get bootloader
  132. uses: actions/download-artifact@v2
  133. with:
  134. name: bootloader_f2
  135. path: bootloader
  136. - name: Get firmware
  137. uses: actions/download-artifact@v2
  138. with:
  139. name: firmware_f2
  140. path: firmware
  141. - name: Get firmware
  142. uses: actions/download-artifact@v2
  143. with:
  144. name: firmware_f2
  145. path: firmware
  146. - name: cp
  147. run: cp ./bootloader/bootloader.bin full_firmware_latest.bin
  148. - name: truncate
  149. run: truncate -s 32768 full_firmware_latest.bin
  150. - name: cat
  151. run: cat ./firmware/firmware.bin >> full_firmware_latest.bin
  152. - name: ls
  153. run: ls -R
  154. - name: Upload fullfirmware
  155. uses: burnett01/rsync-deployments@4.1
  156. with:
  157. switches: -avzp --delete
  158. path: full_firmware_latest.bin
  159. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}/"
  160. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  161. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  162. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}
  163. genpic:
  164. name: Generate pic
  165. needs: fullfirmware
  166. if: github.ref == 'refs/heads/master'
  167. runs-on: ubuntu-latest
  168. steps:
  169. - name: Checkout code
  170. uses: actions/checkout@v2
  171. with:
  172. fetch-depth: 0
  173. ref: master
  174. submodules: true
  175. - name: Echo debug
  176. run: echo ${{ github.ref }}
  177. - name: Get template and font
  178. run: |
  179. wget https://zhovner.com/tmp/latest-firmware-template.png
  180. wget https://zhovner.com/tmp/Born2bSportyV2.ttf
  181. - name: Set test env
  182. run: echo "NUMBER_OF_COMMITS=$(git rev-list --count HEAD)" >> $GITHUB_ENV
  183. - name: Test output NUMBER_OF_COMMITS
  184. run: echo $NUMBER_OF_COMMITS
  185. - name: Test output date
  186. run: |
  187. GET_DATE=$(date +"%b %d")
  188. PREP_DATE=$(echo "${GET_DATE^^}")
  189. echo "PREP_DATE=$PREP_DATE" >> $GITHUB_ENV
  190. - name: Test output PREP_DATE
  191. run: echo $PREP_DATE
  192. - name: Gen pic
  193. run: convert latest-firmware-template.png -font ./Born2bSportyV2.ttf -weight 700 -pointsize 140 -annotate +900+330 "$NUMBER_OF_COMMITS $PREP_DATE" out.png
  194. - name: Upload pic
  195. uses: burnett01/rsync-deployments@4.1
  196. with:
  197. switches: -avzp --delete
  198. path: out.png
  199. remote_path: "${{ secrets.RSYNC_DEPLOY_BASE_PATH }}/"
  200. remote_host: ${{ secrets.RSYNC_DEPLOY_HOST }}
  201. remote_user: ${{ secrets.RSYNC_DEPLOY_USER }}
  202. remote_key: ${{ secrets.RSYNC_DEPLOY_KEY }}