@@ -9,14 +9,85 @@ concurrency:
9
9
cancel-in-progress : true
10
10
11
11
jobs :
12
- tests :
13
- name : Test
14
- uses : swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
15
- with :
16
- linux_exclude_swift_versions : " [{\" swift_version\" : \" 5.8\" }]"
17
- soundness :
18
- name : Soundness
19
- uses : swiftlang/github-workflows/.github/workflows/soundness.yml@main
20
- with :
21
- license_header_check_project_name : " Swift.org"
22
- api_breakage_check_allowlist_path : " api-breakages.txt"
12
+ # tests:
13
+ # name: Test
14
+ # uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
15
+ # with:
16
+ # linux_exclude_swift_versions: "[{\"swift_version\": \"5.8\"}]"
17
+ # soundness:
18
+ # name: Soundness
19
+ # uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
20
+ # with:
21
+ # license_header_check_project_name: "Swift.org"
22
+ # api_breakage_check_allowlist_path: "api-breakages.txt"
23
+ performance_test :
24
+ name : Performance test
25
+ runs-on : ubuntu-latest
26
+ container :
27
+ image : swift:latest
28
+ permissions :
29
+ pull-requests : write
30
+ steps :
31
+ - name : Install libjemalloc-dev
32
+ run : apt-get update && apt-get install -y libjemalloc-dev
33
+ - name : Checkout repository
34
+ uses : actions/checkout@v4
35
+ with :
36
+ fetch-depth : 0
37
+ - name : Mark the workspace as safe
38
+ # https://github.com/actions/checkout/issues/766
39
+ run : git config --global --add safe.directory ${GITHUB_WORKSPACE}
40
+ - name : Measure PR performance
41
+ run : |
42
+ swift package --package-path Benchmarks/ --allow-writing-to-directory Benchmarks/.benchmarkBaselines/ benchmark baseline update "${{ github.head_ref }}"
43
+ - name : Measure base branch performance
44
+ run : |
45
+ git checkout ${{ github.base_ref }}
46
+ swift package --package-path Benchmarks/ --allow-writing-to-directory Benchmarks/.benchmarkBaselines/ benchmark baseline update "${{ github.base_ref }}"
47
+ - name : Compare performance measurements
48
+ id : compare_performance
49
+ run : |
50
+ find Benchmarks
51
+ if ! swift package --package-path Benchmarks benchmark baseline check "${{ github.base_ref }}" "${{ github.head_ref }}" --format markdown > /tmp/comparison.md 2>/tmp/comparison-stderr.txt; then
52
+ echo "has_significant_changes=true" >> "$GITHUB_OUTPUT"
53
+ else
54
+ echo "has_significant_changes=false" >> "$GITHUB_OUTPUT"
55
+ fi
56
+ - name : Install gh
57
+ if : ${{ steps.compare_performance.outputs.has_significant_changes == 'true' }}
58
+ # Installation instructions from https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt
59
+ run : |
60
+ (type -p wget >/dev/null || (apt update && apt-get install wget -y)) \
61
+ && mkdir -p -m 755 /etc/apt/keyrings \
62
+ && out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
63
+ && cat $out | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
64
+ && chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
65
+ && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
66
+ && apt update \
67
+ && apt install gh -y
68
+ - name : Post comment
69
+ if : ${{ steps.compare_performance.outputs.has_significant_changes == 'true' }}
70
+ env :
71
+ GH_TOKEN : ${{ github.token }}
72
+ run : |
73
+ if grep benchmarkThresholdRegression /tmp/comparison-stderr.txt > /dev/null; then
74
+ PERFORMANCE_CHANGE_MESSAGE="This PR has regressed performance characteristics. Please review whether the changes reported below are expected or if you can do something to improve them."
75
+ END_OF_COMMENT
76
+ elif grep benchmarkThresholdImprovement /tmp/comparison-stderr.txt > /dev/null; then
77
+ PERFORMANCE_CHANGE_MESSAGE="This PR has improved performance characteristics. Thank you 🚀"
78
+ else
79
+ PERFORMANCE_CHANGE_MESSAGE="This PR has changed performance characteristics. Please review that the measurements reported below are expected or if you can do something to improve them."
80
+ fi
81
+
82
+ cat > /tmp/performance_change_header.md <<EOF
83
+ $PERFORMANCE_CHANGE_MESSAGE
84
+
85
+ <details><summary><b>Performance report</b></summary>
86
+
87
+ EOF
88
+
89
+ cat "</details>" > /tmp/performance_change_footer.md
90
+
91
+ COMMENT="$(cat /tmp/performance_change_header.md /tmp/comparison.md /tmp/performance_change_footer.md)"
92
+ gh pr comment ${{ github.event.number }} --body "$COMMENT"
93
+
0 commit comments