Skip to content

Add drag icon, update dots icon #2100

Add drag icon, update dots icon

Add drag icon, update dots icon #2100

Workflow file for this run

name: Pull Request
on:
pull_request:
branches:
- main
env:
PREVIEW_PATH: preview/${{ github.event.pull_request.head.ref }}
PREFIX_PATHS: true
##
# Sjekker først om det er endringer som krever grundigere test.
# Bygger i så fall pakkene og cacher dem via Nx.
# Bygger så portalen og en branch preview dersom det er visuelle endringer og cacher på samme måte.
# Cachen lastes ned av jobbene testlint, cypress.
# Førstnevnte kjører enhetstester, ESLint, og TypeScript typesjekk.
# N instanser av cypress-jobben spinner opp og kjører deler av testene fordelt mellom seg.
# Om en jobb har nye snapshots lastes disse opp som en artifact.
# Til slutt sjekker en jobb om nye snapshots har blitt generert av en eller
# flere av cypressjobbene. I så fall samles disse i én commit
# som pushes til branchen som testes.
##
jobs:
build:
outputs:
visual: ${{ steps.changes.outputs.visual }}
preview: ${{ steps.changes.outputs.preview }}
testlint: ${{ steps.changes.outputs.testlint }}
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
pull-requests: write
steps:
- name: Checkout
if: "!contains(github.event.sender.login, 'fremtind-bot')"
uses: actions/checkout@v3
- name: Check for changes that require extra verification
if: "!contains(github.event.sender.login, 'fremtind-bot')"
uses: ./actions/paths-filter
id: changes
with:
filters: |
testlint:
- "**/*.js"
- "**/*.scss"
- "**/*.ts"
- "**/*.tsx"
- "pnpm-lock.yaml"
visual:
- "cypress/**"
- "packages/**/*.spec.js"
- "packages/**/*.scss"
- "packages/core/**/!(*.d|*.test).ts"
- "packages/core/**/!(*.test).tsx"
- "packages/*-react/**/!(*.d|*.test).ts"
- "packages/*-react/**/!(*.test).tsx"
- "pnpm-lock.yaml"
preview:
- "packages/**/*.mdx"
- "portal/src/texts/**"
- name: Setup pnpm
if: steps.changes.outputs.has_matches == 'true' && !contains(github.event.sender.login, 'fremtind-bot')
uses: pnpm/action-setup@v2
with:
version: 7
- name: Setup Node
uses: actions/setup-node@v3
if: steps.changes.outputs.has_matches == 'true' && !contains(github.event.sender.login, 'fremtind-bot')
with:
node-version: 18
cache: "pnpm"
- name: Cypress binary cache
if: steps.changes.outputs.visual == 'true' && !contains(github.event.sender.login, 'fremtind-bot')
uses: actions/cache@v3
id: cypress-cache
with:
path: /home/runner/.cache/Cypress
key: cypresss-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Monorepo Runner Cache
if: steps.changes.outputs.has_matches == 'true' && !contains(github.event.sender.login, 'fremtind-bot')
uses: actions/cache@v3
id: nx-cache
with:
path: .nx
key: nx-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }}
restore-keys: |
nx-${{ hashFiles('pnpm-lock.yaml') }}-
- name: Install dependencies and build packages
if: steps.changes.outputs.has_matches == 'true' && !contains(github.event.sender.login, 'fremtind-bot')
run: pnpm ci:install
- name: Cypress binary install
if: steps.changes.outputs.visual == 'true' && !contains(github.event.sender.login, 'fremtind-bot')
run: pnpm cypress install
# Installeringen printer ikke hvor den ligger første gang, men gjør det på n+1
- name: Cypress binary install debug
if: steps.changes.outputs.visual == 'true' && !contains(github.event.sender.login, 'fremtind-bot')
run: pnpm cypress install
- name: Add a comment with a link to the preview
if: (steps.changes.outputs.visual == 'true' || steps.changes.outputs.preview == 'true') && !contains(github.event.sender.login, 'fremtind-bot')
uses: marocchino/sticky-pull-request-comment@da224cb0e3c8b27cae68d40c93649421b5b93e45
with:
header: preview
GITHUB_TOKEN: ${{ secrets.FREMTIND_BOT_ACCESS_TOKEN }}
message: |
<span aria-hidden="true">🔄</span> **Gjør klar en forhåndsvisning…**
<span aria-hidden="true">🔍</span> Commit: ${{ github.sha }}
- name: Build site
if: (steps.changes.outputs.visual == 'true' || steps.changes.outputs.preview == 'true') && !contains(github.event.sender.login, 'fremtind-bot')
env:
GATSBY_MIXPANEL_PROJECT_ID: ${{ secrets.MIXPANEL_PROJECT_ID_TEST }}
run: pnpm build:docs
- name: Deploy preview
if: (steps.changes.outputs.visual == 'true' || steps.changes.outputs.preview == 'true') && !contains(github.event.sender.login, 'fremtind-bot')
env:
GH_TOKEN: ${{ secrets.BOT_PUBLISH_TOKEN }}
run: |
git config user.email "fremtind.designsystem@fremtind.no"
git config user.name "fremtind-bot"
git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/fremtind/jokul.git
pnpm gh-pages --add --dist portal/public --dest ${{ env.PREVIEW_PATH }} --message "docs: preview #${{ github.event.number }}"
- name: Add a comment with a link to the preview
if: (steps.changes.outputs.visual == 'true' || steps.changes.outputs.preview == 'true') && !contains(github.event.sender.login, 'fremtind-bot')
uses: marocchino/sticky-pull-request-comment@da224cb0e3c8b27cae68d40c93649421b5b93e45
with:
header: preview
GITHUB_TOKEN: ${{ secrets.FREMTIND_BOT_ACCESS_TOKEN }}
message: |
<span aria-hidden="true">✅</span> Forhåndsvisning: https://jokul.fremtind.no/${{ env.PREVIEW_PATH }}/
<span aria-hidden="true">🔍</span> Commit: ${{ github.sha }}
Forhåndsvisningen blir tilgjengelig innen et par minutter. Den fjernes automatisk når pull requesten lukkes.
testlint:
needs: [build]
if: needs.build.outputs.testlint == 'true' && !contains(github.event.sender.login, 'fremtind-bot')
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 7
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
- name: Monorepo Runner Cache
uses: actions/cache@v3
id: nx-cache
with:
path: .nx
key: nx-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }}
restore-keys: |
nx-${{ hashFiles('pnpm-lock.yaml') }}-
- name: Install dependencies and build packages
run: pnpm ci:install
- name: Lint and test
run: pnpm ci:test
cypress:
needs: [build]
if: needs.build.outputs.visual == 'true' && !contains(github.event.sender.login, 'fremtind-bot')
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Om du legger til flere grupper, husk å legge til en tilsvarende download-action i snapshot
forced-colors: [true, false]
permissions:
actions: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: "0" # Hent hele git-historikken, for lerna changed, som brukes i beregning av hvilke tester som skal kjøre
- name: Fetch version tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* # Hent tags, for lerna changed, som brukes i beregning av hvilke tester som skal kjøre
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 7
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
- name: Cypress binary cache
uses: actions/cache@v3
id: cypress-cache
with:
path: /home/runner/.cache/Cypress
key: cypresss-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Monorepo Runner Cache
uses: actions/cache@v3
id: nx-cache
with:
path: .nx
key: nx-${{ hashFiles('pnpm-lock.yaml') }}-${{ github.sha }}
restore-keys: |
nx-${{ hashFiles('pnpm-lock.yaml') }}-
- name: Build packages
run: pnpm ci:install
- name: Build site with path prefix
run: pnpm build:docs
- name: Calculate tests to run based on lerna changed
run: |
CHANGED_SPECS=$(node scripts/calculate-cypress-tests.js)
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "CHANGED_SPECS<<$EOF" >> $GITHUB_ENV
printf "%s\n" "${CHANGED_SPECS[@]}" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: Run Cypress tests
uses: cypress-io/github-action@v5
with:
# We install packages above
install: false
browser: chrome
start: pnpm serve
wait-on: "http://localhost:9000/${{ env.PREVIEW_PATH }}"
wait-on-timeout: 280
spec: |
${{ env.CHANGED_SPECS }}
env:
FORCED_COLORS: ${{ matrix.forced-colors }}
- name: Upload screenshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots-${{ matrix.forced-colors }}
path: |
cypress/screenshots
packages/*/integration/**/*.actual.png
packages/*/integration/**/*.diff.png
- name: Debug
if: success()
run: git status --porcelain
- name: Look for new snapshots
if: success()
uses: ./actions/changed-files
id: lfcf
with:
# See the micromatch docs for more examples: https://github.com/micromatch/micromatch#matching-features
patterns: |
**/__image_snapshots__/*
- name: Upload snapshots
uses: actions/upload-artifact@v3
if: steps.lfcf.outputs.has_changed_files == 'true'
with:
name: cypress-snapshots-${{ matrix.forced-colors }}
# GitHub will find the lowest common folder to reduce the number of folders
# in the uploaded artifact. If you want to preserve the same folder structure
# as in your repository when downloading the artifact, include a file from
# the root of your repository.
path: |
cypress.json
${{ steps.lfcf.outputs.changed_files }}
snapshots:
needs: [cypress]
if: needs.build.outputs.visual == 'true' && !contains(github.event.sender.login, 'fremtind-bot')
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.BOT_PUBLISH_TOKEN }}
- name: Download snapshots
uses: actions/download-artifact@v3
# Sannsynligvis lastet ikke alle jobbene opp nye snapshots
# Dette gjør at vi får noen errors i oppsummeringen, men selve
# bygget markeres som grønt.
continue-on-error: true
with:
name: cypress-snapshots-false
- name: Download snapshots
uses: actions/download-artifact@v3
continue-on-error: true
with:
name: cypress-snapshots-true
- name: Commit snapshots
run: |
git config user.email "fremtind.designsystem@fremtind.no"
git config user.name "fremtind-bot"
git add **/*.png || echo "No updated snapshots, nothing to add!"
git commit -m "chore: update cypress snapshots [ci skip cypress]" --no-verify || echo "No updated snapshots, nothing to commit!"
git push