Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👷 (ci): Use sticky message md file for compare head/base #1437

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 18 additions & 54 deletions .github/actions/compare_base_head_changes/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,63 +40,27 @@ runs:
shell: bash
run: ${{ github.action_path }}/get_diffs.sh ${{ inputs.base_dir }} ${{ inputs.head_dir }}

- name: Create stick message
id: create_sticky_message
shell: bash
run: ruby ${{ github.action_path }}/generate_sticky_note.rb
env:
RUNNER_HOME: ${{ env.RUNNER_HOME }}
ENABLE_LOG_DEBUG: ${{ inputs.enable_log_debug }}
ARM_GNU_TOOLCHAIN_VERSION: ${{ env.TOOLCHAIN_VERSION }}
BASE_REF: ${{ env.BASE_REF }}
HEAD_REF: ${{ env.HEAD_REF }}
BASE_SHA: ${{ env.BASE_SHA }}
HEAD_SHA: ${{ env.HEAD_SHA }}
BASE_MBED_VERSION: ${{ env.BASE_MBED_VERSION }}
HEAD_MBED_VERSION: ${{ env.HEAD_MBED_VERSION }}
BASE_CXX_STANDARD: ${{ env.BASE_CXX_STANDARD }}
HEAD_CXX_STANDARD: ${{ env.HEAD_CXX_STANDARD }}

- name: Publish differences
uses: marocchino/sticky-pull-request-comment@v2
with:
hide_and_recreate: true
hide_classify: "OUTDATED"
header: compare_base_head_changes-${{ inputs.comment_header }}
message: |
# :chart_with_upwards_trend: Changes Impact Analysis Report

## :pushpin: Info

- toolchain: `${{ env.TOOLCHAIN_VERSION }}`
- enable_log_debug: `${{ inputs.enable_log_debug }}`

| | `base` | `head` |
|--------|--------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
| branch | [`${{ env.BASE_REF}}`](https://github.com/leka/LekaOS/tree/${{ env.BASE_REF}}) | [`${{ env.HEAD_REF }}`](https://github.com/leka/LekaOS/tree/${{ env.HEAD_REF }}) |
| sha | ${{ env.BASE_SHA }} | ${{ env.HEAD_SHA }} |
| mbed | `${{ env.BASE_MBED_VERSION }}` | `${{ env.HEAD_MBED_VERSION }}` |
| `-std` | `${{ env.BASE_CXX_STANDARD }}` | `${{ env.HEAD_CXX_STANDARD }}` |

## :robot: Firmware impact analysis

${{ env.FIRMWARE_STATISTICS_OUTPUT }}

<details>
<summary>Click to show memory sections</summary>

```
| - | Hex | Bytes | KiB |
|------------|---------:|----------:|-----:|
| Flash | 0x200000 | 2 097 152 | 2048 |
| SRAM | 0x80000 | 524 288 | 512 |
| Bootloader | 0x40000 | 262 144 | 256 |
| Header | 0x1000 | 4 096 | 4 |
| OS | 0x17E000 | 1 564 672 | 1528 |
| Tail | 0x1000 | 4 096 | 4 |
| Scratch | 0x40000 | 262 144 | 256 |
```

</details>

## :microscope: Detailed impact analysis

<details>
<summary>Click to show detailed analysis for all targets</summary>

- :heavy_check_mark: - existing target
- :sparkles: - new target
- :coffin: - deleted target
- :white_check_mark: - files are the same
- :x: - files are different

${{ env.STATUS_DIFF_OUTPUT }}

## :world_map: Map files diff output

${{ env.MAP_DIFF_OUTPUT }}

</details>
path: ${{ env.RUNNER_HOME }}/STICKY_MESSAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,40 @@ HEAD_DIR=$2
source ./.github/actions/compare_base_head_changes/utils.sh
source ./.github/actions/compare_base_head_changes/get_all_targets.sh $BASE_DIR $HEAD_DIR

echo 'STATUS_DIFF_OUTPUT<<EOF_STATUS_DIFF_OUTPUT' >> $GITHUB_ENV
STATUS_DIFF_OUTPUT="$RUNNER_HOME/STATUS_DIFF_OUTPUT.md"
touch $STATUS_DIFF_OUTPUT

echo "| Target | Status | .bin | .map | Total Flash (base/head) | Total Flash Δ | Static RAM (base/head) | Static RAM Δ |" >> $GITHUB_ENV
echo "|-------|:------:|:------:|:------:|:------:|:------:|:------:|:------:|" >> $GITHUB_ENV
echo "| Target | Status | .bin | .map | Total Flash (base/head) | Total Flash Δ | Static RAM (base/head) | Static RAM Δ |" >> $STATUS_DIFF_OUTPUT
echo "|-------|:------:|:------:|:------:|:------:|:------:|:------:|:------:|" >> $STATUS_DIFF_OUTPUT

for target in "${all_targets[@]}"; do
target_name=$target

echo -n "| $target_name " >> $GITHUB_ENV
echo -n "| $target_name " >> $STATUS_DIFF_OUTPUT

if [[ " ${added_targets[*]} " =~ " $target " ]]; then

echo -n "| :sparkles: | - | - " >> $GITHUB_ENV
echo -n "| :sparkles: | - | - " >> $STATUS_DIFF_OUTPUT

createSizeTextFile $HEAD_DIR $target_name

head_flash_with_percentage="$(getUsedFlashSizeWithPercentage $HEAD_DIR $target_name)"
head_ram_with_percentage="$(getUsedRamSizeWithPercentage $HEAD_DIR $target_name)"

echo -n "| $head_flash_with_percentage | - | $head_ram_with_percentage | - |\n" >> $GITHUB_ENV
echo -n "| $head_flash_with_percentage | - | $head_ram_with_percentage | - |\n" >> $STATUS_DIFF_OUTPUT

elif [[ " ${deleted_targets[*]} " =~ " $target " ]]; then

echo -n "| :coffin: | - | - | - | - | - | - |\n" >> $GITHUB_ENV
echo -n "| :coffin: | - | - | - | - | - | - |\n" >> $STATUS_DIFF_OUTPUT

else

echo -n "| :heavy_check_mark: " >> $GITHUB_ENV
echo -n "| :heavy_check_mark: " >> $STATUS_DIFF_OUTPUT

if ! output=$(diff $BASE_DIR/$target_name.bin $HEAD_DIR/$target_name.bin 2>/dev/null); then
echo -n "| :x: " >> $GITHUB_ENV
echo -n "| :x: " >> $STATUS_DIFF_OUTPUT
else
echo -n "| :white_check_mark: " >> $GITHUB_ENV
echo -n "| :white_check_mark: " >> $STATUS_DIFF_OUTPUT
fi

createMapTextFile $BASE_DIR $target_name
Expand All @@ -53,9 +54,9 @@ for target in "${all_targets[@]}"; do


if ! output=$(diff $BASE_DIR/$target_name-map.txt $HEAD_DIR/$target_name-map.txt 2>/dev/null); then
echo -n "| :x: " >> $GITHUB_ENV
echo -n "| :x: " >> $STATUS_DIFF_OUTPUT
else
echo -n "| :white_check_mark: " >> $GITHUB_ENV
echo -n "| :white_check_mark: " >> $STATUS_DIFF_OUTPUT
fi

base_flash_with_percentage="$(getUsedFlashSizeWithPercentage $BASE_DIR $target_name)"
Expand Down Expand Up @@ -100,11 +101,9 @@ for target in "${all_targets[@]}"; do
output_ram_delta="ø"
fi

echo -n "| $output_flash | $output_flash_delta | $output_ram | $output_ram_delta " >> $GITHUB_ENV
echo -n "| $output_flash | $output_flash_delta | $output_ram | $output_ram_delta " >> $STATUS_DIFF_OUTPUT

echo -n "|\n" >> $GITHUB_ENV
echo -n "|\n" >> $STATUS_DIFF_OUTPUT
fi

done

echo 'EOF_STATUS_DIFF_OUTPUT' >> $GITHUB_ENV
15 changes: 7 additions & 8 deletions .github/actions/compare_base_head_changes/generate_statistics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ HEAD_DIR=$2

source ./.github/actions/compare_base_head_changes/utils.sh

FIRMWARE_STATISTICS_OUTPUT="$RUNNER_HOME/FIRMWARE_STATISTICS_OUTPUT.md"
touch $FIRMWARE_STATISTICS_OUTPUT

#
# MARK: - bootloader statistics
#
Expand Down Expand Up @@ -166,12 +169,8 @@ fi

echo "Creating markdown output"

echo 'FIRMWARE_STATISTICS_OUTPUT<<EOF_FIRMWARE_STATISTICS_OUTPUT' >> $GITHUB_ENV

echo -n "| Target | Flash Used (base/head) | Flash Used Δ | Flash Available (base/head) | Static RAM (base/head) | Static RAM Δ |\n" >> $GITHUB_ENV
echo -n "|--------|:----------------------:|:-----------:|:---------------------------:|:----------------------:|:------------:|\n" >> $GITHUB_ENV

echo -n "| bootloader | $OUTPUT_BOOTLOADER_FLASH_USED | $OUTPUT_BOOTLOADER_FLASH_USED_DELTA | $OUTPUT_BOOTLOADER_FLASH_AVAILABLE | $OUTPUT_BOOTLOADER_RAM | $OUTPUT_BOOTLOADER_RAM_DELTA |\n" >> $GITHUB_ENV
echo -n "| os | $OUTPUT_LEKA_OS_FLASH_USED | $OUTPUT_LEKA_OS_FLASH_USED_DELTA | $OUTPUT_LEKA_OS_FLASH_AVAILABLE | $OUTPUT_LEKA_OS_RAM | $OUTPUT_LEKA_OS_RAM_DELTA |\n" >> $GITHUB_ENV
echo -n "| Target | Flash Used (base/head) | Flash Used Δ | Flash Available (base/head) | Static RAM (base/head) | Static RAM Δ |\n" >> $FIRMWARE_STATISTICS_OUTPUT
echo -n "|--------|:----------------------:|:-----------:|:---------------------------:|:----------------------:|:------------:|\n" >> $FIRMWARE_STATISTICS_OUTPUT

echo 'EOF_FIRMWARE_STATISTICS_OUTPUT' >> $GITHUB_ENV
echo -n "| bootloader | $OUTPUT_BOOTLOADER_FLASH_USED | $OUTPUT_BOOTLOADER_FLASH_USED_DELTA | $OUTPUT_BOOTLOADER_FLASH_AVAILABLE | $OUTPUT_BOOTLOADER_RAM | $OUTPUT_BOOTLOADER_RAM_DELTA |\n" >> $FIRMWARE_STATISTICS_OUTPUT
echo -n "| os | $OUTPUT_LEKA_OS_FLASH_USED | $OUTPUT_LEKA_OS_FLASH_USED_DELTA | $OUTPUT_LEKA_OS_FLASH_AVAILABLE | $OUTPUT_LEKA_OS_RAM | $OUTPUT_LEKA_OS_RAM_DELTA |\n" >> $FIRMWARE_STATISTICS_OUTPUT
77 changes: 77 additions & 0 deletions .github/actions/compare_base_head_changes/generate_sticky_note.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env ruby

# Leka - LekaOS
# Copyright 2023 APF France handicap
# SPDX-License-Identifier: Apache-2.0

FIRMWARE_STATISTICS_OUTPUT_PATH="#{ENV["RUNNER_HOME"]}/FIRMWARE_STATISTICS_OUTPUT.md"
STATUS_DIFF_OUTPUT_PATH="#{ENV["RUNNER_HOME"]}/STATUS_DIFF_OUTPUT.md"
MAP_DIFF_OUTPUT_PATH="#{ENV["RUNNER_HOME"]}/MAP_DIFF_OUTPUT.md"

FIRMWARE_STATISTICS_OUTPUT=File.read(FIRMWARE_STATISTICS_OUTPUT_PATH)
STATUS_DIFF_OUTPUT=File.read(STATUS_DIFF_OUTPUT_PATH)
MAP_DIFF_OUTPUT=File.read(MAP_DIFF_OUTPUT_PATH)

sticky_message = <<-EOF

# :chart_with_upwards_trend: Changes Impact Analysis Report

## :pushpin: Info

- toolchain: `#{ENV["ARM_GNU_TOOLCHAIN_VERSION"]}`
- enable_log_debug: `#{ENV["ENABLE_LOG_DEBUG"]}`

| | `base` | `head` |
|-----------|----------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
| branch | [`#{ENV["BASE_REF"]}`](https://github.com/leka/LekaOS/tree/#{ENV["BASE_REF"]}) | [`#{ENV["HEAD_REF"]}`](https://github.com/leka/LekaOS/tree/#{ENV["HEAD_REF"]}) |
| sha | #{ENV["BASE_SHA"]} | #{ENV["HEAD_SHA"]} |
| mbed | `#{ENV["BASE_MBED_VERSION"]}` | `#{ENV["HEAD_MBED_VERSION"]}` |
| `-std` | `#{ENV["BASE_CXX_STANDARD"]}` | `#{ENV["HEAD_CXX_STANDARD"]}` |

## :robot: Firmware impact analysis

#{FIRMWARE_STATISTICS_OUTPUT}

<details>
<summary>Click to show memory sections</summary>

```
| - | Hex | Bytes | KiB |
|------------|---------:|----------:|-----:|
| Flash | 0x200000 | 2 097 152 | 2048 |
| SRAM | 0x80000 | 524 288 | 512 |
| Bootloader | 0x40000 | 262 144 | 256 |
| Header | 0x1000 | 4 096 | 4 |
| OS | 0x17E000 | 1 564 672 | 1528 |
| Tail | 0x1000 | 4 096 | 4 |
| Scratch | 0x40000 | 262 144 | 256 |
```

</details>

## :microscope: Detailed impact analysis

<details>
<summary>Click to show detailed analysis for all targets</summary>

- :heavy_check_mark: - existing target
- :sparkles: - new target
- :coffin: - deleted target
- :white_check_mark: - files are the same
- :x: - files are different

#{STATUS_DIFF_OUTPUT}

## :world_map: Map files diff output

#{MAP_DIFF_OUTPUT}

</details>

EOF

puts sticky_message

STICKY_MESSAGE_PATH = "#{ENV["RUNNER_HOME"]}/STICKY_MESSAGE.md"

File.write(STICKY_MESSAGE_PATH, "#{sticky_message}", mode: 'a')
59 changes: 29 additions & 30 deletions .github/actions/compare_base_head_changes/get_diffs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Leka - LekaOS
# Copyright 2022 APF France handicap
# Copyright 2021 APF France handicap
# SPDX-License-Identifier: Apache-2.0

shopt -s xpg_echo
Expand All @@ -10,9 +10,10 @@ HEAD_DIR=$2
source ./.github/actions/compare_base_head_changes/utils.sh
source ./.github/actions/compare_base_head_changes/get_all_targets.sh

no_map_diff=true
MAP_DIFF_OUTPUT="$RUNNER_HOME/MAP_DIFF_OUTPUT.md"
touch $MAP_DIFF_OUTPUT

echo 'MAP_DIFF_OUTPUT<<EOF_MAP_DIFF_OUTPUT' >> $GITHUB_ENV
no_map_diff=true

for target in "${all_targets[@]}"; do
target_name=$target
Expand All @@ -30,21 +31,21 @@ target_name=$target
echo $diff_map_output
echo $diff_size_output

echo "<details>" >> $GITHUB_ENV
echo "<summary><b><code>$target_name</code></b> (click to expand)</summary>" >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo "<details>" >> $MAP_DIFF_OUTPUT
echo "<summary><b><code>$target_name</code></b> (click to expand)</summary>" >> $MAP_DIFF_OUTPUT
echo "" >> $MAP_DIFF_OUTPUT

echo "\`\`\`diff" >> $GITHUB_ENV
echo "$diff_map_output" >> $GITHUB_ENV
echo "\`\`\`" >> $GITHUB_ENV
echo "\`\`\`diff" >> $MAP_DIFF_OUTPUT
echo "$diff_map_output" >> $MAP_DIFF_OUTPUT
echo "\`\`\`" >> $MAP_DIFF_OUTPUT

echo "\`\`\`diff" >> $GITHUB_ENV
echo "$diff_size_output" >> $GITHUB_ENV
echo "\`\`\`" >> $GITHUB_ENV
echo "\`\`\`diff" >> $MAP_DIFF_OUTPUT
echo "$diff_size_output" >> $MAP_DIFF_OUTPUT
echo "\`\`\`" >> $MAP_DIFF_OUTPUT

echo "" >> $GITHUB_ENV
echo "</details>" >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo "" >> $MAP_DIFF_OUTPUT
echo "</details>" >> $MAP_DIFF_OUTPUT
echo "" >> $MAP_DIFF_OUTPUT

no_map_diff=false
fi
Expand All @@ -56,21 +57,21 @@ target_name=$target
map_output=$(cat $HEAD_DIR/$target_name-map.txt)
size_output=$(cat $HEAD_DIR/$target_name-code_size.txt)

echo "<details>" >> $GITHUB_ENV
echo "<summary><b><code>$target_name</code></b> (click to expand)</summary>" >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo "<details>" >> $MAP_DIFF_OUTPUT
echo "<summary><b><code>$target_name</code></b> (click to expand)</summary>" >> $MAP_DIFF_OUTPUT
echo "" >> $MAP_DIFF_OUTPUT

echo "\`\`\`" >> $GITHUB_ENV
echo "$map_output" >> $GITHUB_ENV
echo "\`\`\`" >> $GITHUB_ENV
echo "\`\`\`" >> $MAP_DIFF_OUTPUT
echo "$map_output" >> $MAP_DIFF_OUTPUT
echo "\`\`\`" >> $MAP_DIFF_OUTPUT

echo "\`\`\`" >> $GITHUB_ENV
echo "$size_output" >> $GITHUB_ENV
echo "\`\`\`" >> $GITHUB_ENV
echo "\`\`\`" >> $MAP_DIFF_OUTPUT
echo "$size_output" >> $MAP_DIFF_OUTPUT
echo "\`\`\`" >> $MAP_DIFF_OUTPUT

echo "" >> $GITHUB_ENV
echo "</details>" >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo "" >> $MAP_DIFF_OUTPUT
echo "</details>" >> $MAP_DIFF_OUTPUT
echo "" >> $MAP_DIFF_OUTPUT

no_map_diff=false

Expand All @@ -79,7 +80,5 @@ target_name=$target
done

if $no_map_diff; then
echo "No differenes where found in map files." >> $GITHUB_ENV
echo "No differenes where found in map files." >> $MAP_DIFF_OUTPUT
fi

echo 'EOF_MAP_DIFF_OUTPUT' >> $GITHUB_ENV
Loading