-
Notifications
You must be signed in to change notification settings - Fork 0
172 lines (141 loc) · 4.67 KB
/
Copy pathtests.yml
File metadata and controls
172 lines (141 loc) · 4.67 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: "Tests"
on:
pull_request:
push:
branches:
- main
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
name: "PHPUnit (PHP ${{ matrix.php }})"
runs-on: ubuntu-latest
strategy:
matrix:
php:
- 8.4
- latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # 2.37.1
with:
coverage: "none"
php-version: ${{ matrix.php }}
tools: composer:v2
- uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
- name: "Run tests"
run: vendor/bin/phpunit
action-smoke:
name: "Action smoke test"
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: "Set up scenario repo"
run: |
mkdir -p scenario/src
cd scenario
git init -q -b main
git config user.email t@t
git config user.name t
cat > src/Repo.php <<'EOF'
<?php
namespace SelfTest;
interface Iface {
public function action(): bool;
}
class Repo {
public function existing(): void {}
public function willBeRemoved(): int { return 0; }
/**
* @internal
*/
public function alreadyInternal(): void {}
}
EOF
git add -A
git commit -q -m base
cat > src/Repo.php <<'EOF'
<?php
namespace SelfTest;
interface Iface {
public function action(): bool;
}
class Repo implements Iface {
public function existing(): void {}
public function brandNewMethod(string $arg): bool { return true; }
public function action(): bool { return false; }
public string $newProp = '';
/**
* @internal
*/
public function alreadyInternal(): void {}
}
EOF
git add -A
git commit -q -m head
- uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # 2.37.1
with:
coverage: 'none'
php-version: 8.5
tools: composer:v2
- run: composer install --no-interaction --no-progress --classmap-authoritative
- name: "Run analysis against scenario"
working-directory: scenario
env:
BASE_REF: HEAD~1
PATHS_GLOB: 'src/**/*.php'
SOURCE_ROOTS: 'src'
SHOW_MODIFIED: 'false'
SHOW_REMOVED: 'true'
WORKSPACE: ${{ github.workspace }}
run: bash "${WORKSPACE}/scripts/detect.sh"
- name: "Assert expected output"
run: |
set -euo pipefail
body="scenario/api-surface-result/comment-body.txt"
if [[ ! -s "$body" ]]; then
echo "Comment body is empty or missing — expected new method, new property, removed method." >&2
exit 1
fi
echo "=== comment body ==="
cat "$body"
echo "===================="
fail=0
must_contain() {
if ! grep -qF "$1" "$body"; then
echo "MISSING: $1" >&2
fail=1
fi
}
must_not_contain() {
if grep -qF "$1" "$body"; then
echo "UNEXPECTED: $1" >&2
fail=1
fi
}
# Brand-new method on existing class — should be reported.
must_contain 'SelfTest\Repo::brandNewMethod'
must_contain 'public function brandNewMethod(string $arg): bool'
# New property on existing class — should be reported.
must_contain 'SelfTest\Repo::newProp'
must_contain '#### Properties'
# Method that just implements an existing interface — must NOT appear.
must_not_contain 'SelfTest\Repo::action'
# Removed method — should be in Removed section.
must_contain '### Removed API Surface'
must_contain 'SelfTest\Repo::willBeRemoved'
# @internal additions are excluded by default.
must_not_contain 'alreadyInternal'
if [[ "$fail" -ne 0 ]]; then
echo "Smoke test assertions failed." >&2
exit 1
fi
echo "Smoke test passed."