-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (62 loc) · 1.96 KB
/
swift.yml
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
name: Swift
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer
SWIFT_STRICT_CONCURRENCY: complete
jobs:
swift:
name: Swift
runs-on: macos-13
env:
SIMULATOR: iPhone 14
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Validate excluded snapshots
run: |
SNAPSHOTS=$(find Tests -type d -name "__Snapshots__" | sort)
EXCLUDED=$(swift package dump-package | jq -r '.targets[] | select(.type == "test") | "Tests/" + .name + "/" + .exclude[]' | sort)
UNEXCLUDED=$(comm -23 <(echo "$SNAPSHOTS") <(echo "$EXCLUDED"))
if test -n "$UNEXCLUDED"
then
echo "::error::Snapshot directories must be excluded from Swift package:" >&2
echo "$UNEXCLUDED" >&2
exit 1
fi
- name: Download swiftlint binary
run: swift package resolve
- name: Lint
run: |
DIRECTORY_NAME=$(echo "${PWD##*/}" | tr '[:upper:]' '[:lower:]')
"$(find ".build/artifacts/${DIRECTORY_NAME}" -type f -name swiftlint -perm +111 -print -quit)" \
lint --strict --reporter github-actions-logging
- name: Resolve package dependencies
run: xcodebuild -resolvePackageDependencies
- name: Build
run: >
xcodebuild
build-for-testing
-scheme "Layout"
-destination "name=$SIMULATOR,OS=latest"
SWIFT_TREAT_WARNINGS_AS_ERRORS=YES
- name: Test
run: >
xcodebuild
test-without-building
-scheme "Layout"
-destination "name=$SIMULATOR,OS=latest"
- name: Delete snapshots
run: make delete-snapshots
- name: Record snapshots
run: >
xcodebuild
test-without-building
-scheme "Layout"
-destination "name=$SIMULATOR,OS=latest"
continue-on-error: true
- name: Validate recorded snapshots
run: test -z "$(git status --porcelain)"