CI: Move bytecode report comparison logic to a script

This commit is contained in:
Kamil Śliwak 2023-06-19 14:19:06 +02:00
parent ea1327707b
commit 69ffcfc242
2 changed files with 59 additions and 22 deletions

View File

@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -euo pipefail
#------------------------------------------------------------------------------
# Compares bytecode reports generated by prepare_report.py/.js.
#
# ------------------------------------------------------------------------------
# This file is part of solidity.
#
# solidity is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# solidity is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with solidity. If not, see <http://www.gnu.org/licenses/>
#
# (c) 2023 solidity contributors.
#------------------------------------------------------------------------------
no_cli_platforms=(
emscripten
)
native_platforms=(
ubuntu2004-static
ubuntu
osx
windows
)
interfaces=(
cli
standard-json
)
report_files=()
for platform in "${no_cli_platforms[@]}"; do
report_files+=("bytecode-report-${platform}.txt")
done
for platform in "${native_platforms[@]}"; do
for interface in "${interfaces[@]}"; do
report_files+=("bytecode-report-${platform}-${interface}.txt")
done
done
echo "Reports to compare:"
printf -- "- %s\n" "${report_files[@]}"
if ! diff --brief --report-identical-files --from-file "${report_files[@]}"; then
diff --unified=0 --report-identical-files --from-file "${report_files[@]}" | head --lines 50
zip "all-bytecode-reports.zip" "${report_files[@]}"
exit 1
fi

View File

@ -1566,31 +1566,11 @@ jobs:
t_bytecode_compare: t_bytecode_compare:
<<: *base_ubuntu2204_small <<: *base_ubuntu2204_small
environment:
REPORT_FILES: |
bytecode-report-emscripten.txt
bytecode-report-ubuntu2004-static-standard-json.txt
bytecode-report-ubuntu2004-static-cli.txt
bytecode-report-ubuntu-standard-json.txt
bytecode-report-ubuntu-cli.txt
bytecode-report-osx-standard-json.txt
bytecode-report-osx-cli.txt
bytecode-report-windows-standard-json.txt
bytecode-report-windows-cli.txt
steps: steps:
- checkout
- attach_workspace: - attach_workspace:
at: . at: .
- run: - run: .circleci/compare_bytecode_reports.sh
name: Compare reports
command: diff --brief --report-identical-files --from-file $REPORT_FILES
- run:
name: Print diff
when: on_fail
command: diff --unified=0 --report-identical-files --from-file $REPORT_FILES | head --lines 50
- run:
name: Bundle reports into a single package
when: on_fail
command: zip all-bytecode-reports.zip $REPORT_FILES
- store_artifacts: - store_artifacts:
# NOTE: store_artifacts does not support the 'when' attribute. # NOTE: store_artifacts does not support the 'when' attribute.
# Fortunately when the artifact does not exist it just says "No artifact files found" and ignores it. # Fortunately when the artifact does not exist it just says "No artifact files found" and ignores it.