Skip to content

Commit

Permalink
only trigger tests if library component file changes
Browse files Browse the repository at this point in the history
  • Loading branch information
robonyong committed Aug 14, 2024
1 parent 8a79a5d commit a866897
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 27 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/chromatic-vrt.yml

This file was deleted.

44 changes: 44 additions & 0 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Chromatic

on: workflow_call

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

permissions:
actions: write
contents: read

jobs:
chromatic:
name: Run Chromatic
runs-on: ubuntu-latest
steps:
- name: List all changed files
env:
ALL_CHANGED_FILES: ${{ steps.ui-changes.outputs.all_changed_files }}
ANY_CHANGED: ${{ steps.ui-changes.outputs.any_changed }}
run: |
echo "Found changed ${#ALL_CHANGED_FILES[@]} files"
for file in ${ALL_CHANGED_FILES}; do
echo "$file"
done
- name: Checkout code
uses: actions/checkout@v4
with:
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 Visual Regression Tests
uses: chromaui/action@latest
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
autoAcceptChanges: 'main'
exitZeroOnChanges: true
exitOnceUploaded: true
33 changes: 33 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 'CI checks'

on:
pull_request:
branches:
- main

jobs:
ui-changes:
runs-on: ubuntu-latest
name: ui-changes
outputs:
all_changed_files: ${{ steps.ui-changes.outputs.all_changed_files }}
any_changed: ${{ steps.ui-changes.outputs.any_changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files: |
src/**
!src/demo/**
.storybook/**
chromatic:
name: Run Chromatic
needs: [ui-changes]
if: ${{ needs.ui-changes.outputs.any_changed == 'true' }}
uses: ./.github/workflows/chromatic.yml
secrets: inherit

0 comments on commit a866897

Please sign in to comment.