From 8e69e972b38b7c5322dc4761a56e069350171088 Mon Sep 17 00:00:00 2001 From: Garric Nahapetian Date: Fri, 26 Jan 2024 17:36:23 -0800 Subject: [PATCH 1/9] Add Superfluous Snapshots workflow --- .github/workflows/superfluous-snapshots.yml | 34 +++++++++++++++++++ .../LayoutItemTests/suprious-snapshot.txt | 1 + 2 files changed, 35 insertions(+) create mode 100644 .github/workflows/superfluous-snapshots.yml create mode 100644 Tests/LayoutTests/__Snapshots__/LayoutItemTests/suprious-snapshot.txt diff --git a/.github/workflows/superfluous-snapshots.yml b/.github/workflows/superfluous-snapshots.yml new file mode 100644 index 00000000..93236461 --- /dev/null +++ b/.github/workflows/superfluous-snapshots.yml @@ -0,0 +1,34 @@ +name: Superfluous Snapshots + +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: Superfluous Snapshots + runs-on: macos-13 + env: + SIMULATOR: iPhone 14 + steps: + - name: Checkout source + uses: actions/checkout@v3 + - name: Delete snapshots + run: make delete-snapshots + - name: Record snapshots + run: xcodebuild test -skipPackageUpdates -scheme "Layout" -destination "name=iPhone 14 Pro,OS=latest" + - name: Detect superfluous snapshots + run: | + if [ -z "$(git status --porcelain)" ] + then + echo "No superfluous snapshots detected." + else + echo "Superfluous snapshots detected." + exit 1 + fi diff --git a/Tests/LayoutTests/__Snapshots__/LayoutItemTests/suprious-snapshot.txt b/Tests/LayoutTests/__Snapshots__/LayoutItemTests/suprious-snapshot.txt new file mode 100644 index 00000000..5134ea08 --- /dev/null +++ b/Tests/LayoutTests/__Snapshots__/LayoutItemTests/suprious-snapshot.txt @@ -0,0 +1 @@ +suprious-snapshot From 28c14b3107713a0ae0d217bea6fd5656d7785f16 Mon Sep 17 00:00:00 2001 From: Garric Nahapetian Date: Fri, 26 Jan 2024 17:49:49 -0800 Subject: [PATCH 2/9] Prevent job from exiting on failure --- .github/workflows/superfluous-snapshots.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/superfluous-snapshots.yml b/.github/workflows/superfluous-snapshots.yml index 93236461..f9916b32 100644 --- a/.github/workflows/superfluous-snapshots.yml +++ b/.github/workflows/superfluous-snapshots.yml @@ -22,7 +22,9 @@ jobs: - name: Delete snapshots run: make delete-snapshots - name: Record snapshots - run: xcodebuild test -skipPackageUpdates -scheme "Layout" -destination "name=iPhone 14 Pro,OS=latest" + run: | + set +e + xcodebuild test -skipPackageUpdates -scheme "Layout" -destination "name=iPhone 14 Pro,OS=latest" - name: Detect superfluous snapshots run: | if [ -z "$(git status --porcelain)" ] From f0bae8d99f26cb13ca86a164fef969ff6ac8709d Mon Sep 17 00:00:00 2001 From: Garric Nahapetian Date: Fri, 26 Jan 2024 17:52:29 -0800 Subject: [PATCH 3/9] Match existing workflows --- .github/workflows/superfluous-snapshots.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/superfluous-snapshots.yml b/.github/workflows/superfluous-snapshots.yml index f9916b32..bb989cff 100644 --- a/.github/workflows/superfluous-snapshots.yml +++ b/.github/workflows/superfluous-snapshots.yml @@ -21,10 +21,16 @@ jobs: uses: actions/checkout@v3 - name: Delete snapshots run: make delete-snapshots - - name: Record snapshots + - name: Resolve swift package + run: swift package resolve + - name: Resolve package dependencies + run: xcodebuild -resolvePackageDependencies + - name: Build + run: xcodebuild build-for-testing -scheme "Layout" -destination "name=$SIMULATOR,OS=latest" + - name: Test run: | set +e - xcodebuild test -skipPackageUpdates -scheme "Layout" -destination "name=iPhone 14 Pro,OS=latest" + xcodebuild test-without-building -scheme "Layout" -destination "name=$SIMULATOR,OS=latest" - name: Detect superfluous snapshots run: | if [ -z "$(git status --porcelain)" ] From 8542a3382f436f3ba07f89f93e9d7ba84b93b3b9 Mon Sep 17 00:00:00 2001 From: Garric Nahapetian Date: Fri, 26 Jan 2024 18:07:52 -0800 Subject: [PATCH 4/9] Continue on error --- .github/workflows/superfluous-snapshots.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/superfluous-snapshots.yml b/.github/workflows/superfluous-snapshots.yml index bb989cff..c56a7525 100644 --- a/.github/workflows/superfluous-snapshots.yml +++ b/.github/workflows/superfluous-snapshots.yml @@ -28,9 +28,8 @@ jobs: - name: Build run: xcodebuild build-for-testing -scheme "Layout" -destination "name=$SIMULATOR,OS=latest" - name: Test - run: | - set +e - xcodebuild test-without-building -scheme "Layout" -destination "name=$SIMULATOR,OS=latest" + continue-on-error: true + run: xcodebuild test-without-building -scheme "Layout" -destination "name=$SIMULATOR,OS=latest" - name: Detect superfluous snapshots run: | if [ -z "$(git status --porcelain)" ] From 5d886eaa4eff2fe4462d6466fde7655410a04a46 Mon Sep 17 00:00:00 2001 From: Garric Nahapetian Date: Fri, 26 Jan 2024 18:20:58 -0800 Subject: [PATCH 5/9] Remove temp file --- .../__Snapshots__/LayoutItemTests/suprious-snapshot.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Tests/LayoutTests/__Snapshots__/LayoutItemTests/suprious-snapshot.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutItemTests/suprious-snapshot.txt b/Tests/LayoutTests/__Snapshots__/LayoutItemTests/suprious-snapshot.txt deleted file mode 100644 index 5134ea08..00000000 --- a/Tests/LayoutTests/__Snapshots__/LayoutItemTests/suprious-snapshot.txt +++ /dev/null @@ -1 +0,0 @@ -suprious-snapshot From ae5a2e0d456580da6a6a1c1265643a1f77773fcd Mon Sep 17 00:00:00 2001 From: Garric Nahapetian Date: Mon, 29 Jan 2024 19:09:39 -0800 Subject: [PATCH 6/9] Move steps to existing workflow --- .github/workflows/superfluous-snapshots.yml | 41 --------------------- .github/workflows/swift.yml | 7 ++++ 2 files changed, 7 insertions(+), 41 deletions(-) delete mode 100644 .github/workflows/superfluous-snapshots.yml diff --git a/.github/workflows/superfluous-snapshots.yml b/.github/workflows/superfluous-snapshots.yml deleted file mode 100644 index c56a7525..00000000 --- a/.github/workflows/superfluous-snapshots.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Superfluous Snapshots - -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: Superfluous Snapshots - runs-on: macos-13 - env: - SIMULATOR: iPhone 14 - steps: - - name: Checkout source - uses: actions/checkout@v3 - - name: Delete snapshots - run: make delete-snapshots - - name: Resolve swift package - run: swift package resolve - - name: Resolve package dependencies - run: xcodebuild -resolvePackageDependencies - - name: Build - run: xcodebuild build-for-testing -scheme "Layout" -destination "name=$SIMULATOR,OS=latest" - - name: Test - continue-on-error: true - run: xcodebuild test-without-building -scheme "Layout" -destination "name=$SIMULATOR,OS=latest" - - name: Detect superfluous snapshots - run: | - if [ -z "$(git status --porcelain)" ] - then - echo "No superfluous snapshots detected." - else - echo "Superfluous snapshots detected." - exit 1 - fi diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 780c0cce..e02b5b19 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -52,3 +52,10 @@ jobs: 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)" From 9a03c6c97f107c15ce1514b5a1e648e4f08bc57e Mon Sep 17 00:00:00 2001 From: Garric Nahapetian Date: Tue, 30 Jan 2024 11:48:22 -0800 Subject: [PATCH 7/9] Use multiline formatting Co-authored-by: Christopher Fuller --- .github/workflows/swift.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index e02b5b19..74b6917e 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -55,7 +55,11 @@ jobs: - name: Delete snapshots run: make delete-snapshots - name: Record snapshots - run: xcodebuild test-without-building -scheme "Layout" -destination "name=$SIMULATOR,OS=latest" + 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)" From faf6cc9d603ebf269850b44836f0875aa8fe77a1 Mon Sep 17 00:00:00 2001 From: Garric Nahapetian Date: Tue, 30 Jan 2024 15:41:20 -0800 Subject: [PATCH 8/9] Add temp file --- .../__Snapshots__/LayoutItemTests/superfluous-snapshot.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Tests/LayoutTests/__Snapshots__/LayoutItemTests/superfluous-snapshot.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutItemTests/superfluous-snapshot.txt b/Tests/LayoutTests/__Snapshots__/LayoutItemTests/superfluous-snapshot.txt new file mode 100644 index 00000000..e69de29b From 164aa27ee7ab142e793fd0fc231cf997f4b2c7ad Mon Sep 17 00:00:00 2001 From: Garric Nahapetian Date: Tue, 30 Jan 2024 16:13:51 -0800 Subject: [PATCH 9/9] Revert "Add temp file" This reverts commit faf6cc9d603ebf269850b44836f0875aa8fe77a1. --- .../__Snapshots__/LayoutItemTests/superfluous-snapshot.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Tests/LayoutTests/__Snapshots__/LayoutItemTests/superfluous-snapshot.txt diff --git a/Tests/LayoutTests/__Snapshots__/LayoutItemTests/superfluous-snapshot.txt b/Tests/LayoutTests/__Snapshots__/LayoutItemTests/superfluous-snapshot.txt deleted file mode 100644 index e69de29b..00000000