Merge pull request #3556 from SwiftPackageIndex/dependabot/swift/swif… #4830
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright Dave Verwer, Sven A. Schmidt, and other contributors. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: Snapshots | |
on: | |
workflow_dispatch: | |
push: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
snapshots: | |
name: Image Snapshots | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Build Front-End | |
run: make build-front-end | |
- name: Copy Front-End | |
run: cp -a ./Public/* ./Tests/AppTests/__Snapshots__/WebpageSnapshotTests | |
- name: Determine Comparison Git Reference | |
id: determine-comparison-ref | |
run: | | |
branch=$(git branch --show-current) | |
if [ $branch == "main" ]; then | |
echo "comparison-ref=HEAD^" >> $GITHUB_OUTPUT | |
else | |
echo "comparison-ref=origin/main" >> $GITHUB_OUTPUT | |
fi | |
- name: Diff for Front-End Changes | |
id: front-end-changes | |
run: | | |
filecount=$(git diff ${{steps.determine-comparison-ref.outputs.comparison-ref}} --shortstat "**.html" "**.scss" "**.js" ".percy.yml" ".github/workflows/snapshots.yml" | awk '{print $1}') | |
echo "matching-files=${filecount:-0}" >> $GITHUB_OUTPUT | |
- name: Run Percy | |
if: steps.front-end-changes.outputs.matching-files != '0' | |
run: | | |
npm install -g @percy/cli | |
echo "=== Installed Percy Version ===" | |
npx percy --version | |
echo "=== Running Snapshots ===" | |
npx percy snapshot ./Tests/AppTests/__Snapshots__/WebpageSnapshotTests | |
env: | |
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} |