Skip to content

Commit

Permalink
introduce VRT test failures (#45)
Browse files Browse the repository at this point in the history
* introduce test failures

* only trigger tests if library component file changes

* deliberately introduce visual change

* revert visual change
  • Loading branch information
robonyong authored Aug 15, 2024
1 parent 41884ba commit 2b0daba
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: 'Chromatic VRT'
name: Chromatic

on:
pull_request:
branches:
- main
on: workflow_call

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-chromatic
cancel-in-progress: true

permissions:
actions: write
contents: read

jobs:
chromatic:
Expand All @@ -16,10 +21,15 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
cache: npm
cache-dependency-path: ./package.json
node-version: 20
- name: Install dependencies
run: npm ci
- name: Run Chromatic
- name: Run Visual Regression Tests
uses: chromaui/action@latest
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
autoAcceptChanges: 'main'
exitZeroOnChanges: true
exitOnceUploaded: true
43 changes: 43 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: 'CI checks'

on:
pull_request:
branches:
- main

jobs:
ui-changes:
runs-on: ubuntu-latest
name: ui-changes
outputs:
any_modified: ${{ steps.ui-changes.outputs.any_modified }}
all_modified_files: ${{ steps.ui-changes.outputs.all_modified_files }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: ui-changes
uses: tj-actions/changed-files@v44
with:
write_output_files: true
files: |
src/**
!src/demo/**
.storybook/**
- name: List all changed files
env:
ALL_MODIFIED_FILES: ${{ steps.ui-changes.outputs.all_modified_files }}
ANY_MODIFIED: ${{ steps.ui-changes.outputs.any_modified }}
run: |
echo "Found ${#ALL_MODIFIED_FILES[@]} changed UI file(s)"
for file in ${ALL_MODIFIED_FILES}; do
echo "$file"
done
chromatic:
name: Run Chromatic
needs: [ui-changes]
if: ${{ needs.ui-changes.outputs.any_modified == 'true' }}
uses: ./.github/workflows/chromatic.yml
secrets: inherit
1 change: 1 addition & 0 deletions src/demo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,5 @@ export default function Demo() {
</div>
);
}

createRoot(document.getElementById('app') as HTMLDivElement).render(<Demo />);

0 comments on commit 2b0daba

Please sign in to comment.