Skip to content

fix(macos): fix failing ci snapshots #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
68d27bb
[WIP] ci(workflow): test macos image snapshots on ci
tillhainbach Nov 5, 2021
24f7afe
[WIP] ci(workflow): upload failing artifacts
tillhainbach Nov 5, 2021
e31bd9f
[WIP] ci(workflow): fix artifact path in upload step
tillhainbach Nov 5, 2021
f8b7dee
feat(nsview): add option to specify appearance
tillhainbach Nov 5, 2021
ce077a1
fix(cg-path, ns-bezier-path): explicitly set decimal separator
tillhainbach Nov 5, 2021
5d08eee
test(nsview): fix appearance to .aqua
tillhainbach Nov 6, 2021
90e90d7
test(navies): add a CI-compatible snapshot test
tillhainbach Nov 6, 2021
c639e36
test(nsview): add snapshots for CI-campatible test
tillhainbach Nov 6, 2021
c3f2b91
feat(nsview): add option to set appearance, backingScaleFactor and co…
tillhainbach Nov 6, 2021
df55d47
test(nsview): set size to fixed value
tillhainbach Nov 6, 2021
23fa4d6
test(nsview): fix failing recursiveDescription test
tillhainbach Nov 6, 2021
02643ce
refactor(nsview): add convenience GenericWindow preconfigured for CI
tillhainbach Nov 6, 2021
a8ca3ac
[WIP] test(nsview): add more ci-compatible nsview-tests
tillhainbach Nov 6, 2021
0259c2f
Include snapshot name in failure message (#547)
calda Dec 13, 2021
3ab2f21
Add support for Windows, add Windows job to `ci.yml` (#532)
MaxDesiatov Jan 7, 2022
2776073
Update package name (#555)
stephencelis Jan 7, 2022
a443288
Added `Snapshotting.json` for `Any` value (#552)
NachoSoto Jan 7, 2022
f4d2d82
Add Issue Templates (#556)
stephencelis Jan 7, 2022
59f0889
Remove GLKView support (#507)
jpsim Jan 7, 2022
070e9ce
Fixes display scaling bug (#554)
arnopoulos Jan 7, 2022
88f6e2c
Fix leak releasing child view controller. (#511)
llinardos Jan 11, 2022
ad2c831
minor typo correction (#601)
heckj May 5, 2022
567c66a
Include watchOS 4.0 in @available check (#579)
aydegee Jun 6, 2022
fc8cb07
Merge branch 'main' into fix-macos
stephencelis Jun 21, 2022
05c8003
Fix typo (#630)
valeriyvan Sep 17, 2022
193f074
Fix doc comment (#631)
valeriyvan Sep 21, 2022
c8da72a
Fix doc comment (#632)
valeriyvan Sep 21, 2022
2d6c5b3
Fix doc comment (#633)
valeriyvan Sep 21, 2022
db425a6
Fix doc comment (#634)
valeriyvan Sep 21, 2022
0ee60e4
Fix doc comment (#635)
valeriyvan Sep 21, 2022
f13a134
Fix doc comment (#636)
valeriyvan Sep 21, 2022
36694f3
Perceptual image precision + 90% speed improvement (#628)
ejensen Sep 21, 2022
5e09892
Add iPhone 13 devices (#603)
luispadron Sep 21, 2022
43f386f
Modernize Project (#637)
stephencelis Sep 21, 2022
208cb71
Report the actual and expected image precision when an image comparis…
ejensen Sep 21, 2022
4eee37a
Update README.md
stephencelis Sep 21, 2022
0c2826f
Fix doc comment (#639)
valeriyvan Sep 21, 2022
c79f0f2
Require Swift 5.5+ (#640)
stephencelis Sep 21, 2022
33dfcad
Add SnapshotTestingHEIC to plugins list (#561)
alexey1312 Sep 21, 2022
ea9bc1b
Improve warning about view snapshot discrepancies (#592)
gohanlon Sep 21, 2022
347fb40
Attach recorded snapshot (#586)
marcelofabri Sep 21, 2022
efe7011
Merge branch 'main' into fix-macos
stephencelis Sep 21, 2022
9259a19
Update ci.yml
stephencelis Sep 21, 2022
4e92761
Remove CI-compatible tests for now
stephencelis Sep 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
34 changes: 34 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
Give a clear and concise description of what the bug is.

**To Reproduce**
Zip up a project that reproduces the behavior and attach it by dragging it here.

```swift
// And/or enter code that reproduces the behavior here.

```

**Expected behavior**
Give a clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment**
- swift-snapshot-testing version [e.g. 1.9.0]
- Xcode [e.g. 13.2]
- Swift [e.g. 5.5]
- OS: [e.g. iOS 15]

**Additional context**
Add any more context about the problem here.
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Question
about: Have a question about SnapshotTesting?
title: ''
labels: ''
assignees: ''

---

SnapshotTesting uses GitHub issues for bugs. For more general discussion and help, please use [GitHub Discussions](https://github.com/pointfreeco/swift-snapshot-testing/discussions).
77 changes: 64 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,74 @@ on:
- main
pull_request:
branches:
- '*'
- "*"

jobs:
build:
name: MacOS
runs-on: macOS-latest
macos:
strategy:
matrix:
xcode:
- "13.2.1" # Swift 5.5.2
- "13.4.1" # Swift 5.6.1
- "14.0" # Swift 5.7

name: macOS 12 (Xcode ${{ matrix.xcode }})
runs-on: macos-12
steps:
- uses: actions/checkout@v1
- name: Select Xcode 12.4
run: sudo xcode-select -s /Applications/Xcode_12.4.app
- name: Run tests
run: make test-swift
- uses: actions/checkout@v2
- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: Run tests
run: make test-swift
env:
SNAPSHOT_ARTIFACTS: "./.temp/artifacts"

- name: Archive failing snapshots
if: always()
uses: actions/upload-artifact@v2
with:
name: failing-snapshots
path: .temp/artifacts

ubuntu:
name: Ubuntu
strategy:
matrix:
swift:
- "5.5"
- "5.6"
- "5.7"

name: Ubuntu (Swift ${{ matrix.swift }})
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run tests
run: make test-linux
- uses: swift-actions/setup-swift@v1
with:
swift-version: ${{ matrix.swift }}
- uses: actions/checkout@v2
- run: swift test

windows:
strategy:
matrix:
swift:
- "5.5"
- "5.6"
#- "5.7"

name: Windows (Swift ${{ matrix.swift }})
runs-on: windows-2019

steps:
- uses: compnerd/gha-setup-swift@main
with:
branch: swift-${{ matrix.swift }}-release
tag: ${{ matrix.swift }}-RELEASE

- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf

- uses: actions/checkout@v2
- run: swift build
- run: swift test
2 changes: 1 addition & 1 deletion Documentation/Available-Snapshot-Strategies.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Available Snapshot Strategies

SnapshotTesting comes with a wide variety of snapshot strategies for a varienty of platforms. To extend these strategies or define your own, see [Defining Custom Snapshot Strategies](Defining-Custom-Snapshot-Strategies.md).
SnapshotTesting comes with a wide variety of snapshot strategies for a variety of platforms. To extend these strategies or define your own, see [Defining Custom Snapshot Strategies](Defining-Custom-Snapshot-Strategies.md).

If you'd like to submit your own custom strategy, see [Contributing](../CONTRIBUTING.md).

Expand Down
13 changes: 5 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
xcodeproj:
PF_DEVELOP=1 swift run xcodegen

test-linux:
docker run \
--rm \
-v "$(PWD):$(PWD)" \
-w "$(PWD)" \
swift:5.2 \
bash -c 'make test-swift'
swift:5.7-focal \
bash -c 'swift test'

test-macos:
set -o pipefail && \
xcodebuild test \
-scheme SnapshotTesting_macOS \
-scheme SnapshotTesting \
-destination platform="macOS" \

test-ios:
set -o pipefail && \
xcodebuild test \
-scheme SnapshotTesting_iOS \
-scheme SnapshotTesting \
-destination platform="iOS Simulator,name=iPhone 11 Pro Max,OS=13.3" \

test-swift:
Expand All @@ -27,7 +24,7 @@ test-swift:
test-tvos:
set -o pipefail && \
xcodebuild test \
-scheme SnapshotTesting_tvOS \
-scheme SnapshotTesting \
-destination platform="tvOS Simulator,name=Apple TV 4K,OS=13.3" \

test-all: test-linux test-macos test-ios
29 changes: 10 additions & 19 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
// swift-tools-version:5.0
import Foundation
// swift-tools-version:5.5
import PackageDescription

let package = Package(
name: "SnapshotTesting",
name: "swift-snapshot-testing",
platforms: [
.iOS(.v11),
.macOS(.v10_10),
.tvOS(.v10)
.iOS(.v13),
.macOS(.v10_15),
.tvOS(.v13)
],
products: [
.library(
name: "SnapshotTesting",
targets: ["SnapshotTesting"]),
targets: ["SnapshotTesting"]
),
],
targets: [
.target(
name: "SnapshotTesting",
dependencies: []),
.target(name: "SnapshotTesting"),
.testTarget(
name: "SnapshotTestingTests",
dependencies: ["SnapshotTesting"]),
dependencies: ["SnapshotTesting"]
)
]
)

if ProcessInfo.processInfo.environment.keys.contains("PF_DEVELOP") {
package.dependencies.append(
contentsOf: [
.package(url: "https://github.com/yonaskolb/XcodeGen.git", .exact("2.15.1")),
]
)
}
54 changes: 19 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 📸 SnapshotTesting

[![Swift 5.1](https://img.shields.io/badge/swift-5.1-ED523F.svg?style=flat)](https://swift.org/download/)
[![CI](https://github.com/pointfreeco/swift-snapshot-testing/workflows/CI/badge.svg)](https://actions-badge.atrox.dev/pointfreeco/swift-snapshot-testing/goto)
[![@pointfreeco](https://img.shields.io/badge/[email protected]?style=flat)](https://twitter.com/pointfreeco)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpointfreeco%2Fswift-snapshot-testing%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/pointfreeco/swift-snapshot-testing)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpointfreeco%2Fswift-snapshot-testing%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/pointfreeco/swift-snapshot-testing)

Delightful Swift snapshot testing.

Expand Down Expand Up @@ -75,7 +75,7 @@ assertSnapshot(matching: vc, as: .image(on: .iPadMini(.portrait)))
assertSnapshot(matching: vc, as: .recursiveDescription(on: .iPadMini(.portrait)))
```

> ⚠️ Warning: Snapshots must be compared using a simulator with the same OS, device gamut, and scale as the simulator that originally took the reference to avoid discrepancies between images.
> ⚠️ Warning: Snapshots must be compared using the exact same simulator that originally took the reference to avoid discrepancies between images.

Better yet, SnapshotTesting isn't limited to views and view controllers! There are [a number of available snapshot strategies](Documentation/Available-Snapshot-Strategies.md) to choose from.

Expand Down Expand Up @@ -128,12 +128,12 @@ If your data can be represented as an image, text, or data, you can write a snap

## Installation

### Xcode 11
### Xcode

> ⚠️ Warning: By default, Xcode will try to add the SnapshotTesting package to your project's main application/framework target. Please ensure that SnapshotTesting is added to a _test_ target instead, as documented in the last step, below.

1. From the **File** menu, navigate through **Swift Packages** and select **Add Package Dependency…**.
2. Enter package repository URL: `https://github.com/pointfreeco/swift-snapshot-testing.git`
2. Enter package repository URL: `https://github.com/pointfreeco/swift-snapshot-testing`
3. Confirm the version and let Xcode resolve the package
4. On the final dialog, update SnapshotTesting's **Add to Target** column to a test target that will contain snapshot tests (if you have more than one test target, you can later add SnapshotTesting to them by manually linking the library in its build phase)

Expand All @@ -143,46 +143,28 @@ If you want to use SnapshotTesting in any other project that uses [SwiftPM](http

```swift
dependencies: [
.package(name: "SnapshotTesting", url: "https://github.com/pointfreeco/swift-snapshot-testing.git", from: "1.9.0"),
.package(
url: "https://github.com/pointfreeco/swift-snapshot-testing",
from: "1.9.0"
),
]
```

Next, add `SnapshotTesting` as a dependency of your test target:

```swift
targets: [
.target(name: "MyApp", dependencies: [], path: "Sources"),
.testTarget(name: "MyAppTests", dependencies: ["MyApp", "SnapshotTesting"])
.target(name: "MyApp"),
.testTarget(
name: "MyAppTests",
dependencies: [
"MyApp",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
]
)
]
```

### Carthage

If you use [Carthage](https://github.com/Carthage/Carthage), you can add the following dependency to your `Cartfile`:

``` ruby
github "pointfreeco/swift-snapshot-testing" ~> 1.9.0
```

> ⚠️ Warning: Carthage instructs you to drag frameworks into your Xcode project. Xcode may automatically attempt to link these frameworks to your app target. `SnapshotTesting.framework` is only compatible with test targets, so when you first add it to your project:
>
> 1. Remove `SnapshotTesting.framework` from any non-test target it may have been added to.
> 2. Add `SnapshotTesting.framework` to any applicable test targets.
> 3. Add a **New Copy Build Phase** to any applicable test targets with **Destination** set to "Frameworks", and add `SnapshotTesting.framework` as an item to this phase.
> 4. Do _not_ add `SnapshotTesting.framework` to the "Input Files" or "Output Files" of your app target's Carthage `copy-frameworks` **Run Script Phase**.
>
> See Carthage's "[Adding frameworks to unit tests or a framework](https://github.com/Carthage/Carthage#adding-frameworks-to-unit-tests-or-a-framework)" documentation for more.

### CocoaPods

If your project uses [CocoaPods](https://cocoapods.org), add the pod to any applicable test targets in your `Podfile`:

```ruby
target 'MyAppTests' do
pod 'SnapshotTesting', '~> 1.9.0'
end
```

## Features

- [**Dozens of snapshot strategies**](Documentation/Available-Snapshot-Strategies.md). Snapshot testing isn't just for `UIView`s and `CALayer`s. Write snapshots against _any_ value.
Expand Down Expand Up @@ -214,6 +196,8 @@ end

- [swift-snapshot-testing-stitch](https://github.com/Sherlouk/swift-snapshot-testing-stitch/) adds the ability to stitch multiple UIView's or UIViewController's together in a single test.

- [SnapshotTestingHEIC](https://github.com/alexey1312/SnapshotTestingHEIC) adds image support using the HEIC storage format which reduces file sizes in comparison to PNG.

Have you written your own SnapshotTesting plug-in? [Add it here](https://github.com/pointfreeco/swift-snapshot-testing/edit/master/README.md) and submit a pull request!

## Related Tools
Expand Down
37 changes: 0 additions & 37 deletions SnapshotTesting.podspec

This file was deleted.

25 changes: 0 additions & 25 deletions SnapshotTesting.xcodeproj/Diff_Info.plist

This file was deleted.

Loading