Skip to content

Commit

Permalink
chore: force update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
tracy-french committed Nov 22, 2024
1 parent f0730c2 commit a80b01b
Show file tree
Hide file tree
Showing 106 changed files with 50,983 additions and 64,373 deletions.
107 changes: 107 additions & 0 deletions .github/workflows/update-snapshots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Update snapshots with manual approval

on:
issue_comment:
types: [created]

jobs:
update-snapshots:
name: Update Snapshots
if: github.event.issue.pull_request && contains(github.event.comment.body, '/approve-snapshots')
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
strategy:
fail-fast: false
matrix:
package: [react-components]

steps:
- name: Get branch of PR
uses: xt0rted/pull-request-comment-branch@v2
id: comment-branch

- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}
fetch-depth: 2
lfs: 'true'

- name: Comment action started
uses: thollander/actions-comment-pull-request@v3
with:
message: |
### Updating snapshots. Click [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) to see the status.
- uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
cache-dependency-path: '**/package-lock.json'

- name: node_modules cache
id: npm-cache
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-node_modules-${{hashFiles('**/package-lock.json')}}
restore-keys: |
${{ runner.os }}-node_modules-
- name: Install
if: steps.npm-cache.outputs.cache-hit != 'true'
shell: bash
env:
NODE_OPTIONS: '--max_old_space_size=8192'
run: npm ci --prefer-offline --no-audit --progress=false --workspaces --include-workspace-root

- name: Turbo cache
uses: actions/cache@v4
with:
path: '.turbo'
key: ${{ runner.os }}-turbo-playwright-${{ matrix.package}}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-pla`ywright-${{ matrix.package}}-
- name: Get installed Playwright version
id: playwright-version
run: echo "::set-output name=version::$(npm info @playwright/test version)"

- name: Playwright cache
uses: actions/cache@v4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: '${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}'
restore-keys: |
${{ runner.os }}-playwright-
- name: Install Playwright with dependencies
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps

- name: Install Playwright's dependencies
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: npx playwright install-deps

- name: Run Playwright update snapshots
run: npx turbo test:ui:update --filter=@iot-app-kit/${{matrix.package}}

- name: Commit and push updated snapshots
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'Chore: update @iot-app-kit/${{matrix.package}} snapshots'

- name: Comment success
uses: thollander/actions-comment-pull-request@v3
with:
message: |
### 🎉 Successfully updated and committed Playwright snapshots! 🎉
36 changes: 28 additions & 8 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ on:
pull_request:
push:
branches:
- sophon
- rc
- main
env:
PW_TEST_HTML_REPORT_OPEN: 'never'
jobs:
Expand Down Expand Up @@ -174,20 +174,40 @@ jobs:
run: npx playwright install-deps

- name: Playwright
run: npx turbo run test:ui:ci --filter=@iot-app-kit/${{matrix.package}}
run: |
npx turbo run test:ui:ci --filter=@iot-app-kit/${{matrix.package}} | tee output.log
if grep -q -e "Error: A snapshot doesn't exist at" -e "expect(locator).toHaveScreenshot(expected)" output.log; then
echo "Playwright tests failed due to a snapshot issue."
echo "SNAPSHOT_DIFFERENCES=true" >> $GITHUB_ENV
exit 1
elif grep -q "failed" output.log; then
echo "Playwright tests failed due to a non-snapshot issue."
exit 1
fi
- name: Test report
id: upload-test-report
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.package }}-playwright-report
path: packages/**/playwright-report
retention-days: 30

- name: Failure report
id: upload-failure-report
uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ matrix.package }}-test-results
path: packages/**/test-results
retention-days: 30

- name: Test report
uses: actions/upload-artifact@v4
if: always()
- name: Comment on PR with report link
uses: thollander/actions-comment-pull-request@v3
if: ${{ failure() && env.SNAPSHOT_DIFFERENCES == 'true' }}
with:
name: ${{ matrix.package }}-playwright-report
path: packages/**/playwright-report
retention-days: 30
message: |
### Playwright visual snapshot differences were detected.
View the [Playwright report](${{ steps.upload-test-report.outputs.artifact-url }}) to review the visual differences.
**To approve the snapshot changes and update the snapshots, please comment:** /approve-snapshots
2 changes: 0 additions & 2 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@
"packages/source-iottwinmaker": "12.1.0",
".": "12.1.0",
"packages/testing-util": "12.1.0",
"configuration/ts-config": "12.1.0",
"configuration/eslint-config": "12.1.0",
"packages/tools-iottwinmaker": "12.1.0"
}
10 changes: 6 additions & 4 deletions configuration/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
"name": "eslint-config-iot-app-kit",
"main": "index.js",
"private": true,
"version": "12.1.0",
"files": [
"index.js"
],
"scripts": {
"clean:nuke": "rimraf node_modules"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.62.0",
Expand All @@ -22,9 +27,6 @@
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-unused-imports": "2.0.0"
},
"files": [
"index.js"
],
"devDependencies": {
"@types/node": "^18.16.18",
"eslint-import-resolver-typescript": "^3.6.0",
Expand Down
Loading

0 comments on commit a80b01b

Please sign in to comment.