You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 lines
4.9 KiB

  1. name: Test Build
  2. on:
  3. pull_request:
  4. jobs:
  5. build:
  6. name: Test ${{ matrix.arch }}
  7. runs-on: ubuntu-latest
  8. strategy:
  9. fail-fast: false
  10. matrix:
  11. include:
  12. - arch: arc_archs
  13. target: archs38-generic
  14. runtime_test: false
  15. - arch: arm_cortex-a9_vfpv3-d16
  16. target: mvebu-cortexa9
  17. runtime_test: false
  18. - arch: mips_24kc
  19. target: ath79-generic
  20. runtime_test: false
  21. - arch: mipsel_24kc
  22. target: mt7621
  23. runtime_test: false
  24. - arch: powerpc_464fp
  25. target: apm821xx-nand
  26. runtime_test: false
  27. - arch: powerpc_8540
  28. target: mpc85xx-p1010
  29. runtime_test: false
  30. - arch: aarch64_cortex-a53
  31. target: mvebu-cortexa53
  32. runtime_test: true
  33. - arch: arm_cortex-a15_neon-vfpv4
  34. target: armvirt-32
  35. runtime_test: true
  36. - arch: i386_pentium-mmx
  37. target: x86-geode
  38. runtime_test: true
  39. - arch: x86_64
  40. target: x86-64
  41. runtime_test: true
  42. steps:
  43. - uses: actions/checkout@v2
  44. with:
  45. fetch-depth: 0
  46. - name: Determine branch name
  47. run: |
  48. BRANCH="${GITHUB_BASE_REF#refs/heads/}"
  49. echo "Building for $BRANCH"
  50. echo "BRANCH=$BRANCH" >> $GITHUB_ENV
  51. - name: Determine changed packages
  52. run: |
  53. # only detect packages with changes
  54. PKG_ROOTS=$(find . -name Makefile | \
  55. grep -v ".*/src/Makefile" | \
  56. sed -e 's@./\(.*\)/Makefile@\1/@')
  57. CHANGES=$(git diff --diff-filter=d --name-only origin/$BRANCH)
  58. for ROOT in $PKG_ROOTS; do
  59. for CHANGE in $CHANGES; do
  60. if [[ "$CHANGE" == "$ROOT"* ]]; then
  61. PACKAGES+=$(echo "$ROOT" | sed -e 's@.*/\(.*\)/@\1 @')
  62. break
  63. fi
  64. done
  65. done
  66. # fallback to test packages if nothing explicitly changes this is
  67. # should run if other mechanics in packages.git changed
  68. PACKAGES="${PACKAGES:-vim attendedsysupgrade-common bmon}"
  69. echo "Building $PACKAGES"
  70. echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
  71. - name: Build
  72. uses: openwrt/gh-action-sdk@v3
  73. env:
  74. ARCH: ${{ matrix.arch }}-${{ env.BRANCH }}
  75. FEEDNAME: packages_ci
  76. - name: Move created packages to project dir
  77. run: cp bin/packages/${{ matrix.arch }}/packages_ci/*.ipk . || true
  78. - name: Collect metadata
  79. run: |
  80. MERGE_ID=$(git rev-parse --short HEAD)
  81. echo "MERGE_ID=$MERGE_ID" >> $GITHUB_ENV
  82. echo "BASE_ID=$(git rev-parse --short HEAD^1)" >> $GITHUB_ENV
  83. echo "HEAD_ID=$(git rev-parse --short HEAD^2)" >> $GITHUB_ENV
  84. PRNUMBER=${GITHUB_REF_NAME%/merge}
  85. echo "PRNUMBER=$PRNUMBER" >> $GITHUB_ENV
  86. echo "ARCHIVE_NAME=${{matrix.arch}}-PR$PRNUMBER-$MERGE_ID" >> $GITHUB_ENV
  87. - name: Generate metadata
  88. run: |
  89. cat << _EOF_ > PKG-INFO
  90. Metadata-Version: 2.1
  91. Name: ${{env.ARCHIVE_NAME}}
  92. Version: $BRANCH
  93. Author: $GITHUB_ACTOR
  94. Home-page: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/pull/$PRNUMBER
  95. Download-URL: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
  96. Summary: $PACKAGES
  97. Platform: ${{ matrix.arch }}
  98. Packages for OpenWrt $BRANCH running on ${{matrix.arch}}, built from PR $PRNUMBER
  99. at commit $HEAD_ID, against $BRANCH at commit $BASE_ID, with merge SHA $MERGE_ID.
  100. Modified packages:
  101. _EOF_
  102. for p in $PACKAGES
  103. do
  104. echo " "$p >> PKG-INFO
  105. done
  106. echo >> PKG-INFO
  107. echo Full file listing: >> PKG-INFO
  108. ls -al *.ipk >> PKG-INFO || true
  109. cat PKG-INFO
  110. - name: Store packages
  111. uses: actions/upload-artifact@v2
  112. with:
  113. name: ${{env.ARCHIVE_NAME}}-packages
  114. path: |
  115. *.ipk
  116. PKG-INFO
  117. - name: Store logs
  118. uses: actions/upload-artifact@v2
  119. with:
  120. name: ${{env.ARCHIVE_NAME}}-logs
  121. path: |
  122. logs/
  123. PKG-INFO
  124. - name: Remove logs
  125. run: sudo rm -rf logs/ || true
  126. - name: Register QEMU
  127. if: ${{ matrix.runtime_test }}
  128. run: |
  129. sudo docker run --rm --privileged aptman/qus -s -- -p
  130. - name: Build Docker container
  131. if: ${{ matrix.runtime_test }}
  132. run: |
  133. docker build -t test-container --build-arg ARCH .github/workflows/
  134. env:
  135. ARCH: ${{ matrix.arch }}-${{ env.BRANCH }}
  136. - name: Test via Docker container
  137. if: ${{ matrix.runtime_test }}
  138. run: |
  139. docker run --rm -v $GITHUB_WORKSPACE:/ci test-container