mirror of
https://github.com/apple/swift-nio.git
synced 2026-05-20 20:30:36 +00:00
### Motivation * When threshold files don't exist yet, `thresholds update` creates new untracked files. `git diff HEAD` only shows changes to tracked files, so newly created threshold files were silently omitted from the diff. ### Modifications * Run `git add --intent-to-add .` before `git diff HEAD` so that untracked files are registered in the index and appear in the diff output without staging their contents. ### Result * The diff output now includes newly created threshold files.
61 lines
2.1 KiB
Bash
Executable File
61 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
##===----------------------------------------------------------------------===##
|
|
##
|
|
## This source file is part of the SwiftNIO open source project
|
|
##
|
|
## Copyright (c) 2025 Apple Inc. and the SwiftNIO project authors
|
|
## Licensed under Apache License v2.0
|
|
##
|
|
## See LICENSE.txt for license information
|
|
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
|
##
|
|
## SPDX-License-Identifier: Apache-2.0
|
|
##
|
|
##===----------------------------------------------------------------------===##
|
|
|
|
set -uo pipefail
|
|
|
|
log() { printf -- "** %s\n" "$*" >&2; }
|
|
error() { printf -- "** ERROR: %s\n" "$*" >&2; }
|
|
fatal() { error "$@"; exit 1; }
|
|
|
|
# Parameter environment variables
|
|
if [ -z "$SWIFT_VERSION" ]; then
|
|
fatal "SWIFT_VERSION must be specified."
|
|
fi
|
|
|
|
benchmark_package_path="${BENCHMARK_PACKAGE_PATH:-"."}"
|
|
swift_version="${SWIFT_VERSION:-""}"
|
|
|
|
# Any parameters to the script are passed along to SwiftPM
|
|
swift_package_arguments=("$@")
|
|
|
|
#"swift package --package-path ${{ inputs.benchmark_package_path }} ${{ inputs.swift_package_arguments }} benchmark baseline check --check-absolute-path ${{ inputs.benchmark_package_path }}/Thresholds/${SWIFT_VERSION}/"
|
|
swift package --package-path "$benchmark_package_path" "${swift_package_arguments[@]}" benchmark thresholds check --format metricP90AbsoluteThresholds --path "${benchmark_package_path}/Thresholds/${swift_version}/"
|
|
rc="$?"
|
|
|
|
# Benchmarks are unchanged, nothing to recalculate
|
|
if [[ "$rc" == 0 ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
# Non-zero exit from 'thresholds check' means thresholds regressed or a build
|
|
# error occurred. Try 'thresholds update' to distinguish: if it also fails, it
|
|
# was a build error; if it succeeds, thresholds were updated.
|
|
log "Recalculating thresholds..."
|
|
|
|
swift package --package-path "$benchmark_package_path" "${swift_package_arguments[@]}" benchmark thresholds update --format metricP90AbsoluteThresholds --path "${benchmark_package_path}/Thresholds/${swift_version}/"
|
|
update_rc="$?"
|
|
|
|
if [[ "$update_rc" != 0 ]]; then
|
|
error "Benchmark failed to run due to build error."
|
|
exit $update_rc
|
|
fi
|
|
|
|
echo "=== BEGIN DIFF ===" # use echo, not log for clean output to be scraped
|
|
git add --intent-to-add .
|
|
git diff HEAD
|
|
exit 1
|
|
|
|
|