Repository navigation
89 lines (79 loc) · 2.8 KB
/
Copy pathapi-breakage.yml
File metadata and controls
89 lines (79 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: API Breakage
on:
pull_request:
branches: [ "main" ]
paths-ignore: [ "**.md", "LICENSE" ]
push:
branches: [ "main" ]
paths-ignore: [ "**.md", "LICENSE" ]
workflow_dispatch:
inputs:
baseline:
description: "Git treeish to compare against (default: latest release tag)"
required: false
default: ""
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
api-breakage:
name: Compare public API with latest release
runs-on: macos-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
- name: Select baseline
id: baseline
env:
REQUESTED: ${{ inputs.baseline }}
run: |
if [ -n "$REQUESTED" ]; then
baseline="$REQUESTED"
else
baseline="$(git tag --list --sort=-version:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)"
fi
if [ -z "$baseline" ]; then
echo "::error::Could not determine a baseline release tag"
exit 1
fi
echo "Comparing the public API against $baseline"
echo "baseline=$baseline" >> "$GITHUB_OUTPUT"
- name: Diagnose API breaking changes
env:
BASELINE: ${{ steps.baseline.outputs.baseline }}
run: |
set -o pipefail
status=0
swift package diagnose-api-breaking-changes "$BASELINE" \
--products OpenAI \
--breakage-allowlist-path .github/api-breakage-allowlist.txt \
2>&1 | tee api-breakage.log || status=$?
if grep -q "API breakage" api-breakage.log; then
{
echo "## 💔 Public API breaks compared with \`$BASELINE\`"
echo
echo "Fix each line below, or consciously accept it by adding the exact message on its own line to \`.github/api-breakage-allowlist.txt\` (messages only, no comments) together with a CHANGELOG entry."
echo
echo '```'
grep "API breakage" api-breakage.log
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
echo "::error::Public API breaking changes detected compared with $BASELINE. See the job summary."
exit 1
fi
if [ "$status" -ne 0 ]; then
echo "::error::swift package diagnose-api-breaking-changes exited with status $status"
exit "$status"
fi
echo "## ✅ No public API breaks compared with \`$BASELINE\`" >> "$GITHUB_STEP_SUMMARY"
- name: Upload report
if: always()
uses: actions/upload-artifact@v7
with:
name: api-breakage-report
path: api-breakage.log
if-no-files-found: ignore