Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…k-template into dev
  • Loading branch information
HagerDakroury committed Jun 14, 2024
2 parents 9e1718d + 1b68140 commit f5d3b69
Show file tree
Hide file tree
Showing 24 changed files with 1,375 additions and 1,391 deletions.
14 changes: 3 additions & 11 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,8 @@ runs:
- name: Install dependencies
shell: bash
run: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 pnpm i
run: pnpm i

- name: Cache playwright binaries
uses: actions/cache@v3
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}

- name: Install Playwright browsers
run: pnpm --filter "@custom-tests/e2e" download-browsers
- name: Check formatting
shell: bash
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: pnpm test:format
77 changes: 77 additions & 0 deletions .github/workflows/estimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Estimate
on:
pull_request:

jobs:
estimate:
name: Estimate
if: vars.JIRA_PROJECT_ID != ''
runs-on: ubuntu-20.04
steps:
- name: Start Check Run
id: check
env:
GH_TOKEN: ${{ github.token }}
run: |
CHECK_ID=$(gh api -X POST -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f 'name=Estimator' \
-f 'head_sha=${{ github.event.pull_request.head.sha }}' \
-f 'status=in_progress' \
-f 'output[title]=🎲 Estimation in progress' \
-f 'output[summary]=🎲 Estimation in progress' \
/repos/${{ github.repository }}/check-runs --jq '.id')
echo "check_id=$CHECK_ID" >> $GITHUB_OUTPUT
- name: Install estimator
run: npm install -g @amazeelabs/estimator

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Find common ancestor
id: ancestor
env:
BASE_BRANCH: ${{ github.base_ref }}
run:
echo "hash=$(git merge-base --fork-point origin/$BASE_BRANCH)" >>
$GITHUB_OUTPUT

- name: Estimate
id: estimate
env:
JIRA_PROJECT_ID: ${{ vars.JIRA_PROJECT_ID }}
PARENT_COMMIT: ${{ steps.ancestor.outputs.hash }}
DASHBOARD_ACCESS_TOKEN: ${{ secrets.DASHBOARD_ACCESS_TOKEN }}
run: echo "result=$(amazeelabs-estimator estimate)" >> $GITHUB_OUTPUT
continue-on-error: true

- name: Report success
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api -X PATCH -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f 'name=Estimator' \
-f 'head_sha=${{ github.event.pull_request.head.sha }}' \
-f 'conclusion=success' \
-f 'output[title]=🎲 ${{ steps.estimate.outputs.result }}' \
-f 'output[summary]=🎲 ${{ steps.estimate.outputs.result }}' \
/repos/${{ github.repository }}/check-runs/${{ steps.check.outputs.check_id }}
if: steps.estimate.outputs.result != ''

- name: Report error
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api -X PATCH -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f 'name=Estimator' \
-f 'head_sha=${{ github.event.pull_request.head.sha }}' \
-f 'conclusion=failure' \
-f 'output[title]=💥 Estimation failed' \
-f 'output[summary]=💥 Estimation failed' \
/repos/${{ github.repository }}/check-runs/${{ steps.check.outputs.check_id }}
if: steps.estimate.outputs.result == ''
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,25 @@ jobs:
target_branch: prod
github_token: ${{ secrets.GITHUB_TOKEN }}

update_dashboard:
name: Update dashboard
if: github.ref == 'refs/heads/release' && vars.JIRA_PROJECT_ID != ''
runs-on: ubuntu-20.04
steps:
- name: Install estimator
run: npm install -g @amazeelabs/estimator

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Update dashboard
env:
JIRA_PROJECT_ID: ${{ vars.JIRA_PROJECT_ID }}
DASHBOARD_ACCESS_TOKEN: ${{ secrets.DASHBOARD_ACCESS_TOKEN }}
run: amazeelabs-estimator update

docker_build:
name: Docker Build
if:
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/write-dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Write dashboard history
on:
workflow_dispatch:

jobs:
write_dashboard:
name: Write dashboard history
if: github.ref == 'refs/heads/release' && vars.JIRA_PROJECT_ID != ''
runs-on: ubuntu-20.04
steps:
- name: Install estimator
run: npm install -g @amazeelabs/estimator

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Update dashboard
env:
JIRA_PROJECT_ID: ${{ vars.JIRA_PROJECT_ID }}
DASHBOARD_ACCESS_TOKEN: ${{ secrets.DASHBOARD_ACCESS_TOKEN }}
run: amazeelabs-estimator write-history
2 changes: 0 additions & 2 deletions .lagoon/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
COPY --from=node /usr/local/bin/node /usr/local/bin/node
RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm

ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1

# Install pnpm
RUN npm install -g [email protected] && pnpm config set store-dir /tmp/cache/pnpm

Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,21 @@ Other steps
- [Create a new Lagoon project](https://amazeelabs.atlassian.net/wiki/spaces/ALU/pages/368115717/Create+a+new+Lagoon+project)
- [Create a new Netlify project](https://amazeelabs.atlassian.net/wiki/spaces/ALU/pages/368017428/Create+a+new+Netlify+project)
- Check the [Environment overrides](#environment-overrides) section below
- Check the [Statistics and Estimations](#statistics-and-estimations) section
below
- Check the [Choose a CMS](#choose-a-cms) section below
- Create `dev` and `prod` branches (and optionally `stage`) from `release`

## Connect to automatic estimations

There are Github workflows that can connect to the
[Amazeelabs Dashboard](https://dashboard.amazeelabs.com) to log complexity
statistics and retrieve automatic estimations. To use that, provide a
`JIRA_PROJECT_ID` environment variable in the Github repository variables.

The project should then show up on
[Estimator page](https://dashboard.amazeelabs.com/estimator).

## Choose a CMS

The template comes with Drupal and Decap CMS enabled by default. To disable
Expand Down
2 changes: 1 addition & 1 deletion apps/cms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"drush": "SB_ENVIRONMENT=1 SIMPLETEST_DB=sqlite://localhost/sites/default/files/.sqlite DRUSH_OPTIONS_URI=http://127.0.0.1:8888 vendor/bin/drush",
"silverback": "SB_ENVIRONMENT=1 SIMPLETEST_DB=sqlite://localhost/sites/default/files/.sqlite SB_ADMIN_USER=admin SB_ADMIN_PASS=admin vendor/bin/silverback",
"drupal-install": "SB_SETUP=1 pnpm silverback setup --profile minimal && pnpm content:import && pnpm drush php-eval 'node_access_rebuild();' && rm -rf install-cache.zip && pnpm fix-premissions && pnpm ensure-working-db",
"export-webforms": "pnpm run --filter '@custom-tests/e2e' download-browsers && pnpm run --filter '@custom-tests/e2e' webform-snapshots",
"export-webforms": "pnpm turbo --filter '@custom-tests/e2e' webform-snapshots",
"start": "cd web; SB_ENVIRONMENT=1 SIMPLETEST_DB=sqlite://localhost/sites/default/files/.sqlite DRUSH_OPTIONS_URI=http://127.0.0.1:8888 php -S 0.0.0.0:8888 .ht.router.php # no drush to avoid the drush server timeout",
"dev": "pnpm start",
"clear": "pnpm drush cr",
Expand Down
12 changes: 12 additions & 0 deletions estimator.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default {
documents: [
'packages/schema/src/fragments/**/*.{gql,graphql,graphqls}',
'packages/schema/src/operations/*.{gql,graphql,graphqls}',
'packages/schema/src/schema.graphql',
],
storage: {
id: process.env.JIRA_PROJECT_ID,
token: process.env.DASHBOARD_ACCESS_TOKEN,
api: 'https://dashboard.amazeelabs.com/api/estimator',
},
};
9 changes: 3 additions & 6 deletions packages/ui/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { StorybookConfig } from '@storybook/react-vite';
import pluginTurbosnap from 'vite-plugin-turbosnap';
import { mergeConfig, UserConfig } from 'vite';
import { imagetools } from 'vite-imagetools';
import { resolve, dirname } from 'path';
Expand All @@ -19,18 +18,16 @@ const config: StorybookConfig = {
),
},
},
plugins: [
pluginTurbosnap({ rootDir: config.root ?? process.cwd() }),
imagetools(),
],
plugins: [imagetools()],
} satisfies UserConfig),
staticDirs: ['../static/public', '../static/stories'],
stories: ['../src/**/*.stories.@(ts|tsx|mdx)'],
stories: ['../src/**/*.@(mdx|stories.@(ts|tsx))'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-coverage',
'@storybook/addon-a11y',
],
framework: {
name: '@storybook/react-vite',
Expand Down
45 changes: 45 additions & 0 deletions packages/ui/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,51 @@ const SWRCacheDecorator: Decorator = (Story) => {

export const parameters = {
chromatic: { viewports: [320, 840, 1440] },
a11y: {
// Optional selector to inspect
element: '#storybook-root',
config: {
rules: [
{
// The autocomplete rule will not run based on the CSS selector provided
id: 'autocomplete-valid',
selector: '*:not([autocomplete="nope"])',
},
{
// Setting the enabled option to false will disable checks for this particular rule on all stories.
id: 'image-alt',
enabled: false,
},
{
// Setting the enabled option to false will disable checks for this particular rule on all stories.
id: 'color-contrast',
reviewOnFail: true,
},
{
id: 'link-name',
reviewOnFail: true,
},
{
id: 'duplicate-id',
reviewOnFail: true,
},
{
id: 'landmark-no-duplicate-main',
reviewOnFail: true,
},
{
id: 'landmark-main-is-top-level',
reviewOnFail: true,
},
{
id: 'landmark-unique',
reviewOnFail: true,
},
],
},
// Axe's options parameter
options: {},
},
};

export const decorators = [LocationDecorator, IntlDecorator, SWRCacheDecorator];
32 changes: 32 additions & 0 deletions packages/ui/.storybook/test-runner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { TestRunnerConfig } from '@storybook/test-runner';
import { getStoryContext } from '@storybook/test-runner';

import { injectAxe, checkA11y, configureAxe } from 'axe-playwright';

/*
* See https://storybook.js.org/docs/writing-tests/test-runner#test-hook-api
* to learn more about the test-runner hooks API.
*/
const config: TestRunnerConfig = {
async preVisit(page) {
await injectAxe(page);
},
async postVisit(page, context) {
// Get the entire context of a story, including parameters, args, argTypes, etc.
const storyContext = await getStoryContext(page, context);

// Apply story-level a11y rules
await configureAxe(page, {
rules: storyContext.parameters?.a11y?.config?.rules,
});

await checkA11y(page, '#storybook-root', {
detailedReport: true,
detailedReportOptions: {
html: true,
},
});
},
};

export default config;
27 changes: 13 additions & 14 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"prep:iframe": "NODE_ENV=production pnpm postcss src/iframe.css -o build/iframe.css",
"prep:gutenberg": "NODE_ENV=production PREFIX=gutenberg pnpm postcss src/tailwind.css -o build/gutenberg.css",
"prep:i18n": "formatjs extract 'src/**/*.ts*' --ignore='**/*.d.ts' --ignore='**/*.stories.ts*' --out-file build/translatables.json --id-interpolation-pattern '[sha512:contenthash:base64:6]'\n",
"build": "storybook build",
"build": "storybook build --stats-json",
"dev": "storybook dev -p 6006 --no-open",
"start": "serve storybook-static -p 6006 > /dev/null 2>&1",
"test:static": "tsc --noEmit && eslint \"**/*.{ts,tsx,js,jsx}\" --ignore-path=\"./.eslintignore\"",
Expand Down Expand Up @@ -63,28 +63,28 @@
"@amazeelabs/bridge-storybook": "^1.2.8",
"@amazeelabs/cloudinary-responsive-image": "^1.6.15",
"@formatjs/cli": "^6.2.4",
"@storybook/addon-actions": "^7.6.7",
"@storybook/addon-coverage": "^1.0.0",
"@storybook/addon-essentials": "^7.6.7",
"@storybook/addon-interactions": "^7.6.7",
"@storybook/addon-links": "^7.6.7",
"@storybook/blocks": "^7.6.7",
"@storybook/react": "^7.6.7",
"@storybook/react-vite": "^7.6.7",
"@storybook/test": "8.0.0-alpha.14",
"@storybook/test-runner": "^0.16.0",
"@storybook/addon-actions": "^8.1.6",
"@storybook/addon-coverage": "^1.0.4",
"@storybook/addon-essentials": "^8.1.6",
"@storybook/addon-interactions": "^8.1.6",
"@storybook/addon-links": "^8.0.8",
"@storybook/blocks": "^8.1.6",
"@storybook/react": "^8.1.6",
"@storybook/react-vite": "^8.1.6",
"@storybook/test": "8.1.6",
"@storybook/test-runner": "^0.18.2",
"@swc/cli": "^0.1.63",
"@swc/core": "^1.3.102",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.10",
"@testing-library/react": "^14.1.2",
"@types/hast": "^2.3.9",
"@types/react": "^18.2.46",
"@types/react-body-classname": "^1.1.10",
"@types/react-dom": "^18.2.18",
"@vitejs/plugin-react-swc": "^3.5.0",
"autoprefixer": "^10.4.16",
"axe-playwright": "^2.0.1",
"cssnano": "^6.0.3",
"eslint-plugin-formatjs": "^4.11.3",
"eslint-plugin-storybook": "^0.6.15",
Expand All @@ -100,12 +100,11 @@
"react-dom": "^18.2.0",
"serve": "^14.2.1",
"start-server-and-test": "^2.0.3",
"storybook": "^7.6.7",
"storybook": "^8.1.6",
"tailwindcss": "^3.4.0",
"typescript": "^5.3.3",
"vite": "^5.0.10",
"vite-imagetools": "^6.2.9",
"vite-plugin-turbosnap": "^1.0.3",
"vitest": "^1.1.1"
}
}
Loading

0 comments on commit f5d3b69

Please sign in to comment.