Skip to content
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
12 changes: 10 additions & 2 deletions .buildkite/commands/run-periphery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ tar -xf build-products.tar

### Run the Tests

echo '+++ :periphery: Detecting unused code'
PERIPHERY_OUTPUT_FILE="periphery-errors.txt"

echo '+++ :zombie: Detecting unused code'
set +e
# This is the script in the root.
./Scripts/Periphery/setup-and-run-periphery.sh --strict --quiet --skip-build --index-store-path 'DerivedData/Index.noindex/DataStore/'
./Scripts/Periphery/setup-and-run-periphery.sh \
--strict --quiet --skip-build --index-store-path 'DerivedData/Index.noindex/DataStore/' \
--write-results "$PERIPHERY_OUTPUT_FILE"
TESTS_EXIT_STATUS=$?
set -e

Expand All @@ -28,8 +32,12 @@ if [[ "$TESTS_EXIT_STATUS" -ne 0 ]]; then
echo 'If you think there is a false positive violation, please check the known issues of Periphery at https://github.com/peripheryapp/periphery/issues.'
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.'
echo ''
# Add the periphery errors as a Buildkite annotation
(echo "### Periphery found unused code"; echo ''; echo '```'; cat "$PERIPHERY_OUTPUT_FILE"; echo ''; echo '```') \
| buildkite-agent annotate --context periphery --style error
else
echo '😊 No unused code found.'
buildkite-agent annotate --context periphery --style success 'No unused code found by Periphery :tada:'
fi

echo '--- 🚦 Report Exit code'
Expand Down
19 changes: 10 additions & 9 deletions Scripts/Periphery/setup-and-run-periphery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ PERIPHERY_PATH="${PERIPHERY_FOLDER_PATH}/periphery"
version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }

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

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

echo "Download and setup complete. Running periphery scan..."
# Run periphery scan with additional arguments
$PERIPHERY_PATH scan "$@"
echo "Download and setup complete."
}

# Check if the executable exists and is executable
Expand All @@ -43,12 +41,15 @@ if [ -x "$PERIPHERY_PATH" ]; then
# Compare the current version with the desired version
if version_gt "$PERIPHERY_VERSION" "$CURRENT_VERSION"; then
echo "Current version ($CURRENT_VERSION) is older than $PERIPHERY_VERSION. Updating..."
update_and_run "$@"
update_periphery
else
echo "Current version ($CURRENT_VERSION) is up-to-date. Running periphery scan..."
$PERIPHERY_PATH scan "$@"
echo "Current version ($CURRENT_VERSION) is up-to-date."
fi
else
echo "Executable not found. Downloading..."
update_and_run "$@"
update_periphery
fi

echo "Running periphery scan..."
# Run periphery scan with additional arguments
"$PERIPHERY_PATH" scan --disable-update-check --relative-results "$@"