Measure performance on PRs #393
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pull request | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
tests: | |
name: Test | |
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main | |
with: | |
linux_exclude_swift_versions: "[{\"swift_version\": \"5.8\"}]" | |
soundness: | |
name: Soundness | |
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main | |
with: | |
license_header_check_project_name: "Swift.org" | |
api_breakage_check_allowlist_path: "api-breakages.txt" | |
performance_test: | |
runs-on: ubuntu-latest | |
container: | |
image: swift:latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download performance comparison script | |
run: | | |
apt-get update && apt-get install -y curl | |
curl -s https://raw.githubusercontent.com/ahoppen/swift-format/refs/heads/main/.github/workflows/scripts/compare-performance-measurements.swift > /tmp/compare-performance-measurements.swift | |
- name: Measure performance with PR changes | |
id: pr_performance | |
run: | | |
OUTPUT=$(echo "Random: $(random)") | |
echo "output=$OUTPUT" >> "$GITHUB_OUTPUT" | |
- name: Measure baseline performance | |
id: baseline_performance | |
run: | | |
OUTPUT=$(echo "Random: $(random)") | |
echo "output=$OUTPUT" >> "$GITHUB_OUTPUT" | |
- name: Post comment if performance changed | |
run: | | |
if ! OUTPUT=$(swift /tmp/compare-performance-measurements.swift "${{ steps.baseline_performance.outputs.output }}" "${{ steps.pr_performance.outputs.output }}" 0.5); then | |
gh pr comment --body "$OUTPUT" | |
else | |
echo "No significant performance change detected" | |
echo "$OUTPUT" | |
fi | |