Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release' into SLB-405-Fade-effect
Browse files Browse the repository at this point in the history
  • Loading branch information
Luqmaan Essop committed Jun 10, 2024
2 parents 317b64c + 2b815f7 commit 6fcb3a4
Show file tree
Hide file tree
Showing 48 changed files with 2,496 additions and 1,486 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
.idea/inspectionProfiles
.idea/git_toolbox_prj.xml
build-storybook.log
storybook-static
coverage
Expand Down
2 changes: 1 addition & 1 deletion .idea/prettier.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
4 changes: 1 addition & 3 deletions 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 All @@ -24,8 +24,6 @@
"content:import": "pnpm drush php-script web/modules/custom/test_content/import.php",
"config:export": "pnpm drush cex -y",
"config:import": "pnpm drush -y cim",
"schema:test": "pnpm jest --testMatch '<rootDir>/generated/__tests__/test-queries.js' --passWithNoTests",
"schema:test:update": "pnpm schema:test -u",
"import-translations": "pnpm drush scr scripts/translations-import.php"
},
"peerDependencies": {
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',
},
};
1 change: 1 addition & 0 deletions packages/drupal/gutenberg_blocks/images/icons/email.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/drupal/gutenberg_blocks/images/icons/phone.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/drupal/gutenberg_blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dev": "vite build --watch",
"prep": "vite build",
"test:static": "tsc --noEmit && eslint \"**/*.{ts,tsx,js,jsx}\" --ignore-path=\"./.eslintignore\"",
"test:fix": "tsc --noEmit && eslint \"**/*.{ts,tsx,js,jsx}\" --ignore-path=\"./.eslintignore\" --fix",
"gutenberg:generate": "node ./scripts/generate-gutenberg-block.js"
},
"dependencies": {
Expand Down
63 changes: 63 additions & 0 deletions packages/drupal/gutenberg_blocks/src/blocks/info-grid-item.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { InnerBlocks, InspectorControls } from 'wordpress__block-editor';
import { registerBlockType } from 'wordpress__blocks';
import { PanelBody, SelectControl } from 'wordpress__components';

import {
iconImagePreview,
Icons,
limitedIconListOption,
} from '../utils/icon-list';

// @ts-ignore
const { t: __ } = Drupal;

registerBlockType('custom/info-grid-item', {
title: __('Info Grid Item'),
icon: 'align-wide',
category: 'layout',
parent: ['custom/info-grid'],
attributes: {
icon: {
type: 'string',
default: '',
},
},
edit: (props) => {
const { setAttributes } = props;
const iconPreview = iconImagePreview(props.attributes.icon as string);

return (
<>
<InspectorControls>
<PanelBody title={__('Select an icon')}>
<SelectControl
value={props.attributes.icon as string}
options={limitedIconListOption([
Icons.EMAIL,
Icons.PHONE,
Icons.LIFE_RING,
])}
onChange={(icon: string) => {
setAttributes({ icon });
}}
/>
</PanelBody>
</InspectorControls>

<div className={'container-wrapper'}>
<div className={'container-label'}>{__('Info Grid Item')}</div>
<div className={'info-grid-icon'} style={{ maxWidth: '50px' }}>
{iconPreview && (
<img src={iconPreview} alt={props.attributes.icon as string} />
)}
</div>
<InnerBlocks
templateLock={false}
allowedBlocks={['custom/heading', 'core/paragraph', 'custom/cta']}
/>
</div>
</>
);
},
save: () => <InnerBlocks.Content />,
});
40 changes: 40 additions & 0 deletions packages/drupal/gutenberg_blocks/src/blocks/info-grid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { InnerBlocks } from 'wordpress__block-editor';
import { registerBlockType } from 'wordpress__blocks';
import { useSelect } from 'wordpress__data';

// @ts-ignore
const { t: __ } = Drupal;

const MAX_BLOCKS: number = 3;

registerBlockType('custom/info-grid', {
title: __('Info Grid'),
icon: 'editor-insertmore',
category: 'layout',
attributes: {},
edit: (props) => {
/* eslint-disable-next-line */
const { blockCount } = useSelect((select) => ({
blockCount: select('core/block-editor').getBlockCount(props.clientId),
}));

return (
<div className={'container-wrapper'}>
<div className={'container-label'}>{__('Info Grid')}</div>
<InnerBlocks
templateLock={false}
renderAppender={() => {
if (blockCount >= MAX_BLOCKS) {
return null;
} else {
return <InnerBlocks.DefaultBlockAppender />;
}
}}
allowedBlocks={['custom/info-grid-item']}
template={[]}
/>
</div>
);
},
save: () => <InnerBlocks.Content />,
});
2 changes: 2 additions & 0 deletions packages/drupal/gutenberg_blocks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ import './blocks/quote';
import './blocks/horizontal-separator';
import './blocks/accordion';
import './blocks/accordion-item-text';
import './blocks/info-grid';
import './blocks/info-grid-item';
Loading

0 comments on commit 6fcb3a4

Please sign in to comment.