Skip to content

Commit

Permalink
Build Portal before running "Run visual tests"
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Feb 1, 2025
1 parent 56f5888 commit e149030
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 46 deletions.
76 changes: 30 additions & 46 deletions .github/workflows/icons-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
process-icons:
name: Fetch and Build Icons

runs-on: ubuntu-latest
runs-on: macos-15

timeout-minutes: 60

Expand All @@ -48,67 +48,51 @@ jobs:
if: steps.modules-cache.outputs.cache-hit != 'true'
run: yarn install --immutable

- name: Use Playwright cache
uses: actions/cache@v4
id: playwright-cache
with:
path: |
~/Library/Caches/ms-playwright
~/.cache/ms-playwright
%USERPROFILE%\AppData\Local\ms-playwright
key: ${{ secrets.CACHE_VERSION }}-${{ runner.os }}-playwright-${{ hashFiles('**/yarn.lock') }}
- run: yarn workspace @dnb/eufemia playwright install --with-deps firefox
if: steps.playwright-cache.outputs.cache-hit != 'true'
- run: yarn workspace @dnb/eufemia playwright install-deps firefox
if: steps.playwright-cache.outputs.cache-hit == 'true'

- name: Icons fetch and prebuild
run: yarn workspace @dnb/eufemia prebuild:figma:ci

- name: Prebuild Library
run: yarn workspace @dnb/eufemia prebuild:ci

- name: Postbuild Library
run: yarn workspace @dnb/eufemia postbuild:ci

- name: Test prebuild
run: yarn workspace @dnb/eufemia test:update

- name: Build portal
run: yarn workspace dnb-design-system-portal build:visual-test

- name: Store portal artifacts
uses: actions/upload-artifact@v4
with:
name: portal-build-artifact
path: ./packages/dnb-design-system-portal/public

- name: Commit icons
run: yarn workspace @dnb/eufemia postbuild:commit

visual-test:
needs: process-icons
name: Run visual e2e-test for icons

runs-on: macos-latest

timeout-minutes: 60

steps:
- name: Git checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'

- name: Use yarn cache
uses: actions/cache@v4
id: yarn-cache
with:
path: ./.yarn/cache
key: ${{ secrets.CACHE_VERSION }}-${{ runner.os }}-deps-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ secrets.CACHE_VERSION }}-${{ runner.os }}-deps-

- name: Install dependencies
run: yarn install --immutable
- name: Run visual tests
run: yarn workspace dnb-design-system-portal test:screenshots:ci:update

- name: Re-store portal artifacts
uses: actions/download-artifact@v4.1.7
- uses: actions/upload-artifact@v4
if: failure()
with:
name: portal-build-artifact
path: ./packages/dnb-design-system-portal/public
name: visual-test-artifact
path: |
./packages/dnb-eufemia/src/**/*.snap-diff.png
./packages/dnb-eufemia/jest-visual-diff-report/*
- name: Run visual tests
run: yarn workspace dnb-design-system-portal test:screenshots:ci
- name: Run visual tests info
if: failure()
run: echo '\n\n👉 Download the diff files as a ZIP file. \nIt is called "visual-test-artifact" and you find it in the test "Summary" under "Artifacts".\n\n\n'

- name: Commit updated snapshots
- name: Commit icons and updated snapshots
run: yarn workspace @dnb/eufemia postbuild:commit

- name: Slack
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/visual-regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ env:
ALGOLIA_SEARCH_KEY: ${{ secrets.ALGOLIA_SEARCH_KEY }}
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
RUN_POST_BUILD: ${{ startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/heads/v') }}
RUN_VISUAL_TEST: ${{ !startsWith(github.ref, 'refs/heads/icon') }}

jobs:
visual-regression:
Expand Down Expand Up @@ -91,9 +92,11 @@ jobs:
run: yarn workspace @dnb/eufemia postbuild:ci

- name: Build portal
if: env.RUN_VISUAL_TEST == 'true'
run: yarn workspace dnb-design-system-portal build:visual-test

- name: Run visual tests
if: env.RUN_VISUAL_TEST == 'true'
run: yarn workspace dnb-design-system-portal test:screenshots:ci

- uses: actions/upload-artifact@v4
Expand Down

0 comments on commit e149030

Please sign in to comment.