|
13 | 13 | - 'doc/**'
|
14 | 14 | - '**.md'
|
15 | 15 |
|
16 |
| - |
17 | 16 | jobs:
|
18 | 17 | build-firmware:
|
19 | 18 | runs-on: ubuntu-latest
|
20 | 19 | container:
|
21 | 20 | image: infinitime/infinitime-build
|
| 21 | + outputs: |
| 22 | + text_size: ${{ steps.output-sizes.outputs.text_size }} |
| 23 | + data_size: ${{ steps.output-sizes.outputs.data_size }} |
| 24 | + bss_size: ${{ steps.output-sizes.outputs.bss_size }} |
| 25 | + env: |
| 26 | + # InfiniTime sources are downloaded to the current directory. |
| 27 | + # Override SOURCES_DIR in build.sh |
| 28 | + SOURCES_DIR: . |
22 | 29 | steps:
|
23 | 30 | - name: Checkout source files
|
24 | 31 | uses: actions/checkout@v3
|
25 | 32 | with:
|
26 | 33 | submodules: recursive
|
27 | 34 | - name: Build
|
28 | 35 | shell: bash
|
29 |
| - env: |
30 |
| - SOURCES_DIR: . |
31 | 36 | run: /opt/build.sh all
|
| 37 | + - name: Output build size |
| 38 | + id: output-sizes |
| 39 | + run: | |
| 40 | + . /opt/build.sh |
| 41 | + .github/workflows/getSize.sh "$BUILD_DIR"/src/pinetime-app-*.out >> $GITHUB_OUTPUT |
32 | 42 | # Unzip the package because Upload Artifact will zip up the files
|
33 | 43 | - name: Unzip DFU package
|
34 | 44 | run: unzip ./build/output/pinetime-mcuboot-app-dfu-*.zip -d ./build/output/pinetime-mcuboot-app-dfu
|
|
87 | 97 | with:
|
88 | 98 | name: infinisim-${{ github.head_ref }}
|
89 | 99 | path: build_lv_sim/infinisim
|
| 100 | + |
| 101 | + get-base-ref-size: |
| 102 | + if: github.event_name == 'pull_request' |
| 103 | + runs-on: ubuntu-22.04 |
| 104 | + container: |
| 105 | + image: infinitime/infinitime-build |
| 106 | + outputs: |
| 107 | + text_size: ${{ steps.output-sizes.outputs.text_size }} |
| 108 | + data_size: ${{ steps.output-sizes.outputs.data_size }} |
| 109 | + bss_size: ${{ steps.output-sizes.outputs.bss_size }} |
| 110 | + env: |
| 111 | + # InfiniTime sources are downloaded to the current directory. |
| 112 | + # Override SOURCES_DIR in build.sh |
| 113 | + SOURCES_DIR: . |
| 114 | + steps: |
| 115 | + - name: Cache sources |
| 116 | + id: cache-sources |
| 117 | + uses: actions/cache@v3 |
| 118 | + with: |
| 119 | + path: . |
| 120 | + key: source-files-${{ github.event.pull_request.base.sha }} |
| 121 | + |
| 122 | + - if: ${{ steps.cache-sources.outputs.cache-hit != 'true' }} |
| 123 | + name: Checkout source files |
| 124 | + uses: actions/checkout@v3 |
| 125 | + with: |
| 126 | + ref: ${{ github.base_ref }} |
| 127 | + submodules: recursive |
| 128 | + |
| 129 | + - if: ${{ steps.cache-sources.outputs.cache-hit != 'true' }} |
| 130 | + name: Build |
| 131 | + shell: bash |
| 132 | + # Only pinetime-app target is needed, but post_build.sh fails |
| 133 | + run: /opt/build.sh all |
| 134 | + |
| 135 | + - name: Output build size |
| 136 | + id: output-sizes |
| 137 | + run: | |
| 138 | + . /opt/build.sh |
| 139 | + .github/workflows/getSize.sh "$BUILD_DIR"/src/pinetime-app-*.out >> $GITHUB_OUTPUT |
| 140 | +
|
| 141 | + leave-build-size-comment: |
| 142 | + if: github.event_name == 'pull_request' |
| 143 | + needs: [build-firmware, get-base-ref-size] |
| 144 | + runs-on: ubuntu-latest |
| 145 | + steps: |
| 146 | + - name: Compare build size |
| 147 | + id: output-sizes-diff |
| 148 | + run: | |
| 149 | + TEXT_SIZE=${{ needs.build-firmware.outputs.text_size }} |
| 150 | + DATA_SIZE=${{ needs.build-firmware.outputs.data_size }} |
| 151 | + BSS_SIZE=${{ needs.build-firmware.outputs.bss_size }} |
| 152 | +
|
| 153 | + echo "text_size=$TEXT_SIZE" >> $GITHUB_OUTPUT |
| 154 | + echo "data_size=$DATA_SIZE" >> $GITHUB_OUTPUT |
| 155 | + echo "bss_size=$BSS_SIZE" >> $GITHUB_OUTPUT |
| 156 | +
|
| 157 | + TEXT_SIZE_BASE=${{ needs.get-base-ref-size.outputs.text_size }} |
| 158 | + DATA_SIZE_BASE=${{ needs.get-base-ref-size.outputs.data_size }} |
| 159 | + BSS_SIZE_BASE=${{ needs.get-base-ref-size.outputs.bss_size }} |
| 160 | +
|
| 161 | + TEXT_SIZE_DIFF=$((TEXT_SIZE - TEXT_SIZE_BASE)) |
| 162 | + DATA_SIZE_DIFF=$((DATA_SIZE - DATA_SIZE_BASE)) |
| 163 | + BSS_SIZE_DIFF=$((BSS_SIZE - BSS_SIZE_BASE)) |
| 164 | +
|
| 165 | + echo "text_diff=$TEXT_SIZE_DIFF" >> $GITHUB_OUTPUT |
| 166 | + echo "data_diff=$DATA_SIZE_DIFF" >> $GITHUB_OUTPUT |
| 167 | + echo "bss_diff=$BSS_SIZE_DIFF" >> $GITHUB_OUTPUT |
| 168 | +
|
| 169 | + - name: Find Comment |
| 170 | + uses: peter-evans/find-comment@v2 |
| 171 | + id: build-size-comment |
| 172 | + with: |
| 173 | + issue-number: ${{ github.event.pull_request.number }} |
| 174 | + comment-author: 'github-actions[bot]' |
| 175 | + body-includes: Build size and comparison to |
| 176 | + |
| 177 | + - name: Create or update comment |
| 178 | + uses: peter-evans/create-or-update-comment@v2 |
| 179 | + with: |
| 180 | + comment-id: ${{ steps.build-size-comment.outputs.comment-id }} |
| 181 | + issue-number: ${{ github.event.pull_request.number }} |
| 182 | + body: | |
| 183 | + Build size and comparison to ${{ github.base_ref }}: |
| 184 | + | Section | Size | Difference | |
| 185 | + | ------- | ---- | ---------- | |
| 186 | + | text | ${{ needs.build-firmware.outputs.text_size }}B | ${{ steps.output-sizes-diff.outputs.text_diff }}B | |
| 187 | + | data | ${{ needs.build-firmware.outputs.data_size }}B | ${{ steps.output-sizes-diff.outputs.data_diff }}B | |
| 188 | + | bss | ${{ needs.build-firmware.outputs.bss_size }}B | ${{ steps.output-sizes-diff.outputs.bss_diff }}B | |
| 189 | + edit-mode: replace |
0 commit comments