Skip to content

Commit 147232e

Browse files
authored
Integrate periphery: add fancier reporting (#15984)
2 parents 7916cc4 + 92b4934 commit 147232e

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

.buildkite/commands/run-periphery.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ tar -xf build-products.tar
1212

1313
### Run the Tests
1414

15-
echo '+++ :periphery: Detecting unused code'
15+
PERIPHERY_OUTPUT_FILE="periphery-errors.txt"
16+
17+
echo '+++ :zombie: Detecting unused code'
1618
set +e
1719
# This is the script in the root.
18-
./Scripts/Periphery/setup-and-run-periphery.sh --strict --quiet --skip-build --index-store-path 'DerivedData/Index.noindex/DataStore/'
20+
./Scripts/Periphery/setup-and-run-periphery.sh \
21+
--strict --quiet --skip-build --index-store-path 'DerivedData/Index.noindex/DataStore/' \
22+
--write-results "$PERIPHERY_OUTPUT_FILE"
1923
TESTS_EXIT_STATUS=$?
2024
set -e
2125

@@ -28,8 +32,12 @@ if [[ "$TESTS_EXIT_STATUS" -ne 0 ]]; then
2832
echo 'If you think there is a false positive violation, please check the known issues of Periphery at https://github.com/peripheryapp/periphery/issues.'
2933
echo 'If you think a violation is valid but it should be surpressed for any reason, please apply the `// periphery: ignore - {your-reason-here}` comment.'
3034
echo ''
35+
# Add the periphery errors as a Buildkite annotation
36+
(echo "### Periphery found unused code"; echo ''; echo '```'; cat "$PERIPHERY_OUTPUT_FILE"; echo ''; echo '```') \
37+
| buildkite-agent annotate --context periphery --style error
3138
else
3239
echo '😊 No unused code found.'
40+
buildkite-agent annotate --context periphery --style success 'No unused code found by Periphery :tada:'
3341
fi
3442

3543
echo '--- 🚦 Report Exit code'

Scripts/Periphery/setup-and-run-periphery.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ PERIPHERY_PATH="${PERIPHERY_FOLDER_PATH}/periphery"
1212
version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }
1313

1414
# Function to update and run Periphery
15-
update_and_run() {
16-
echo "Downloading the latest version..."
15+
update_periphery() {
16+
echo "Downloading version $PERIPHERY_VERSION..."
1717
# Download the zip file
1818
curl -L "https://github.com/peripheryapp/periphery/releases/download/${PERIPHERY_VERSION}/periphery-${PERIPHERY_VERSION}.zip" -o "periphery.zip"
1919

@@ -29,9 +29,7 @@ update_and_run() {
2929
# Make sure the executable is executable
3030
chmod +x "$PERIPHERY_PATH"
3131

32-
echo "Download and setup complete. Running periphery scan..."
33-
# Run periphery scan with additional arguments
34-
$PERIPHERY_PATH scan "$@"
32+
echo "Download and setup complete."
3533
}
3634

3735
# Check if the executable exists and is executable
@@ -43,12 +41,15 @@ if [ -x "$PERIPHERY_PATH" ]; then
4341
# Compare the current version with the desired version
4442
if version_gt "$PERIPHERY_VERSION" "$CURRENT_VERSION"; then
4543
echo "Current version ($CURRENT_VERSION) is older than $PERIPHERY_VERSION. Updating..."
46-
update_and_run "$@"
44+
update_periphery
4745
else
48-
echo "Current version ($CURRENT_VERSION) is up-to-date. Running periphery scan..."
49-
$PERIPHERY_PATH scan "$@"
46+
echo "Current version ($CURRENT_VERSION) is up-to-date."
5047
fi
5148
else
5249
echo "Executable not found. Downloading..."
53-
update_and_run "$@"
50+
update_periphery
5451
fi
52+
53+
echo "Running periphery scan..."
54+
# Run periphery scan with additional arguments
55+
"$PERIPHERY_PATH" scan --disable-update-check --relative-results "$@"

0 commit comments

Comments
 (0)