2023-08-03 10:11:18 +00:00
|
|
|
name: 'UI tests'
|
|
|
|
|
2023-08-23 18:37:26 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2023-08-23 18:38:42 +00:00
|
|
|
- '*'
|
2023-08-23 18:38:10 +00:00
|
|
|
- '!main'
|
2023-08-03 10:11:18 +00:00
|
|
|
|
2023-08-23 18:27:07 +00:00
|
|
|
permissions:
|
2023-08-23 18:46:16 +00:00
|
|
|
pull-requests: write
|
2023-08-23 18:57:32 +00:00
|
|
|
deployments: write
|
2023-08-23 18:27:07 +00:00
|
|
|
|
2023-08-03 10:11:18 +00:00
|
|
|
jobs:
|
2023-08-03 10:34:21 +00:00
|
|
|
cache-dependencies:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout Commit
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Cache yarn dependencies and cypress
|
|
|
|
uses: actions/cache@v2
|
|
|
|
id: yarn-cache
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cache/Cypress
|
|
|
|
node_modules
|
|
|
|
key: ${{ runner.os }}-yarn-v3-${{ hashFiles('**/yarn.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-yarn-v3
|
|
|
|
- name: Install dependencies if cache invalid
|
|
|
|
if: steps.yarn-cache.outputs.cache-hit != 'true'
|
|
|
|
run: yarn
|
|
|
|
|
2023-08-23 18:22:36 +00:00
|
|
|
build-and-deploy:
|
2023-08-07 07:35:38 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: cache-dependencies
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2023-08-23 18:27:07 +00:00
|
|
|
- name: Get PR number
|
|
|
|
id: pull_request
|
2023-08-25 09:43:30 +00:00
|
|
|
run: echo "::set-output name=number::$(gh pr view --json number -q .number || echo "null")"
|
2023-08-23 18:27:07 +00:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2023-08-07 07:35:38 +00:00
|
|
|
- uses: actions/setup-node@v2
|
|
|
|
with:
|
|
|
|
node-version: '18.x'
|
|
|
|
- name: Restore yarn dependencies
|
|
|
|
uses: actions/cache@v2
|
|
|
|
id: yarn-cache
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cache/Cypress
|
|
|
|
node_modules
|
|
|
|
key: ${{ runner.os }}-yarn-v3-${{ hashFiles('**/yarn.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-yarn-v3
|
|
|
|
- name: Build
|
|
|
|
run: yarn build
|
2023-09-26 09:23:26 +00:00
|
|
|
- name: Check formatting
|
|
|
|
run: yarn format:check
|
2023-08-23 18:22:36 +00:00
|
|
|
- name: Pull Vercel configuration
|
2024-02-27 11:45:17 +00:00
|
|
|
run: yarn vercel pull --scope metacraft-labs --yes --token ${{ secrets.vercel_token }}
|
2023-08-23 18:22:36 +00:00
|
|
|
- name: Build Vercel bundle
|
|
|
|
run: yarn vercel build
|
|
|
|
- name: Deploy to Vercel
|
2024-02-27 11:45:17 +00:00
|
|
|
run: yarn vercel deploy --scope metacraft-labs --prebuilt --token ${{ secrets.vercel_token }} > _vercel-deployment-url
|
2023-08-23 18:22:36 +00:00
|
|
|
- name: Comment on PR with deployment URL
|
|
|
|
uses: actions/github-script@v6
|
|
|
|
with:
|
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
script: |
|
2023-08-25 09:43:30 +00:00
|
|
|
const pullRequestNumber = ${{ steps.pull_request.outputs.number }};
|
|
|
|
if (pullRequestNumber === null) {
|
|
|
|
return;
|
|
|
|
}
|
2023-08-23 18:22:36 +00:00
|
|
|
const fs = require('fs');
|
|
|
|
const deploymentUrl = fs.readFileSync('_vercel-deployment-url', 'utf8');
|
|
|
|
await github.rest.issues.createComment({
|
2023-08-23 18:27:07 +00:00
|
|
|
issue_number: ${{ steps.pull_request.outputs.number }},
|
2023-08-23 18:22:36 +00:00
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
body: `Deployed to ${deploymentUrl}`,
|
|
|
|
});
|
2023-08-23 18:53:03 +00:00
|
|
|
- name: Add deployment to PR
|
|
|
|
uses: actions/github-script@v6
|
2023-08-23 19:15:42 +00:00
|
|
|
id: deployment
|
2023-08-23 18:53:03 +00:00
|
|
|
with:
|
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
script: |
|
|
|
|
const fs = require('fs');
|
|
|
|
const deploymentUrl = fs.readFileSync('_vercel-deployment-url', 'utf8');
|
2023-08-23 19:15:42 +00:00
|
|
|
const deployment = await github.rest.repos.createDeployment({
|
2023-08-23 18:53:03 +00:00
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
ref: context.sha,
|
|
|
|
environment: 'preview',
|
|
|
|
transient_environment: true,
|
|
|
|
required_contexts: [],
|
|
|
|
auto_merge: false,
|
|
|
|
production_environment: false,
|
|
|
|
payload: JSON.stringify({
|
|
|
|
deploymentUrl,
|
|
|
|
}),
|
|
|
|
});
|
2023-08-23 19:15:42 +00:00
|
|
|
console.log("::set-output name=deployment_id::" + deployment.data.id);
|
2023-08-23 19:09:30 +00:00
|
|
|
- name: Add deployment status to PR
|
|
|
|
uses: actions/github-script@v6
|
|
|
|
with:
|
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
script: |
|
|
|
|
const fs = require('fs');
|
|
|
|
const deploymentUrl = fs.readFileSync('_vercel-deployment-url', 'utf8');
|
|
|
|
await github.rest.repos.createDeploymentStatus({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
2023-08-23 19:15:42 +00:00
|
|
|
deployment_id: ${{ steps.deployment.outputs.deployment_id }},
|
2023-08-23 19:09:30 +00:00
|
|
|
state: 'success',
|
|
|
|
environment_url: deploymentUrl,
|
|
|
|
log_url: deploymentUrl,
|
|
|
|
description: 'Deployed to Vercel',
|
|
|
|
environment: 'preview',
|
|
|
|
auto_inactive: true,
|
|
|
|
});
|
2023-08-07 07:35:38 +00:00
|
|
|
|
2023-08-03 10:11:18 +00:00
|
|
|
interaction-and-and-accessibility:
|
|
|
|
runs-on: ubuntu-latest
|
2023-08-03 10:34:21 +00:00
|
|
|
needs: cache-dependencies
|
2023-08-03 10:11:18 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/setup-node@v2
|
|
|
|
with:
|
|
|
|
node-version: '18.x'
|
2023-08-03 10:34:21 +00:00
|
|
|
- name: Restore yarn dependencies
|
|
|
|
uses: actions/cache@v2
|
|
|
|
id: yarn-cache
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cache/Cypress
|
|
|
|
node_modules
|
|
|
|
key: ${{ runner.os }}-yarn-v3-${{ hashFiles('**/yarn.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-yarn-v3
|
2023-08-03 10:11:18 +00:00
|
|
|
- name: Install Playwright
|
|
|
|
run: npx playwright install --with-deps
|
|
|
|
- name: Build Storybook
|
|
|
|
run: yarn build-storybook --quiet
|
2023-08-21 11:18:43 +00:00
|
|
|
- name: Run Storybook tests
|
2023-08-03 10:11:18 +00:00
|
|
|
run: |
|
|
|
|
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
|
|
|
|
"npx http-server storybook-static --port 6006 --silent" \
|
2023-08-03 10:53:16 +00:00
|
|
|
"npx wait-on tcp:127.0.0.1:6006 && yarn test-storybook"
|