-
Notifications
You must be signed in to change notification settings - Fork 83
327 lines (314 loc) · 14.1 KB
/
Copy pathpull_request.yml
File metadata and controls
327 lines (314 loc) · 14.1 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
name: Pull Request
permissions:
contents: read
on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches: [main, 'release/*']
jobs:
soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
license_header_check_enabled: false
license_header_check_project_name: "Swift.org"
api_breakage_check_enabled: false
docs_check_enabled: false
format_check_enabled: false
shell_check_enabled: false
unacceptable_language_check_enabled: true
freebsd-aarch64-tests:
name: Test / FreeBSD aarch64
runs-on: ubuntu-latest
if: ${{ github.repository == 'networkextension/swiftly' || github.repository == 'swiftlang/swiftly' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install cloudflared
run: |
curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | sudo tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null
echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared any main' | sudo tee /etc/apt/sources.list.d/cloudflared.list
sudo apt-get update && sudo apt-get install -y cloudflared
- name: Set up SSH key and known hosts
env:
FREEBSD_SSH_KEY: ${{ secrets.FREEBSD_SSH_KEY }}
FREEBSD_CF_HOSTNAME: ${{ secrets.FREEBSD_CF_HOSTNAME }}
run: |
mkdir -p "$HOME/.ssh"
printf '%s\n' "$FREEBSD_SSH_KEY" > "$HOME/.ssh/freebsd_ci_key"
chmod 600 "$HOME/.ssh/freebsd_ci_key"
printf '%s ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFqpy2Vs6oX1K5khxWW7INHC8a6meSaSvNDVXpCSv1Gj\n' \
"$FREEBSD_CF_HOSTNAME" >> "$HOME/.ssh/known_hosts"
chmod 600 "$HOME/.ssh/known_hosts"
printf 'Host freebsd-ci\n HostName %s\n User swift\n IdentityFile %s/.ssh/freebsd_ci_key\n ProxyCommand cloudflared access tcp --hostname %%h\n' \
"$FREEBSD_CF_HOSTNAME" "$HOME" > "$HOME/.ssh/config"
chmod 600 "$HOME/.ssh/config"
- name: Sync source to board
run: |
ssh -F "$HOME/.ssh/config" freebsd-ci 'mkdir -p /home/swift/ci/swiftly'
rsync -avz --delete \
--exclude='.build' --exclude='.git' \
-e "ssh -F $HOME/.ssh/config" \
. freebsd-ci:/home/swift/ci/swiftly/
- name: Build and Test on FreeBSD aarch64
run: |
ssh -F "$HOME/.ssh/config" freebsd-ci /bin/sh << 'ENDSSH'
set -e
. "$HOME/swift632-env.sh"
cd "$HOME/ci/swiftly"
swift package resolve 2>&1
# CNIOBoringSSL: FreeBSD sys/time.h guards gettimeofday behind __XSI_VISIBLE,
# which is 0 unless _XOPEN_SOURCE>=500. BoringSSL doesn't define it.
# Inject _XOPEN_SOURCE 600 + sys/time.h unconditionally at line 1.
# Also strip any prior v1 patch (2-line) before applying the new 5-line one.
SSL_LIB=$(find .build/checkouts -path "*/CNIOBoringSSL*/ssl/ssl_lib.cc" 2>/dev/null | head -1)
if [ -n "$SSL_LIB" ]; then
grep -qF 'FreeBSD-gettimeofday-xsi' "$SSL_LIB" || {
grep -q 'FreeBSD-gettimeofday' "$SSL_LIB" && sed -i '' '1,2d' "$SSL_LIB"
awk 'NR==1{print "/* FreeBSD-gettimeofday-xsi */\n#ifndef _XOPEN_SOURCE\n#define _XOPEN_SOURCE 600\n#endif\n#include <sys/time.h>"}1' "$SSL_LIB" > /tmp/_ssl.cc
mv /tmp/_ssl.cc "$SSL_LIB"
echo "Patched $SSL_LIB"
}
fi
# CNIOBoringSSL: getentropy in unistd.h is behind __BSD_VISIBLE on FreeBSD.
# Forward-declare it directly so no feature macros are needed.
GE=$(find .build/checkouts -path "*/CNIOBoringSSL*/crypto/rand/getentropy.cc" 2>/dev/null | head -1)
if [ -n "$GE" ]; then
grep -qF 'FreeBSD-getentropy-fix' "$GE" || {
awk 'NR==1{print "/* FreeBSD-getentropy-fix */\n#if defined(__FreeBSD__)\nextern \"C\" int getentropy(void*, __SIZE_TYPE__);\n#endif"}1' "$GE" > /tmp/_ge.cc
mv /tmp/_ge.cc "$GE"
echo "Patched $GE"
}
fi
# All NIO-style lock files: FreeBSD pthread types are opaque pointers like OpenBSD
find .build/checkouts \( -name "Locks.swift" -o -name "NIOLock.swift" \) 2>/dev/null | while read LOCKS; do
grep -qF "pthread" "$LOCKS" || continue
grep -qF "os(OpenBSD) || os(FreeBSD)" "$LOCKS" || \
sed -i '' 's/os(OpenBSD)/os(OpenBSD) || os(FreeBSD)/g' "$LOCKS"
grep -qF "pthread_rwlock_t?>" "$LOCKS" || \
sed -i '' 's/pthread_rwlock_t> =/pthread_rwlock_t?> =/' "$LOCKS"
grep -qF "LockPrimitive = pthread_mutex_t?" "$LOCKS" || \
sed -i '' 's/typealias LockPrimitive = pthread_mutex_t$/typealias LockPrimitive = pthread_mutex_t?/' "$LOCKS"
grep -qF "pthread_mutexattr_t(bitPattern:" "$LOCKS" || \
sed -i '' 's/var attr = pthread_mutexattr_t()/var attr: pthread_mutexattr_t? = pthread_mutexattr_t(bitPattern: 0)/' "$LOCKS"
echo "Patched $LOCKS"
done
# swift-log Logging.swift: Glibc.stdout/stderr non-optional on FreeBSD (unlike Linux)
LOGGING=$(find .build/checkouts -path "*/swift-log*/Logging.swift" 2>/dev/null | head -1)
if [ -n "$LOGGING" ]; then
grep -qF "Glibc.stdout!" "$LOGGING" && \
sed -i '' 's/Glibc\.stdout!/Glibc.stdout/g; s/Glibc\.stderr!/Glibc.stderr/g' "$LOGGING" && \
echo "Patched $LOGGING"
fi
# swift-subprocess Thread.swift: two FreeBSD fixes —
# 1) MutexType/ConditionType need optional typealiases (opaque pthread types)
# 2) pthread_t() has no default init on FreeBSD; use unsafeBitCast placeholder
# (_subprocess_pthread_create takes _Nonnull ptr so must stay non-optional)
SUBTHREAD=$(find .build/checkouts -path "*/swift-subprocess*/Thread.swift" 2>/dev/null | head -1)
if [ -n "$SUBTHREAD" ]; then
grep -qF "pthread_mutex_t?" "$SUBTHREAD" || {
awk '/^private typealias MutexType = pthread_mutex_t$/{
print "#if os(FreeBSD) || os(OpenBSD)\nprivate typealias MutexType = pthread_mutex_t?\nprivate typealias ConditionType = pthread_cond_t?\n#else\n" $0; next}
/^private typealias ConditionType = pthread_cond_t$/{print $0 "\n#endif"; next}1' \
"$SUBTHREAD" > /tmp/_th.swift
mv /tmp/_th.swift "$SUBTHREAD"
echo "Patched $SUBTHREAD (typealiases)"
}
grep -qF 'unsafeBitCast(0 as UInt' "$SUBTHREAD" || {
awk '/^ var thread = pthread_t\(\)$/{
print "#if os(FreeBSD) || os(OpenBSD)"
print " var thread: pthread_t = unsafeBitCast(0 as UInt, to: pthread_t.self)"
print "#else"
print $0
print "#endif"
next}1' "$SUBTHREAD" > /tmp/_th.swift
mv /tmp/_th.swift "$SUBTHREAD"
echo "Patched $SUBTHREAD (pthread_t init)"
}
fi
swift build 2>&1
swift test --filter SwiftlyTests 2>&1
ENDSSH
timeout-minutes: 60
macos-tests-selfhosted:
name: Test (Self Hosted) / macOS Tahoe ARM64
runs-on: [self-hosted, macos, tahoe, ARM64]
if: ${{ github.repository == 'swiftlang/swiftly' }}
strategy:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare the action
run: ./scripts/prep-gh-action.sh --install-swiftly
- name: Build and Test
run: swift test
timeout-minutes: 60
tests-selfhosted:
name: Test (Self Hosted) / ${{ matrix.container }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
container: ["ubuntu:22.04", "ubuntu:24.04", "redhat/ubi9", "debian:12", "fedora:39"]
container:
image: ${{ matrix.container }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare the action
run: ./scripts/prep-gh-action.sh --install-swiftly
- name: Build and Test
# UBI 9 - See https://github.com/swiftlang/swift/issues/80908
# UBI 9 - See https://github.com/swiftlang/swift/issues/80909
run: bash -c 'if [[ "${{ matrix.container }}" == "redhat/ubi9" ]]; then swift build --build-tests; else swift test; fi'
# Verify new platforms without a released Swiftly build
tests-bootstrapped:
name: Test (Bootstrapped) / ${{ matrix.container }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
container: ["swiftlang/swift:nightly-6.3-fedora41"]
container:
image: ${{ matrix.container }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare the action
run: ./scripts/prep-gh-action.sh
- name: Build and Test
run: swift test
releasebuildcheck:
name: Release Build Check / Linux
runs-on: ubuntu-latest
container:
image: "redhat/ubi9"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare the action
run: ./scripts/prep-gh-action.sh --install-swiftly
- name: Build Artifact
run: swift run build-swiftly-release --test --skip "999.0.0"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: swiftly-release-x86_64
path: .build/release/swiftly-*.tar.gz
if-no-files-found: error
retention-days: 1
- name: Upload Tests
uses: actions/upload-artifact@v4
with:
name: test-swiftly-linux-x86_64
path: .build/debug/test-swiftly-linux-x86_64.tar.gz
if-no-files-found: error
retention-days: 1
releasebuildcheckmacos:
name: Release Build Check / macOS
runs-on: [self-hosted, macos, tahoe, ARM64]
if: ${{ github.repository == 'swiftlang/swiftly' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare the action
run: ./scripts/prep-gh-action.sh --install-swiftly
- name: Build Artifact
run: swift run build-swiftly-release --test --skip "999.0.0"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: swiftly-release-darwin
path: .build/release/swiftly-*.pkg
if-no-files-found: error
retention-days: 1
- name: Upload Tests
uses: actions/upload-artifact@v4
with:
name: test-swiftly-macos
path: .build/release/test-swiftly-macos.tar.gz
if-no-files-found: error
retention-days: 1
releasetest:
name: Test Release / ${{matrix.shell.pkg}}
needs: releasebuildcheck
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shell: [
{"pkg": "bash", "bin": "/bin/bash"},
{"pkg": "zsh", "bin": "/bin/zsh"},
{"pkg": "fish", "bin": "/bin/fish"}
]
container:
image: "ubuntu:24.04"
steps:
- name: Prepare System
run: apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install ca-certificates gpg tzdata ${{matrix.shell.pkg}} && chsh -s ${{matrix.shell.bin}}
- name: Download Release
uses: actions/download-artifact@v4
with:
name: swiftly-release-x86_64
- name: Download Tests
uses: actions/download-artifact@v4
with:
name: test-swiftly-linux-x86_64
- name: Extract and Run Workflow Tests
run: cp swiftly-*.tar.gz /root/swiftly.tar.gz && cp test-swiftly-*.tar.gz /root && cd /root && tar zxf test-swiftly-*.tar.gz && ./test-swiftly -y ./swiftly.tar.gz
release-custom-install-test:
name: Test Release - Custom Install Location
needs: releasebuildcheck
runs-on: ubuntu-latest
container:
image: "ubuntu:24.04"
steps:
- name: Prepare System
run: apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install ca-certificates gpg tzdata
- name: Download Release
uses: actions/download-artifact@v4
with:
name: swiftly-release-x86_64
- name: Download Tests
uses: actions/download-artifact@v4
with:
name: test-swiftly-linux-x86_64
- name: Extract and Run Workflow Tests
run: cp swiftly-*.tar.gz /root/swiftly.tar.gz && cp test-swiftly-*.tar.gz /root && cd /root && tar zxf test-swiftly-*.tar.gz && ./test-swiftly -y --custom-location ./swiftly.tar.gz
formatcheck:
name: Format Check
runs-on: ubuntu-latest
container:
image: ubuntu:22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare the action
run: ./scripts/prep-gh-action.sh --install-swiftly
- name: Check format
run: swift run swiftformat --lint --dryrun . || (echo "Please run 'swift run swiftformat .' to format the source code."; exit 1)
docscheck:
name: Documentation Check
runs-on: ubuntu-latest
container:
image: ubuntu:24.04
steps:
- name: Install git
run: apt-get update && apt-get -y install git
- name: Checkout repository
uses: actions/checkout@v4
- name: Prepare the action
run: ./scripts/prep-gh-action.sh --install-swiftly
- name: Generate Swiftly CLI Reference and Check for Differences
run: swift package plugin --allow-writing-to-package-directory generate-docs-reference && bash -c 'git config --global --add safe.directory $(pwd)' && git diff --exit-code Documentation/SwiftlyDocs.docc/swiftly-cli-reference.md || (echo "The documentation hasn't been updated with the latest swiftly command-line reference. Please run 'swift package plugin generate-docs-reference' and commit/push the changes."; exit 1)
- name: Generate Documentation Set
run: swift package --allow-writing-to-directory .build/docs generate-documentation --target SwiftlyDocs --output-path .build/docs
- name: Upload Documentation Artifacts
uses: actions/upload-artifact@v4
with:
name: swiftly-docs
path: .build/docs/**
if-no-files-found: error
retention-days: 1